From eea4ff2785bdd39e2ea8087f140c104a00f4a1ba Mon Sep 17 00:00:00 2001 From: AhsanRns Date: Thu, 9 May 2024 16:25:59 +0500 Subject: [PATCH] feat: code refactor --- .../custom_widgets/bottom_buttons.dart | 49 ++++++++++ .../screens/custom_widgets/page_app_bar.dart | 47 ++++++++++ evently/lib/screens/detail_screen.dart | 3 +- .../screens/event_hub/event_hub_screen.dart | 47 ++++------ .../lib/screens/host_view_ticket_preview.dart | 2 +- evently/lib/screens/overview_screen.dart | 3 +- evently/lib/screens/perks_screen.dart | 4 +- evently/lib/screens/price_screen.dart | 92 +------------------ 8 files changed, 125 insertions(+), 122 deletions(-) create mode 100644 evently/lib/screens/custom_widgets/bottom_buttons.dart create mode 100644 evently/lib/screens/custom_widgets/page_app_bar.dart diff --git a/evently/lib/screens/custom_widgets/bottom_buttons.dart b/evently/lib/screens/custom_widgets/bottom_buttons.dart new file mode 100644 index 0000000000..118b8985eb --- /dev/null +++ b/evently/lib/screens/custom_widgets/bottom_buttons.dart @@ -0,0 +1,49 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:evently/generated/locale_keys.g.dart'; +import 'package:evently/utils/evently_app_theme.dart'; +import 'package:evently/utils/space_utils.dart'; +import 'package:evently/widgets/clipped_button.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class BottomButtons extends StatelessWidget { + const BottomButtons({ + super.key, + required this.onPressContinue, + required this.onPressSaveDraft, + required this.isContinueEnable, + }); + + final VoidCallback onPressContinue; + final VoidCallback onPressSaveDraft; + final bool isContinueEnable; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ClippedButton( + title: LocaleKeys.continue_key.tr(), + bgColor: isContinueEnable ? EventlyAppTheme.kBlue : EventlyAppTheme.kGery03, + textColor: EventlyAppTheme.kWhite, + onPressed: onPressContinue, + cuttingHeight: 15.h, + clipperType: ClipperType.bottomLeftTopRight, + isShadow: false, + fontWeight: FontWeight.w700, + ), + const VerticalSpace(10), + Center( + child: InkWell( + onTap: onPressSaveDraft, + child: Text( + LocaleKeys.save_draft.tr(), + style: TextStyle(color: EventlyAppTheme.kTextGrey02, fontSize: 14.sp, fontWeight: FontWeight.w700), + ), + ), + ), + const VerticalSpace(5), + ], + ); + } +} diff --git a/evently/lib/screens/custom_widgets/page_app_bar.dart b/evently/lib/screens/custom_widgets/page_app_bar.dart new file mode 100644 index 0000000000..49ca128a59 --- /dev/null +++ b/evently/lib/screens/custom_widgets/page_app_bar.dart @@ -0,0 +1,47 @@ +import 'package:evently/utils/evently_app_theme.dart'; +import 'package:evently/viewmodels/create_event_viewmodel.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:provider/provider.dart'; + +class PageAppBar extends StatelessWidget { + const PageAppBar({ + super.key, + required this.onPressBack, + }); + + final VoidCallback onPressBack; + + @override + Widget build(BuildContext context) { + final createEventViewModel = context.watch(); + return Stack( + alignment: Alignment.center, + children: [ + Align( + alignment: Alignment.centerLeft, + child: ValueListenableBuilder( + valueListenable: createEventViewModel.currentPage, + builder: (_, int currentPage, __) => Padding( + padding: const EdgeInsets.only(left: 10), + child: IconButton( + onPressed: onPressBack, + icon: const Icon( + Icons.arrow_back_ios, + color: EventlyAppTheme.kGrey02, + ), + )), + )), + ValueListenableBuilder( + valueListenable: createEventViewModel.currentPage, + builder: (_, int currentPage, __) { + return Text( + createEventViewModel.pageTitles[createEventViewModel.currentPage.value], + style: Theme.of(context).textTheme.bodyLarge!.copyWith(fontSize: 18.sp, fontWeight: FontWeight.w700, color: EventlyAppTheme.kTextDarkBlue), + ); + }, + ), + ], + ); + } +} diff --git a/evently/lib/screens/detail_screen.dart b/evently/lib/screens/detail_screen.dart index 38fbbae2c8..a099ace12c 100644 --- a/evently/lib/screens/detail_screen.dart +++ b/evently/lib/screens/detail_screen.dart @@ -1,9 +1,10 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:evently/evently_provider.dart'; import 'package:evently/generated/locale_keys.g.dart'; +import 'package:evently/screens/custom_widgets/bottom_buttons.dart'; +import 'package:evently/screens/custom_widgets/page_app_bar.dart'; import 'package:evently/screens/custom_widgets/step_labels.dart'; import 'package:evently/screens/custom_widgets/steps_indicator.dart'; -import 'package:evently/screens/price_screen.dart'; import 'package:evently/utils/space_utils.dart'; import 'package:evently/viewmodels/create_event_viewmodel.dart'; import 'package:evently/widgets/evently_text_field.dart'; diff --git a/evently/lib/screens/event_hub/event_hub_screen.dart b/evently/lib/screens/event_hub/event_hub_screen.dart index bcfdcf85a1..0f4ca9ed5e 100644 --- a/evently/lib/screens/event_hub/event_hub_screen.dart +++ b/evently/lib/screens/event_hub/event_hub_screen.dart @@ -36,7 +36,7 @@ class _EventHubScreenState extends State { ); TextStyle subTitleStyle = TextStyle( - fontSize: isTablet ? 12.sp : 12.sp, + fontSize: isTablet ? 12.sp : 15, fontWeight: FontWeight.w700, color: EventlyAppTheme.kGrey01, fontFamily: kUniversalFontFamily, @@ -50,46 +50,38 @@ class _EventHubScreenState extends State { child: Scaffold( backgroundColor: EventlyAppTheme.kBlack, body: Padding( - padding: EdgeInsets.only(top: 20.h), + padding: const EdgeInsets.only(top: 20), child: Column( - crossAxisAlignment: CrossAxisAlignment.center, children: [ - Container( - height: 40.h, - alignment: Alignment.centerRight, - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - onTap: () => Navigator.of(context).pushNamed(RouteUtil.kCreateEvent), - child: DecoratedBox( - decoration: const BoxDecoration(color: EventlyAppTheme.kTextLightBlue), - child: Icon(Icons.add, size: 27.h, color: EventlyAppTheme.kWhite), - ), + Padding( + padding: const EdgeInsets.only(right: 20), + child: Align( + alignment: Alignment.topRight, + child: InkWell( + onTap: () => Navigator.of(context).pushNamed(RouteUtil.kCreateEvent), + child: const DecoratedBox( + decoration: BoxDecoration(color: EventlyAppTheme.kTextLightBlue), + child: Icon(Icons.add, size: 21, color: EventlyAppTheme.kWhite), ), - ], + ), ), ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 20.w), - child: Text( - LocaleKeys.eventhub.tr(), - style: headingStyle, - textAlign: TextAlign.center, - ), + Text( + LocaleKeys.eventhub.tr(), + style: headingStyle, + textAlign: TextAlign.center, ), Padding( - padding: EdgeInsets.symmetric(horizontal: 20.w), + padding: const EdgeInsets.symmetric(horizontal: 30), child: Text( LocaleKeys.welcome_event.tr(), style: titleStyle, textAlign: TextAlign.center, ), ), - SizedBox(height: 20.h), + const SizedBox(height: 40), Padding( - padding: EdgeInsets.symmetric(horizontal: 50.w), + padding: const EdgeInsets.symmetric(horizontal: 50), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -99,6 +91,7 @@ class _EventHubScreenState extends State { ], ), ), + const SizedBox(height: 40), Padding( padding: EdgeInsets.symmetric(horizontal: 20.w), child: Align( diff --git a/evently/lib/screens/host_view_ticket_preview.dart b/evently/lib/screens/host_view_ticket_preview.dart index 5eabc83d92..3438340504 100644 --- a/evently/lib/screens/host_view_ticket_preview.dart +++ b/evently/lib/screens/host_view_ticket_preview.dart @@ -1,4 +1,4 @@ -import 'package:evently/screens/price_screen.dart'; +import 'package:evently/screens/custom_widgets/bottom_buttons.dart'; import 'package:evently/utils/constants.dart'; import 'package:evently/utils/evently_app_theme.dart'; import 'package:evently/utils/space_utils.dart'; diff --git a/evently/lib/screens/overview_screen.dart b/evently/lib/screens/overview_screen.dart index 685c022d39..55a0f63f57 100644 --- a/evently/lib/screens/overview_screen.dart +++ b/evently/lib/screens/overview_screen.dart @@ -2,9 +2,10 @@ import 'package:dotted_border/dotted_border.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:evently/evently_provider.dart'; import 'package:evently/generated/locale_keys.g.dart'; +import 'package:evently/screens/custom_widgets/bottom_buttons.dart'; +import 'package:evently/screens/custom_widgets/page_app_bar.dart'; import 'package:evently/screens/custom_widgets/step_labels.dart'; import 'package:evently/screens/custom_widgets/steps_indicator.dart'; -import 'package:evently/screens/price_screen.dart'; import 'package:evently/utils/constants.dart'; import 'package:evently/utils/evently_app_theme.dart'; import 'package:evently/utils/space_utils.dart'; diff --git a/evently/lib/screens/perks_screen.dart b/evently/lib/screens/perks_screen.dart index 6395c4f61f..2f41bf61d0 100644 --- a/evently/lib/screens/perks_screen.dart +++ b/evently/lib/screens/perks_screen.dart @@ -1,14 +1,14 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:evently/generated/locale_keys.g.dart'; +import 'package:evently/screens/custom_widgets/bottom_buttons.dart'; +import 'package:evently/screens/custom_widgets/page_app_bar.dart'; import 'package:evently/screens/custom_widgets/step_labels.dart'; import 'package:evently/screens/custom_widgets/steps_indicator.dart'; -import 'package:evently/screens/price_screen.dart'; import 'package:evently/utils/constants.dart'; import 'package:evently/utils/evently_app_theme.dart'; import 'package:evently/utils/screen_responsive.dart'; import 'package:evently/utils/space_utils.dart'; import 'package:evently/viewmodels/create_event_viewmodel.dart'; -import 'package:evently/widgets/clipped_button.dart'; import 'package:evently/widgets/evently_text_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/evently/lib/screens/price_screen.dart b/evently/lib/screens/price_screen.dart index 6feaf5ab2b..97adf14b48 100644 --- a/evently/lib/screens/price_screen.dart +++ b/evently/lib/screens/price_screen.dart @@ -1,14 +1,14 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:evently/evently_provider.dart'; +import 'package:evently/screens/custom_widgets/bottom_buttons.dart'; +import 'package:evently/screens/custom_widgets/page_app_bar.dart'; import 'package:evently/screens/custom_widgets/step_labels.dart'; import 'package:evently/screens/custom_widgets/steps_indicator.dart'; import 'package:evently/utils/constants.dart'; import 'package:evently/utils/evently_app_theme.dart'; -import 'package:evently/utils/route_util.dart'; import 'package:evently/utils/screen_responsive.dart'; import 'package:evently/utils/space_utils.dart'; import 'package:evently/viewmodels/create_event_viewmodel.dart'; -import 'package:evently/widgets/clipped_button.dart'; import 'package:evently/widgets/evently_price_input_field.dart'; import 'package:evently/widgets/evently_text_field.dart'; import 'package:flutter/material.dart'; @@ -206,91 +206,3 @@ class _PriceScreenState extends State { ); } } - -class BottomButtons extends StatelessWidget { - const BottomButtons({ - super.key, - required this.onPressContinue, - required this.onPressSaveDraft, - required this.isContinueEnable, - }); - - final VoidCallback onPressContinue; - final VoidCallback onPressSaveDraft; - final bool isContinueEnable; - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ClippedButton( - title: LocaleKeys.continue_key.tr(), - bgColor: isContinueEnable ? EventlyAppTheme.kBlue : EventlyAppTheme.kGery03, - textColor: EventlyAppTheme.kWhite, - onPressed: () async { - Navigator.of(context).pushNamed(RouteUtil.kHostTicketPreview); - }, - cuttingHeight: 15.h, - clipperType: ClipperType.bottomLeftTopRight, - isShadow: false, - fontWeight: FontWeight.w700, - ), - VerticalSpace(10.h), - Center( - child: InkWell( - onTap: () { - Navigator.of(context).pushNamed(RouteUtil.kHostTicketPreview); - }, - child: Text( - LocaleKeys.save_draft.tr(), - style: TextStyle(color: EventlyAppTheme.kTextGrey02, fontSize: 14.sp, fontWeight: FontWeight.w700), - ), - ), - ), - VerticalSpace(5.h), - ], - ); - } -} - -class PageAppBar extends StatelessWidget { - const PageAppBar({ - super.key, - required this.onPressBack, - }); - - final VoidCallback onPressBack; - - @override - Widget build(BuildContext context) { - final createEventViewModel = context.watch(); - return Stack( - alignment: Alignment.center, - children: [ - Align( - alignment: Alignment.centerLeft, - child: ValueListenableBuilder( - valueListenable: createEventViewModel.currentPage, - builder: (_, int currentPage, __) => Padding( - padding: EdgeInsets.only(left: 10.sp), - child: IconButton( - onPressed: onPressBack, - icon: const Icon( - Icons.arrow_back_ios, - color: EventlyAppTheme.kGrey02, - ), - )), - )), - ValueListenableBuilder( - valueListenable: createEventViewModel.currentPage, - builder: (_, int currentPage, __) { - return Text( - createEventViewModel.pageTitles[createEventViewModel.currentPage.value], - style: Theme.of(context).textTheme.bodyLarge!.copyWith(fontSize: 18.sp, fontWeight: FontWeight.w700, color: EventlyAppTheme.kTextDarkBlue), - ); - }, - ), - ], - ); - } -}