-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(home-view): remove duplicated error segments (academic calendar r…
…epo)
- Loading branch information
1 parent
a497739
commit e9ee49a
Showing
5 changed files
with
106 additions
and
84 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
lib/features/academic_calendar/widgets/academic_calendar_consumer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
|
||
import "../../../config/ui_config.dart"; | ||
import "../../../widgets/my_error_widget.dart"; | ||
import "../../home_view/widgets/loading_widgets/horizontal_rectangular_section_loading.dart"; | ||
import "../repository/academic_calendar_repo.dart"; | ||
import "countdown_widget/exam_session_countdown.dart"; | ||
import "home_screen_greeting.dart"; | ||
|
||
class AcademicCalendarConsumer extends ConsumerWidget { | ||
const AcademicCalendarConsumer({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final state = ref.watch(academicCalendarRepoProvider); | ||
|
||
return switch (state) { | ||
AsyncError(:final error) => Padding( | ||
padding: const EdgeInsets.only(top: HomeViewConfig.paddingSmall), | ||
child: MyErrorWidget(error), | ||
), | ||
AsyncValue(:final AcademicCalendar value) => Column( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Greeting(value), | ||
const SizedBox(height: HomeViewConfig.paddingMedium), | ||
ExamSessionCountdown(value), | ||
], | ||
), | ||
_ => const Padding( | ||
padding: | ||
EdgeInsets.symmetric(horizontal: HomeViewConfig.paddingMedium), | ||
child: Column( | ||
children: [ | ||
HorizontalRectangularSectionLoading(), | ||
SizedBox(height: HomeViewConfig.paddingMedium), | ||
HorizontalRectangularSectionLoading(), | ||
], | ||
), | ||
), | ||
}; | ||
} | ||
} |
85 changes: 37 additions & 48 deletions
85
lib/features/academic_calendar/widgets/countdown_widget/exam_session_countdown.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,54 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
|
||
import "../../../../theme/app_theme.dart"; | ||
import "../../../../utils/context_extensions.dart"; | ||
import "../../../../widgets/my_error_widget.dart"; | ||
import "../../../home_view/widgets/loading_widgets/horizontal_rectangular_section_loading.dart"; | ||
import "../../repository/academic_calendar_repo.dart"; | ||
import "digits_widgets.dart"; | ||
|
||
class ExamSessionCountdown extends ConsumerWidget { | ||
const ExamSessionCountdown({super.key}); | ||
|
||
class ExamSessionCountdown extends StatelessWidget { | ||
const ExamSessionCountdown(this.academicCalendar, {super.key}); | ||
final AcademicCalendar academicCalendar; | ||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final state = ref.watch(academicCalendarRepoProvider); | ||
return switch (state) { | ||
AsyncLoading() => const Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 16), | ||
child: HorizontalRectangularSectionLoading(), | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24), | ||
child: Container( | ||
width: double.infinity, | ||
height: 69, | ||
decoration: BoxDecoration( | ||
gradient: context.colorTheme.toPwrGradient, | ||
borderRadius: BorderRadius.circular(8), | ||
boxShadow: const [ | ||
BoxShadow( | ||
spreadRadius: 6, | ||
blurRadius: 11, | ||
color: Color(0x28fa6465), | ||
), | ||
], | ||
), | ||
AsyncError(:final error) => MyErrorWidget(error), | ||
AsyncValue(:final value) => Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24), | ||
child: Container( | ||
width: double.infinity, | ||
height: 69, | ||
decoration: BoxDecoration( | ||
gradient: context.colorTheme.toPwrGradient, | ||
borderRadius: BorderRadius.circular(8), | ||
boxShadow: const [ | ||
BoxShadow( | ||
spreadRadius: 6, | ||
blurRadius: 11, | ||
color: Color(0x28fa6465), | ||
), | ||
], | ||
child: Row( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(16), | ||
child: DigitsRow(academicCalendar), | ||
), | ||
child: Row( | ||
Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(16), | ||
child: DigitsRow(value), | ||
Text( | ||
context.localize.days, | ||
style: context.textTheme.headlineWhite, | ||
), | ||
Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
context.localize.days, | ||
style: context.textTheme.headlineWhite, | ||
), | ||
Text( | ||
context.localize.to_start_session, | ||
style: context.textTheme.bodyWhite, | ||
), | ||
], | ||
Text( | ||
context.localize.to_start_session, | ||
style: context.textTheme.bodyWhite, | ||
), | ||
], | ||
), | ||
), | ||
) | ||
}; | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
53 changes: 21 additions & 32 deletions
53
lib/features/academic_calendar/widgets/home_screen_greeting.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,35 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
|
||
import "../../../theme/app_theme.dart"; | ||
import "../../../utils/context_extensions.dart"; | ||
import "../../../widgets/my_error_widget.dart"; | ||
import "../../home_view/widgets/loading_widgets/horizontal_rectangular_section_loading.dart"; | ||
import "../model/academic_calendar_extensions.dart"; | ||
import "../repository/academic_calendar_repo.dart"; | ||
import "../utils/localize_academic_day.dart"; | ||
|
||
class Greeting extends ConsumerWidget { | ||
const Greeting({ | ||
class Greeting extends StatelessWidget { | ||
const Greeting( | ||
this.academicCalendar, { | ||
super.key, | ||
}); | ||
|
||
final AcademicCalendar academicCalendar; | ||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final state = ref.watch(academicCalendarRepoProvider); | ||
|
||
return switch (state) { | ||
AsyncLoading() => const Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 16), | ||
child: HorizontalRectangularSectionLoading(), | ||
), | ||
AsyncError(:final error) => MyErrorWidget(error), | ||
AsyncValue(:final value) => Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Text( | ||
context.localize.home_screen_greeting, | ||
style: context.greetingTheme.textStyle, | ||
), | ||
Text( | ||
value?.academicDay?.localize(context) ?? "", | ||
style: context.greetingTheme.boldTextStyle, | ||
), | ||
], | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Text( | ||
context.localize.home_screen_greeting, | ||
style: context.greetingTheme.textStyle, | ||
), | ||
Text( | ||
academicCalendar.academicDay?.localize(context) ?? "", | ||
style: context.greetingTheme.boldTextStyle, | ||
), | ||
) | ||
}; | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters