From 64b249a0cd39513456803c386f3f279ea00d1978 Mon Sep 17 00:00:00 2001 From: nextwo <1234> Date: Thu, 19 Oct 2023 11:17:03 +0300 Subject: [PATCH] gas refill --- assets/translations/ar.json | 2 + assets/translations/en.json | 2 + lib/models/enums/translation_keys.dart | 2 + .../common_widgets/app_search_field.dart | 36 +++++ lib/new_views/common_widgets/app_tab_bar.dart | 23 +++ lib/new_views/pages/land_page/land_page.dart | 20 ++- .../my_request/my_requests_page.dart | 52 ++++++ .../pages/land_page/my_requests_page.dart | 14 -- .../user/gas_refill/track_gas_refill.dart | 95 ++++++----- .../widgets/gas_refill/gas_refill_item.dart | 153 +++++++++--------- pubspec.lock | 8 + pubspec.yaml | 1 + 12 files changed, 276 insertions(+), 132 deletions(-) create mode 100644 lib/new_views/common_widgets/app_search_field.dart create mode 100644 lib/new_views/common_widgets/app_tab_bar.dart create mode 100644 lib/new_views/pages/land_page/my_request/my_requests_page.dart delete mode 100644 lib/new_views/pages/land_page/my_requests_page.dart diff --git a/assets/translations/ar.json b/assets/translations/ar.json index b444f4ca..6727200e 100644 --- a/assets/translations/ar.json +++ b/assets/translations/ar.json @@ -18,6 +18,8 @@ "transferRequest" : "طلب نقل", "serviceRequest" : "طلب خدمة", "newServiceRequest" : "طلب خدمة جديدة", + "search": "بحث", + "filter" : "تصنيف", "newGasRefillRequest" : "طلب إعادة تعبئة غاز جديد", "newTransferRequest" : "طلب نقل جديد", "submitRequest" : "تأكيد الطلب", diff --git a/assets/translations/en.json b/assets/translations/en.json index 49c1ed56..70344223 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -18,6 +18,8 @@ "transferRequest" : "Transfer Request", "serviceRequest" : "Service Request", "newServiceRequest" : "New Service Request", + "search": "Search", + "filter": "Filter", "newGasRefillRequest" : "New Gas Refill Request", "newTransferRequest" : "New Transfer Request", "submitRequest" : "Submit Request", diff --git a/lib/models/enums/translation_keys.dart b/lib/models/enums/translation_keys.dart index 12108d51..d72de1fc 100644 --- a/lib/models/enums/translation_keys.dart +++ b/lib/models/enums/translation_keys.dart @@ -18,6 +18,8 @@ enum TranslationKeys { transferRequest, serviceRequest, newServiceRequest, + search, + filter, newGasRefillRequest, newTransferRequest, submitRequest, diff --git a/lib/new_views/common_widgets/app_search_field.dart b/lib/new_views/common_widgets/app_search_field.dart new file mode 100644 index 00000000..38e3668c --- /dev/null +++ b/lib/new_views/common_widgets/app_search_field.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/new_views/app_style/app_color.dart'; + +import '../../models/enums/translation_keys.dart'; + +class AppSearchField extends StatefulWidget { + final Function(String) onChanged; + final Function(String) onSubmitted; + const AppSearchField({Key key, this.onChanged, this.onSubmitted}) : super(key: key); + + @override + State createState() => _AppSearchFieldState(); +} + +class _AppSearchFieldState extends State { + @override + Widget build(BuildContext context) { + return TextField( + onChanged: widget.onChanged, + onSubmitted: widget.onSubmitted, + decoration: InputDecoration( + prefixIcon: const Icon(Icons.search, color: AppColor.neutral20,), + hintText: context.translate(TranslationKeys.search), + hintStyle: TextStyle( + fontSize: Theme.of(context).textTheme.bodySmall.fontSize + ), + filled: true, + fillColor: AppColor.neutral30, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15), + borderSide: BorderSide.none, + )), + ); + } +} diff --git a/lib/new_views/common_widgets/app_tab_bar.dart b/lib/new_views/common_widgets/app_tab_bar.dart new file mode 100644 index 00000000..4aab61f3 --- /dev/null +++ b/lib/new_views/common_widgets/app_tab_bar.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class AppTabBar extends StatelessWidget { + + const AppTabBar({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return TabBar( + tabs:[ + Tab( + icon: Icon(Icons.cloud_outlined), + ), + Tab( + icon: Icon(Icons.beach_access_sharp), + ), + Tab( + icon: Icon(Icons.brightness_5_sharp), + ), + ], + ); + } +} diff --git a/lib/new_views/pages/land_page/land_page.dart b/lib/new_views/pages/land_page/land_page.dart index ebd460fa..f7f5cdc1 100644 --- a/lib/new_views/pages/land_page/land_page.dart +++ b/lib/new_views/pages/land_page/land_page.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/new_views/pages/land_page/home_app_bar.dart'; import 'package:test_sa/new_views/pages/land_page/my_assets_page.dart'; -import 'package:test_sa/new_views/pages/land_page/my_requests_page.dart'; +import 'package:test_sa/new_views/pages/land_page/my_request/my_requests_page.dart'; import '../../common_widgets/app_bottom_nav_bar.dart'; import '../../common_widgets/app_drawer.dart'; @@ -24,6 +24,7 @@ class LandPage extends StatefulWidget { class _LandPageState extends State { final GlobalKey _scaffoldKey = GlobalKey(); int currentPageIndex = 0; + bool showAppbar =true; final List _pages = const [ DashboardPage(), MyRequestsPage(), @@ -53,11 +54,8 @@ class _LandPageState extends State { }, child: Scaffold( key: _scaffoldKey, - appBar: HomeAppBar(scaffoldKey: _scaffoldKey), - body: Padding( - padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth, end: 11.toScreenHeight), - child: _pages[currentPageIndex], - ), + appBar: showAppbar?HomeAppBar(scaffoldKey: _scaffoldKey): null, + body: _pages[currentPageIndex], drawer: const AppDrawer(), floatingActionButton: const AppFloatingActionButton(), bottomNavigationBar: AppBottomNavigationBar( @@ -74,6 +72,16 @@ class _LandPageState extends State { setState(() { currentPageIndex = index; }); + + if(index == 1){ + setState(() { + showAppbar =false; + }); + }else{ + setState(() { + showAppbar =true; + }); + } } }, ), diff --git a/lib/new_views/pages/land_page/my_request/my_requests_page.dart b/lib/new_views/pages/land_page/my_request/my_requests_page.dart new file mode 100644 index 00000000..b8653094 --- /dev/null +++ b/lib/new_views/pages/land_page/my_request/my_requests_page.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/models/enums/translation_keys.dart'; + +import '../../../app_style/app_color.dart'; +import '../../../common_widgets/app_search_field.dart'; + +class MyRequestsPage extends StatelessWidget { + const MyRequestsPage({Key key}) : super(key: key); + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + + leadingWidth: 0, + title: Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded(child: SizedBox( + height: 50, + child: AppSearchField())), + SizedBox(width: 20,), + Text(context.translate(TranslationKeys.filter), style: TextStyle( + color: AppColor.primary50, + fontSize: Theme.of(context).textTheme.bodySmall.fontSize, + fontWeight: FontWeight.w500 + ),) + ], + ), + ), + ), + + body: TabBarView( + children: const [ + Center( + child: Text("It's cloudy here"), + ), + Center( + child: Text("It's rainy here"), + ), + Center( + child: Text("It's sunny here"), + ), + ], + ), + ); + } +} diff --git a/lib/new_views/pages/land_page/my_requests_page.dart b/lib/new_views/pages/land_page/my_requests_page.dart deleted file mode 100644 index ccccada1..00000000 --- a/lib/new_views/pages/land_page/my_requests_page.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:flutter/material.dart'; - -class MyRequestsPage extends StatelessWidget { - const MyRequestsPage({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Text("My Requests"), - ), - ); - } -} diff --git a/lib/views/pages/user/gas_refill/track_gas_refill.dart b/lib/views/pages/user/gas_refill/track_gas_refill.dart index cd7df4ee..b08042a7 100644 --- a/lib/views/pages/user/gas_refill/track_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/track_gas_refill.dart @@ -4,12 +4,16 @@ import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; +import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/gas_refill/gas_refill_list.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; +import '../../../../models/enums/translation_keys.dart'; +import '../../../../new_views/app_style/app_color.dart'; +import '../../../../new_views/common_widgets/app_search_field.dart'; import '../../../widgets/switch_button.dart'; class TrackGasRefillPage extends StatefulWidget { @@ -31,13 +35,13 @@ class _TrackGasRefillPageState extends State with TickerProv Widget build(BuildContext context) { if (_gasRefillProvider == null) { _gasRefillProvider = Provider.of(context); - //_gasRefillProvider?.isLoading = false; _gasRefillProvider.reset(); } _userProvider = Provider.of(context); _settingProvider = Provider.of(context); return Scaffold( + body: SafeArea( child: LoadingManager( isLoading: _gasRefillProvider.isLoading, @@ -56,45 +60,64 @@ class _TrackGasRefillPageState extends State with TickerProv Column( children: [ Container( - color: AColors.white, - padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Column( + color: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), + //margin: const EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Row( - children: [ - const ABackButton(), - Expanded( - child: Center( - child: Text( - "Gas Refill Requests", - style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic), - ), - ), - ), - const SizedBox( - width: 48, - ) - ], - ), + Expanded(child: SizedBox( + height: 40, + child: AppSearchField())), + SizedBox(width: 20,), + Text(context.translate(TranslationKeys.filter), style: TextStyle( + color: AppColor.primary50, + fontSize: Theme.of(context).textTheme.bodySmall.fontSize, + fontWeight: FontWeight.w500 + ),) ], ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: ASwitchButton( - title: "Most Recent", - value: mostRecent, - onChange: (value) async { - mostRecent = value; - _gasRefillProvider.reset(); - await _gasRefillProvider.getRequests( - user: _userProvider.user, - host: _settingProvider.host, - mostRecent: mostRecent, - ); - }, - ), - ), + // Container( + // color: AColors.white, + // padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), + // child: Column( + // children: [ + // Row( + // children: [ + // const ABackButton(), + // Expanded( + // child: Center( + // child: Text( + // "Gas Refill Requests", + // style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic), + // ), + // ), + // ), + // const SizedBox( + // width: 48, + // ) + // ], + // ), + // ], + // ), + // ), + // Padding( + // padding: const EdgeInsets.symmetric(horizontal: 16.0), + // child: ASwitchButton( + // title: "Most Recent", + // value: mostRecent, + // onChange: (value) async { + // mostRecent = value; + // _gasRefillProvider.reset(); + // await _gasRefillProvider.getRequests( + // user: _userProvider.user, + // host: _settingProvider.host, + // mostRecent: mostRecent, + // ); + // }, + // ), + // ), Expanded( child: GasRefillList( nextPage: _gasRefillProvider.nextPage, diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 86861808..da6041d1 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -1,10 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:test_sa/controllers/localization/localization.dart'; -import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; -import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; -import 'package:test_sa/views/widgets/requests/request_status.dart'; + +import '../../../models/gas_refill/gas_refill_model.dart'; class GasRefillItem extends StatelessWidget { final int index; @@ -15,20 +12,17 @@ class GasRefillItem extends StatelessWidget { @override Widget build(BuildContext context) { - Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; - Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; return Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), - backgroundColor: itemColor, + backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), ), ), - //padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8), onPressed: () { onPressed(item); }, @@ -37,74 +31,81 @@ class GasRefillItem extends StatelessWidget { children: [ Row( children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - item.title ?? "-----", - style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), - ), - Row( - children: [ - Expanded( - child: Text( - context.translation.hospital, - style: Theme.of(context).textTheme.titleSmall.copyWith( - color: onItemColor, - ), - ), - ), - if (item.clientName != null) - Text( - item.clientName, - style: Theme.of(context).textTheme.titleSmall.copyWith( - color: onItemColor, - ), - ), - ], - ), - Divider(color: onItemColor), - Row( - children: [ - Expanded( - child: Text(context.translation.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - ), - if (item.status?.id != null) StatusLabel(label: item.status.name, backgroundColor: AColors.getGasStatusColor(item.status.id)), - ], - ), - if (item?.expectedDate != null) Divider(color: onItemColor), - if (item?.expectedDate != null) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - ], - ), - if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: item.details - .map( - (gas) => gas?.type?.name?.isNotEmpty ?? false - ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)) - : const SizedBox.shrink(), - ) - .toList(), - ) - ], - ), - ], - ), - ), + Text("priority"), + Text("process"), ], - ), + ) + + // Row( + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // item.title ?? "-----", + // style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), + // ), + // Row( + // children: [ + // Expanded( + // child: Text( + // subtitle.hospital, + // style: Theme.of(context).textTheme.titleSmall.copyWith( + // color: onItemColor, + // ), + // ), + // ), + // if (item.clientName != null) + // Text( + // item.clientName, + // style: Theme.of(context).textTheme.titleSmall.copyWith( + // color: onItemColor, + // ), + // ), + // ], + // ), + // Divider(color: onItemColor), + // Row( + // children: [ + // Expanded( + // child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // ), + // if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)), + // ], + // ), + // if (item?.expectedDate != null) Divider(color: onItemColor), + // if (item?.expectedDate != null) + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // ], + // ), + // if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // Column( + // crossAxisAlignment: CrossAxisAlignment.end, + // children: item.details + // .map( + // (gas) => gas?.type?.name?.isNotEmpty ?? false + // ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)) + // : const SizedBox.shrink(), + // ) + // .toList(), + // ) + // ], + // ), + // ], + // ), + // ), + // ], + // ), ], ), ), diff --git a/pubspec.lock b/pubspec.lock index b3a50550..4b2e01a2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -97,6 +97,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + buttons_tabbar: + dependency: "direct main" + description: + name: buttons_tabbar + sha256: "781128180f3e76cf93c093183f10395c664983dbee20bc4da2025be70085c2da" + url: "https://pub.dev" + source: hosted + version: "1.3.7+1" cached_network_image: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 7a84b17e..26ea7c35 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: path_provider: ^2.1.0 open_file: ^3.3.2 localization: ^2.1.0 + buttons_tabbar: ^1.3.7+1 dev_dependencies: flutter_test: