Skip to content

Commit

Permalink
Exam Card
Browse files Browse the repository at this point in the history
  • Loading branch information
thePeras committed Aug 7, 2024
1 parent 43aab39 commit b718ebb
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 1 deletion.
120 changes: 120 additions & 0 deletions packages/uni_ui/lib/cards/exam_card.dart
Original file line number Diff line number Diff line change
@@ -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<String> 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,
),
),
],
),
),
);
}
}
File renamed without changes.
25 changes: 24 additions & 1 deletion packages/uni_ui/lib/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand All @@ -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);
}
8 changes: 8 additions & 0 deletions packages/uni_ui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions packages/uni_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b718ebb

Please sign in to comment.