diff --git a/lib/application/bottom_navbar_cubit/bottom_navbar_cubit.dart b/lib/application/bottom_navbar_cubit/bottom_navbar_cubit.dart index e925292..8827180 100644 --- a/lib/application/bottom_navbar_cubit/bottom_navbar_cubit.dart +++ b/lib/application/bottom_navbar_cubit/bottom_navbar_cubit.dart @@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../core/enums/enums.dart'; class NavigationCubit extends Cubit { - NavigationCubit() : super(NavigationTab.homeTab); + NavigationCubit() : super(NavigationTab.home); void updateTab(NavigationTab tab) => emit(tab); } diff --git a/lib/core/enums/enums.dart b/lib/core/enums/enums.dart index f25d7bd..9643444 100644 --- a/lib/core/enums/enums.dart +++ b/lib/core/enums/enums.dart @@ -1 +1 @@ -enum NavigationTab { homeTab, history, profileTab } +enum NavigationTab { home, histories, profile } diff --git a/lib/presentation/screens/histories_screen.dart b/lib/presentation/screens/histories_screen.dart new file mode 100644 index 0000000..c8d142c --- /dev/null +++ b/lib/presentation/screens/histories_screen.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../application/order_bloc/order_bloc.dart'; +import '../../configs/configs.dart'; +import '../../core/core.dart'; +import '../widgets/widgets.dart'; + +class HistoriesScreen extends StatelessWidget { + const HistoriesScreen({super.key}); + + @override + Widget build(BuildContext context) { + App.init(context); + return Scaffold( + backgroundColor: AppColors.surface, + body: NotificationListener( + onNotification: (ScrollNotification scrollInfo) { + if (scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent) { + context.read().add(const GetMoreOrders()); + } + return false; + }, + child: CustomScrollView( + slivers: [ + SliverToBoxAdapter( + child: Padding( + padding: Space.all(1, 1), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + /// gap + Space.yf(1.3), + + /// header text + Text( + 'Sargytlaryn taryhy', + style: AppText.h1b, + ), + const Text( + 'şu ýerde siziň sargytlaryňyz wagt tertipi boyunça görkezilen', + style: TextStyle( + color: AppColors.darkGrey, + ), + ), + ], + ), + ), + ), + BlocBuilder( + builder: (context, state) { + if (state is OrderLoading && state.orders.isEmpty) { + return const SliverToBoxAdapter( + child: Center( + child: CircularProgressIndicator(), + ), + ); + } else if (state is OrderError && state.orders.isEmpty) { + return SliverToBoxAdapter( + child: Center( + child: RetryWidget(onRetry: () { + context.read().add(GetOrders(state.params)); + }), + ), + ); + } else if (state is OrderLoaded) { + return SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + final order = state.orders[index]; + + if (index == state.orders.length - 1) { + // Trigger loading more orders when reaching the bottom + context.read().add(const GetMoreOrders()); + } + + return OrderCard(order: order); + }, + childCount: state.orders.length, + ), + ); + } else { + return const SliverToBoxAdapter( + child: Center( + child: Text('No orders available'), + ), + ); + } + }, + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/screens/order_details.dart b/lib/presentation/screens/order_details.dart index 2776872..182b398 100644 --- a/lib/presentation/screens/order_details.dart +++ b/lib/presentation/screens/order_details.dart @@ -56,7 +56,7 @@ class _OrderDetailsScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Sargyt barada maglumat №ABC456789', + 'Sargyt barada maglumat №${widget.order.no}', style: AppText.b1b, ), @@ -64,7 +64,7 @@ class _OrderDetailsScreenState extends State { Space.y!, /// info card - const InfoCard(), + InfoCard(order: widget.order), ], ), ), diff --git a/lib/presentation/screens/profile.dart b/lib/presentation/screens/profile.dart index a8ce8fb..a8e9246 100644 --- a/lib/presentation/screens/profile.dart +++ b/lib/presentation/screens/profile.dart @@ -62,7 +62,7 @@ class _ProfileScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ /// gap - Space.yf(1), + Space.yf(1.3), /// header Text( diff --git a/lib/presentation/screens/root.dart b/lib/presentation/screens/root.dart index dfc4c22..889bae7 100644 --- a/lib/presentation/screens/root.dart +++ b/lib/presentation/screens/root.dart @@ -64,11 +64,11 @@ class RootScreen extends StatelessWidget { child: BlocBuilder( builder: (context, activeTab) { switch (activeTab) { - case NavigationTab.homeTab: + case NavigationTab.home: return const OrdersScreen(); - case NavigationTab.history: - return const Text(' CategoriesScreen()'); - case NavigationTab.profileTab: + case NavigationTab.histories: + return const HistoriesScreen(); + case NavigationTab.profile: return const ProfileScreen(); default: return const OrdersScreen(); diff --git a/lib/presentation/screens/screens.dart b/lib/presentation/screens/screens.dart index 477fc72..8306dfb 100644 --- a/lib/presentation/screens/screens.dart +++ b/lib/presentation/screens/screens.dart @@ -1,3 +1,4 @@ +export 'histories_screen.dart'; export 'login.dart'; export 'order_details.dart'; export 'orders.dart'; diff --git a/lib/presentation/widgets/info_card.dart b/lib/presentation/widgets/info_card.dart index 83f39a1..8e906b9 100644 --- a/lib/presentation/widgets/info_card.dart +++ b/lib/presentation/widgets/info_card.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import '../../configs/configs.dart'; +import '../../domain/entities/order/order.dart'; class InfoCard extends StatelessWidget { - const InfoCard({super.key}); + final OrderEntity order; + const InfoCard({super.key, required this.order}); @override Widget build(BuildContext context) { @@ -16,25 +18,26 @@ class InfoCard extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const RowTextWidget(title: 'Ýagdaýy:', info: 'Ýolda'), + RowTextWidget(title: 'Ýagdaýy:', info: order.state), Space.y!, - const RowTextWidget(title: 'Awtoulag №:', info: 'ABC456789'), + RowTextWidget(title: 'Awtoulag №:', info: order.carrier), Space.y!, - const RowTextWidget(title: 'Dukan №:', info: 'ABC456789'), + RowTextWidget(title: 'Dukan №:', info: order.shopNo), Space.y!, - const RowTextWidget(title: 'Nireden ugradyldy:', info: 'Urumçy'), + RowTextWidget(title: 'Nireden ugradyldy:', info: order.from), Space.y!, - const RowTextWidget(title: 'Nirä barmaly:', info: 'Aşgabat'), + RowTextWidget(title: 'Nirä barmaly:', info: order.to), Space.y!, - const RowTextWidget(title: 'Ýer sany:', info: '36'), + RowTextWidget(title: 'Ýer sany:', info: order.placesCount.toString()), Space.y!, - const RowTextWidget(title: 'Kub:', info: '12 m3'), + RowTextWidget(title: 'Kub:', info: order.volume.toString()), Space.y!, - const RowTextWidget(title: 'Göwrumi:', info: '60x57x38 (ini, uzynlygy, beýikligi)'), + RowTextWidget( + title: 'Göwrumi:', info: '${order.width}x${order.depth}x${order.height} (ini, uzynlygy, beýikligi)'), Space.y!, - const RowTextWidget(title: 'Harydyň ady:', info: 'Köwüş'), - Space.y!, - const RowTextWidget(title: 'Sargydyň bahasy:', info: '300'), + RowTextWidget(title: 'Harydyň ady:', info: order.name), + // Space.y!, + // const RowTextWidget(title: 'Sargydyň bahasy:', info: '300'), ], ), ), @@ -61,13 +64,17 @@ class RowTextWidget extends StatelessWidget { style: AppText.b1!.copyWith( color: const Color(0xFF57575C), ), + maxLines: 2, ), Space.x!, - Text( - info, - style: AppText.b1!.copyWith( - color: const Color(0xFF0C0C0D), - fontWeight: FontWeight.w500, + Expanded( + child: Text( + info, + style: AppText.b1!.copyWith( + color: const Color(0xFF0C0C0D), + fontWeight: FontWeight.w500, + ), + maxLines: 2, ), ), ], diff --git a/lib/presentation/widgets/location_card.dart b/lib/presentation/widgets/location_card.dart index 0794fbd..40c9de2 100644 --- a/lib/presentation/widgets/location_card.dart +++ b/lib/presentation/widgets/location_card.dart @@ -38,7 +38,7 @@ class LocationCard extends StatelessWidget { route.isCurrent ? const Icon( Icons.radio_button_checked, - color: AppColors.grey, + color: AppColors.primary, ) : Container( margin: Space.hf(0.35),