Skip to content

Commit

Permalink
feat: profile card (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormpp authored Feb 6, 2025
2 parents 3a78367 + 881f3e5 commit ac2a4a8
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 26 deletions.
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
62 changes: 36 additions & 26 deletions packages/uni_ui/lib/cards/generic_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,50 @@ import 'package:figma_squircle/figma_squircle.dart';
import 'package:flutter/material.dart';

class GenericCard extends StatelessWidget {
const GenericCard(
{super.key,
this.margin,
this.padding,
this.color,
this.shadowColor,
this.borderRadius,
this.onClick,
this.child,
this.gradient});
const GenericCard({
super.key,
this.margin,
this.padding,
this.color,
this.shadowColor,
this.borderRadius,
this.onClick,
this.child,
this.gradient,
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 Gradient? gradient;
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.03),
blurRadius: 12,
spreadRadius: -2,
offset: const Offset(0, 1),
),
],
),
child: ClipSmoothRect(
radius: SmoothBorderRadius(
cornerRadius: borderRadius ?? 20,
Expand All @@ -42,19 +57,14 @@ class GenericCard extends StatelessWidget {
cardTheme.color ??
theme.colorScheme.surfaceContainer,
gradient: gradient,
boxShadow: [
BoxShadow(
color: shadowColor ??
cardTheme.shadowColor ??
Colors.black.withOpacity(0.25),
blurRadius: 6,
),
],
),
child: Padding(
padding: padding ??
const EdgeInsets.symmetric(vertical: 15, horizontal: 25),
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

0 comments on commit ac2a4a8

Please sign in to comment.