added histories screen
This commit is contained in:
parent
883c196aae
commit
9b38337f94
|
|
@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import '../../core/enums/enums.dart';
|
||||
|
||||
class NavigationCubit extends Cubit<NavigationTab> {
|
||||
NavigationCubit() : super(NavigationTab.homeTab);
|
||||
NavigationCubit() : super(NavigationTab.home);
|
||||
|
||||
void updateTab(NavigationTab tab) => emit(tab);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
enum NavigationTab { homeTab, history, profileTab }
|
||||
enum NavigationTab { home, histories, profile }
|
||||
|
|
|
|||
|
|
@ -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<ScrollNotification>(
|
||||
onNotification: (ScrollNotification scrollInfo) {
|
||||
if (scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent) {
|
||||
context.read<OrderBloc>().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<OrderBloc, OrderState>(
|
||||
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<OrderBloc>().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<OrderBloc>().add(const GetMoreOrders());
|
||||
}
|
||||
|
||||
return OrderCard(order: order);
|
||||
},
|
||||
childCount: state.orders.length,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SliverToBoxAdapter(
|
||||
child: Center(
|
||||
child: Text('No orders available'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||
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<OrderDetailsScreen> {
|
|||
Space.y!,
|
||||
|
||||
/// info card
|
||||
const InfoCard(),
|
||||
InfoCard(order: widget.order),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// gap
|
||||
Space.yf(1),
|
||||
Space.yf(1.3),
|
||||
|
||||
/// header
|
||||
Text(
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ class RootScreen extends StatelessWidget {
|
|||
child: BlocBuilder<NavigationCubit, NavigationTab>(
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export 'histories_screen.dart';
|
||||
export 'login.dart';
|
||||
export 'order_details.dart';
|
||||
export 'orders.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,14 +64,18 @@ class RowTextWidget extends StatelessWidget {
|
|||
style: AppText.b1!.copyWith(
|
||||
color: const Color(0xFF57575C),
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
Space.x!,
|
||||
Text(
|
||||
Expanded(
|
||||
child: Text(
|
||||
info,
|
||||
style: AppText.b1!.copyWith(
|
||||
color: const Color(0xFF0C0C0D),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in New Issue