Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: profile card #1319

Open
wants to merge 4 commits into
base: ui/redesign
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/uni_ui/lib/cards/course_grade_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ class CourseGradeCard extends StatelessWidget {
{required this.courseName,
required this.ects,
required this.grade,
required this.tooltip,
super.key});

final String courseName;
final double ects;
final double grade;
final String tooltip;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return GenericCard(
key: key,
tooltip: tooltip,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.35,
height: MediaQuery.of(context).size.height * 0.09,
Expand Down
3 changes: 3 additions & 0 deletions packages/uni_ui/lib/cards/exam_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ExamCard extends StatelessWidget {
required this.acronym,
required this.rooms,
required this.type,
required this.tooltip,
this.startTime,
this.isInvisible = false,
this.showIcon = true,
Expand All @@ -20,6 +21,7 @@ class ExamCard extends StatelessWidget {
final String acronym;
final List<String> rooms;
final String type;
final String tooltip;
final String? startTime;
final bool isInvisible;
final bool showIcon;
Expand All @@ -38,6 +40,7 @@ class ExamCard extends StatelessWidget {
opacity: isInvisible ? 0.6 : 1.0,
child: GenericCard(
key: key,
tooltip: tooltip,
child: Row(
children: [
Expanded(
Expand Down
39 changes: 25 additions & 14 deletions packages/uni_ui/lib/cards/generic_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,39 @@ class GenericCard extends StatelessWidget {
this.borderRadius,
this.onClick,
this.child,
required this.tooltip,
});

final EdgeInsetsGeometry? margin;
final EdgeInsetsGeometry? padding;
final Color? color;
final Color? shadowColor;
final double? borderRadius;
final Function? onClick;
final VoidCallback? onClick;
final Widget? child;
final String tooltip;

@override
Widget build(BuildContext context) {
final cardTheme = CardTheme.of(context);
final theme = Theme.of(context);

return Padding(
padding: margin ?? cardTheme.margin ?? const EdgeInsets.all(4),
child: GestureDetector(
onTap: () => onClick,
return Tooltip(
message: tooltip,
child: Container(
margin: margin ?? cardTheme.margin ?? const EdgeInsets.all(4),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: shadowColor ??
cardTheme.shadowColor ??
Colors.black.withOpacity(0.15),
blurRadius: 12,
spreadRadius: -4,
offset: const Offset(0, 6),
),
],
),
child: ClipSmoothRect(
radius: SmoothBorderRadius(
cornerRadius: borderRadius ?? 20,
Expand All @@ -40,17 +54,14 @@ class GenericCard extends StatelessWidget {
color: color ??
cardTheme.color ??
theme.colorScheme.surfaceContainer,
boxShadow: [
BoxShadow(
color: shadowColor ??
cardTheme.shadowColor ??
Colors.black.withOpacity(0.25),
blurRadius: 6,
),
],
),
child: Padding(
padding: padding ?? const EdgeInsets.all(10), child: child),
padding: padding ?? const EdgeInsets.all(10),
child: GestureDetector(
onTap: onClick,
child: child,
),
),
),
),
),
Expand Down
64 changes: 64 additions & 0 deletions packages/uni_ui/lib/cards/profile_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:uni_ui/cards/generic_card.dart';

class ProfileCard extends StatelessWidget {
const ProfileCard({
super.key,
required this.label,
required this.content,
required this.tooltip,
this.onClick,
});

final String label;
final String content;
final String tooltip;
final VoidCallback? onClick;

@override
Widget build(BuildContext context) {
return Stack(
clipBehavior: Clip.none,
children: [
GenericCard(
tooltip: tooltip,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleSmall!,
),
Text(
content,
overflow: TextOverflow.ellipsis,
),
],
),
),
if (onClick != null)
Positioned(
bottom: -4,
right: 2,
child: GestureDetector(
onTap: onClick,
child: Container(
child: PhosphorIcon(
PhosphorIcons.plus(PhosphorIconsStyle.light),
color: Colors.white,
size: 14,
),
padding: EdgeInsets.all(3.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
),
),
),
),
],
);
}
}
3 changes: 3 additions & 0 deletions packages/uni_ui/lib/cards/service_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ class ServiceCard extends StatelessWidget {
super.key,
required this.name,
required this.openingHours,
required this.tooltip,
});

final String name;
final List<String> openingHours;
final String tooltip;

@override
Widget build(BuildContext context) {
return GenericCard(
key: key,
tooltip: tooltip,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
Loading