Skip to content

Commit

Permalink
feat: code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 9, 2024
1 parent bfeaab9 commit eea4ff2
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 122 deletions.
49 changes: 49 additions & 0 deletions evently/lib/screens/custom_widgets/bottom_buttons.dart
Original file line number Diff line number Diff line change
@@ -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),
],
);
}
}
47 changes: 47 additions & 0 deletions evently/lib/screens/custom_widgets/page_app_bar.dart
Original file line number Diff line number Diff line change
@@ -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<CreateEventViewModel>();
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),
);
},
),
],
);
}
}
3 changes: 2 additions & 1 deletion evently/lib/screens/detail_screen.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
47 changes: 20 additions & 27 deletions evently/lib/screens/event_hub/event_hub_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _EventHubScreenState extends State<EventHubScreen> {
);

TextStyle subTitleStyle = TextStyle(
fontSize: isTablet ? 12.sp : 12.sp,
fontSize: isTablet ? 12.sp : 15,
fontWeight: FontWeight.w700,
color: EventlyAppTheme.kGrey01,
fontFamily: kUniversalFontFamily,
Expand All @@ -50,46 +50,38 @@ class _EventHubScreenState extends State<EventHubScreen> {
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: [
Expand All @@ -99,6 +91,7 @@ class _EventHubScreenState extends State<EventHubScreen> {
],
),
),
const SizedBox(height: 40),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Align(
Expand Down
2 changes: 1 addition & 1 deletion evently/lib/screens/host_view_ticket_preview.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion evently/lib/screens/overview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions evently/lib/screens/perks_screen.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
92 changes: 2 additions & 90 deletions evently/lib/screens/price_screen.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -206,91 +206,3 @@ class _PriceScreenState extends State<PriceScreen> {
);
}
}

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<CreateEventViewModel>();
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),
);
},
),
],
);
}
}

0 comments on commit eea4ff2

Please sign in to comment.