From fa544390c2f304260f3270a41ddbd4cc3c96f991 Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Tue, 22 Nov 2022 09:40:35 -0800 Subject: [PATCH 1/3] Load timezone and location --- lib/utils/schedule.dart | 2 ++ lib/utils/schedule_variant.dart | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/utils/schedule.dart b/lib/utils/schedule.dart index 24bbbc0..b3b7d3d 100644 --- a/lib/utils/schedule.dart +++ b/lib/utils/schedule.dart @@ -23,6 +23,8 @@ class Schedule { String get name => schedule["name"]; String get shortName => schedule["shortName"]; String get color => schedule["color"]; + String get timezone => schedule["timezone"]; + String get location => schedule["location"]; Map get periodSchedule => schedule["schedule"] as Map; diff --git a/lib/utils/schedule_variant.dart b/lib/utils/schedule_variant.dart index b6e6949..73bb8fa 100644 --- a/lib/utils/schedule_variant.dart +++ b/lib/utils/schedule_variant.dart @@ -5,11 +5,15 @@ import 'schedule.dart'; class ScheduleVariant { String name; String color; + String timezone; + String location; List variants; ScheduleVariant({ required this.name, required this.color, + required this.timezone, + required this.location, required this.variants, }); } @@ -35,11 +39,15 @@ class VariantOrSchedule { 'One of the parameters must be provided', ); - String get name => - type == Schedule ? schedule!.schedule["name"] : variant!.name; + String get name => type == Schedule ? schedule!.name : variant!.name; - String get color => - type == Schedule ? schedule!.schedule["color"] : variant!.color; + String get color => type == Schedule ? schedule!.color : variant!.color; + + String get timezone => + type == Schedule ? schedule!.timezone : variant!.timezone; + + String get location => + type == Schedule ? schedule!.location : variant!.location; String get comparableName => name.toLowerCase().replaceFirst("a ", "").replaceFirst("the", "").trim(); @@ -127,6 +135,8 @@ Map generateScheduleListWithVariants( name: schedules[variants[id]!.first]["name"] .replaceAll(RegExp(r"\s\(.*\)"), ""), color: schedules[variants[id]!.first]["color"], + timezone: schedules[variants[id]!.first]["timezone"], + location: schedules[variants[id]!.first]["location"], variants: variants[id]! .map( (id) => ScheduleVariantItem( From f79edaa95f81150e41ca77c0fa3e3ab609322418 Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Tue, 22 Nov 2022 10:01:04 -0800 Subject: [PATCH 2/3] Add location parameter --- lib/widgets/schedule_card.dart | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/widgets/schedule_card.dart b/lib/widgets/schedule_card.dart index a7721bc..9bfca30 100644 --- a/lib/widgets/schedule_card.dart +++ b/lib/widgets/schedule_card.dart @@ -4,11 +4,13 @@ class ScheduleCard extends StatelessWidget { const ScheduleCard({ Key? key, required this.name, + this.location, required this.backgroundColor, required this.onPressed, }) : super(key: key); final String name; + final String? location; final Color backgroundColor; final VoidCallback onPressed; @@ -34,12 +36,31 @@ class ScheduleCard extends StatelessWidget { 0, 15, ), - child: Text( - name, - style: const TextStyle( - fontSize: 16.0, - ), - ), + child: location == null + ? Text( + name, + style: const TextStyle( + fontSize: 16.0, + ), + ) + : Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + name, + style: const TextStyle( + fontSize: 16.0, + ), + ), + Text( + location!, + style: const TextStyle( + fontSize: 12.0, + ), + ) + ], + ), ), ), const SizedBox( From 1599c501ecadfedf474f73120a4933ddee26685e Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Tue, 22 Nov 2022 10:01:15 -0800 Subject: [PATCH 3/3] Pass location to card --- lib/screens/home.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/screens/home.dart b/lib/screens/home.dart index ce09f39..a8dd8cc 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -177,6 +177,7 @@ class _HomeScreenState extends State { .map( (schedule) => ScheduleCard( name: schedule.value.name, + location: schedule.value.location, backgroundColor: HexColor.fromHex(schedule.value.color), onPressed: () {