diff --git a/packages/uni_ui/lib/cards/exam_card.dart b/packages/uni_ui/lib/cards/exam_card.dart new file mode 100644 index 000000000..3acf18ca5 --- /dev/null +++ b/packages/uni_ui/lib/cards/exam_card.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:phosphor_flutter/phosphor_flutter.dart'; +import 'package:uni_ui/cards/generic_card.dart'; +import 'package:uni_ui/theme.dart'; + +class ExamCard extends StatelessWidget { + const ExamCard({ + super.key, + required this.name, + required this.acronym, + required this.rooms, + required this.type, + this.startTime, + this.isInvisible = false, + this.showIcon = true, + this.iconAction, + }); + + final String name; + final String acronym; + final List rooms; + final String type; + final String? startTime; + final bool isInvisible; + final bool showIcon; + final Function()? iconAction; + + @override + Widget build(BuildContext context) { + return Opacity( + opacity: isInvisible ? 0.6 : 1.0, + child: GenericCard( + key: key, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + acronym, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.headlineMedium!, + ), + const SizedBox(width: 8), + Badge( + label: Text(type), + backgroundColor: BadgeColors.er, + textColor: Theme.of(context).colorScheme.surface, + ), + ], + ), + Text( + name, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.titleLarge!, + ), + const SizedBox(height: 5), + Row( + children: [ + PhosphorIcon( + PhosphorIcons.clock(PhosphorIconsStyle.duotone), + color: Theme.of(context).iconTheme.color, + size: 20, + ), + const SizedBox(width: 4), + Text( + startTime ?? "--:--", + style: Theme.of(context).textTheme.bodyMedium!, + ), + const SizedBox(width: 8), + if (!rooms.isEmpty) + PhosphorIcon( + PhosphorIcons.mapPin(PhosphorIconsStyle.duotone), + color: Theme.of(context).iconTheme.color, + size: 20, + ), + const SizedBox(width: 4), + SizedBox( + height: 20, + child: ListView.separated( + scrollDirection: Axis.horizontal, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: rooms.length, + separatorBuilder: (context, int index) { + return const SizedBox(width: 4); + }, + itemBuilder: (context, int index) { + return IntrinsicWidth( + child: Text(rooms[index]), + ); + }, + ), + ), + ], + ) + ], + ), + ), + if (showIcon) + IconButton( + onPressed: iconAction ?? () {}, + icon: PhosphorIcon( + isInvisible + ? PhosphorIcons.eye(PhosphorIconsStyle.duotone) + : PhosphorIcons.eyeSlash(PhosphorIconsStyle.duotone), + color: Theme.of(context).iconTheme.color, + size: 35, + ), + ), + ], + ), + ), + ); + } +} diff --git a/packages/uni_ui/lib/generic_card.dart b/packages/uni_ui/lib/cards/generic_card.dart similarity index 100% rename from packages/uni_ui/lib/generic_card.dart rename to packages/uni_ui/lib/cards/generic_card.dart diff --git a/packages/uni_ui/lib/theme.dart b/packages/uni_ui/lib/theme.dart index 02ec51da9..fcf9df238 100644 --- a/packages/uni_ui/lib/theme.dart +++ b/packages/uni_ui/lib/theme.dart @@ -14,6 +14,7 @@ const _textTheme = TextTheme( displayLarge: TextStyle(fontSize: 40, fontWeight: FontWeight.w400), displayMedium: TextStyle(fontSize: 32, fontWeight: FontWeight.w400), displaySmall: TextStyle(fontSize: 28, fontWeight: FontWeight.w400), + headlineLarge: TextStyle(fontSize: 28, fontWeight: FontWeight.w300), headlineMedium: TextStyle(fontSize: 24, fontWeight: FontWeight.w300), headlineSmall: TextStyle(fontSize: 20, fontWeight: FontWeight.w400), titleLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w300), @@ -24,9 +25,24 @@ const _textTheme = TextTheme( bodySmall: TextStyle(fontSize: 13, fontWeight: FontWeight.w400), ); +var _lightTextTheme = TextTheme( + displayLarge: _textTheme.displayLarge!, + displayMedium: _textTheme.displayMedium!, + displaySmall: _textTheme.displaySmall!, + headlineLarge: _textTheme.headlineLarge!, + headlineMedium: _textTheme.headlineMedium!.copyWith(color: darkRed), + headlineSmall: _textTheme.headlineSmall!, + titleLarge: _textTheme.titleLarge!.copyWith(color: darkRed), + titleMedium: _textTheme.titleMedium!, + titleSmall: _textTheme.titleSmall!, + bodyLarge: _textTheme.bodyLarge!, + bodyMedium: _textTheme.bodyMedium!, + bodySmall: _textTheme.bodySmall!, +); + ThemeData lightTheme = ThemeData( useMaterial3: true, - textTheme: _textTheme, + textTheme: _lightTextTheme, colorScheme: ColorScheme.fromSeed( seedColor: darkRed, surface: mildWhite, @@ -47,3 +63,10 @@ ThemeData lightTheme = ThemeData( indicatorColor: darkRed, iconTheme: const IconThemeData(color: darkRed), ); + +class BadgeColors { + static const mt = Color(0xFF7ca5b8); + static const en = Color(0xFF769c87); + static const er = Color(0xFFab4d39); + static const ee = Color(0xFFfbc11f); +} diff --git a/packages/uni_ui/pubspec.lock b/packages/uni_ui/pubspec.lock index 25a63aad9..1f09ca040 100644 --- a/packages/uni_ui/pubspec.lock +++ b/packages/uni_ui/pubspec.lock @@ -363,6 +363,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + phosphor_flutter: + dependency: "direct main" + description: + name: phosphor_flutter + sha256: "8a14f238f28a0b54842c5a4dc20676598dd4811fcba284ed828bd5a262c11fde" + url: "https://pub.dev" + source: hosted + version: "2.1.0" pool: dependency: transitive description: diff --git a/packages/uni_ui/pubspec.yaml b/packages/uni_ui/pubspec.yaml index 9f518255d..71d7cbb74 100644 --- a/packages/uni_ui/pubspec.yaml +++ b/packages/uni_ui/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: figma_squircle: ^0.5.3 flutter: sdk: flutter + phosphor_flutter: ^2.1.0 dev_dependencies: custom_lint: ^0.6.4