Skip to content

Commit

Permalink
Updated the way we use the icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano-7 committed Dec 27, 2024
1 parent 4b0c272 commit 8ff66e7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CourseUnitSheetView extends StatelessWidget {
),
if (exams.isNotEmpty) ...[
SizedBox(
height: 120,
height: 100,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: buildExamsRow(context, exams),
Expand Down Expand Up @@ -215,7 +215,7 @@ Widget buildExamsRow(BuildContext context, List<Exam> exams) {
return Padding(
padding: const EdgeInsets.only(right: 8),
child: SizedBox(
width: 260,
width: 240,
child: ExamCard(
name: exam.subject,
acronym: exam.subject,
Expand Down
31 changes: 19 additions & 12 deletions packages/uni_ui/lib/cards/exam_card.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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';
import 'package:uni_ui/icons.dart';

class ExamCard extends StatelessWidget {
const ExamCard({
Expand Down Expand Up @@ -29,6 +29,13 @@ class ExamCard extends StatelessWidget {
final String? examDay;
final String? examMonth;

static const Map<String, Color> examTypeColors = {
'MT': BadgeColors.mt,
'EN': BadgeColors.en,
'ER': BadgeColors.er,
'EE': BadgeColors.ee,
};

@override
Widget build(BuildContext context) {
return Opacity(
Expand All @@ -52,7 +59,7 @@ class ExamCard extends StatelessWidget {
const SizedBox(width: 8),
Badge(
label: Text(type),
backgroundColor: BadgeColors.er,
backgroundColor: examTypeColors[type],
textColor: Theme.of(context).colorScheme.surface,
),
],
Expand All @@ -65,8 +72,8 @@ class ExamCard extends StatelessWidget {
const SizedBox(height: 5),
Row(
children: [
PhosphorIcon(
PhosphorIcons.clock(PhosphorIconsStyle.duotone),
UniIcon(
UniIcons.clock,
color: Theme.of(context).iconTheme.color,
size: 20,
),
Expand All @@ -77,8 +84,8 @@ class ExamCard extends StatelessWidget {
),
if (examDay != null && examMonth != null) ...[
const SizedBox(width: 8),
PhosphorIcon(
PhosphorIcons.calendarBlank(PhosphorIconsStyle.duotone),
UniIcon(
UniIcons.calendarBlank,
color: Theme.of(context).iconTheme.color,
size: 20,
),
Expand All @@ -90,8 +97,8 @@ class ExamCard extends StatelessWidget {
],
const SizedBox(width: 8),
if (rooms.isNotEmpty)
PhosphorIcon(
PhosphorIcons.mapPin(PhosphorIconsStyle.duotone),
UniIcon(
UniIcons.mapPin,
color: Theme.of(context).iconTheme.color,
size: 20,
),
Expand Down Expand Up @@ -125,10 +132,10 @@ class ExamCard extends StatelessWidget {
if (showIcon)
IconButton(
onPressed: iconAction ?? () {},
icon: PhosphorIcon(
icon: UniIcon(
isInvisible
? PhosphorIcons.eye(PhosphorIconsStyle.duotone)
: PhosphorIcons.eyeSlash(PhosphorIconsStyle.duotone),
? UniIcons.eyeVisible
: UniIcons.eyeHidden,
color: Theme.of(context).iconTheme.color,
size: 35,
),
Expand All @@ -138,4 +145,4 @@ class ExamCard extends StatelessWidget {
),
);
}
}
}
29 changes: 28 additions & 1 deletion packages/uni_ui/lib/icons.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
import 'package:flutter/material.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';

// A list of all available icons
class UniIcons {
static const calendar = PhosphorIconsDuotone.calendarDots;
static const lecture = PhosphorIconsDuotone.lectern;
static const exam = PhosphorIconsDuotone.exam;
static const course = PhosphorIconsDuotone.certificate;
static const calendar = PhosphorIconsDuotone.calendarDots;
static const courses = PhosphorIconsDuotone.certificate;
static const classes = PhosphorIconsDuotone.usersThree;
static const files = PhosphorIconsDuotone.folderOpen;
static const notebook = PhosphorIconsDuotone.notebook;
static const email = PhosphorIconsDuotone.paperPlaneTilt;
static const location = PhosphorIconsDuotone.mapPin;
static const clock = PhosphorIconsDuotone.clock;
static const calendarBlank = PhosphorIconsDuotone.calendarBlank;
static const mapPin = PhosphorIconsDuotone.mapPin;
static const eyeVisible = PhosphorIconsDuotone.eye;
static const eyeHidden = PhosphorIconsDuotone.eyeSlash;
}

// The same as default Icon class from material.dart but allowing to use PhosphorIcons duotone icons
class UniIcon extends PhosphorIcon {
const UniIcon(
IconData icon, {
super.key,
double size = 24,
Color? color,
String? semanticLabel,
TextDirection? textDirection,
}) : super(
icon,
size: size,
color: color,
semanticLabel: semanticLabel,
textDirection: textDirection,
);
}
6 changes: 3 additions & 3 deletions packages/uni_ui/lib/tabs/tab_icon.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:uni_ui/icons.dart';

class TabIcon extends StatelessWidget {
const TabIcon({
Expand All @@ -13,15 +14,14 @@ class TabIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Tab(
height: 30,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon),
UniIcon(icon),
const SizedBox(width: 4),
Text(text),
],
),
);
}
}
}

0 comments on commit 8ff66e7

Please sign in to comment.