Skip to content

Commit

Permalink
Exam Card (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
thePeras authored Nov 2, 2024
2 parents 7e98d31 + 63b0ff7 commit e9dc3d7
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:uni_ui/generic_card.dart';
import 'package:uni_ui/cards/generic_card.dart';

class CourseGradeCard extends StatelessWidget {
const CourseGradeCard(
Expand Down Expand Up @@ -32,12 +32,8 @@ class CourseGradeCard extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${ects} ECTS",
style: theme.textTheme.bodyLarge
),
Text("${grade.toInt()}",
style: theme.textTheme.bodyLarge)
Text("${ects} ECTS", style: theme.textTheme.bodyLarge),
Text("${grade.toInt()}", style: theme.textTheme.bodyLarge)
],
)
],
Expand Down
123 changes: 123 additions & 0 deletions packages/uni_ui/lib/cards/exam_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
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(
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),
Expanded(
child: ShaderMask(
shaderCallback: (Rect bounds) {
return const LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: <Color>[Colors.black, Colors.transparent],
stops: [0.8, 1.0],
).createShader(bounds);
},
blendMode: BlendMode.dstIn,
child: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
scrollDirection: Axis.horizontal,
child: Text(
rooms.join(" "),
style: Theme.of(context).textTheme.bodyMedium,
),
),
),
),
],
)
],
),
),
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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:uni_ui/generic_card.dart';
import 'package:uni_ui/cards/generic_card.dart';

class ServiceCard extends StatelessWidget {
const ServiceCard({
Expand Down
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 @@ -48,3 +64,10 @@ ThemeData lightTheme = ThemeData(
secondaryHeaderColor: normalGray,
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);
}

0 comments on commit e9dc3d7

Please sign in to comment.