Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ignore_for_file: public_member_api_docs, sort_constructors_first
- import 'package:auto_route/auto_route.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_bloc/flutter_bloc.dart';
- import 'package:flutter_hooks/flutter_hooks.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_svg/flutter_svg.dart';
- import 'package:get/get_utils/src/extensions/context_extensions.dart';
- import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
- import '../../../../../core/bloc/trigger_fetch_paging_list/trigger_fetch_paging_list_cubit.dart';
- import '../../../../../core/components/paging/widget/custom_pagination_view.dart';
- import '../../../../../core/components/space/space_component.dart';
- import '../../../../../core/config/router/router.dart';
- import '../../../../../core/config/theme/theme.dart';
- import '../../../../../core/utils/currency_util.dart';
- import '../../../domain/model/list/list_by_day/sales_order_list_by_day_model.dart';
- import '../../bloc/list/list_by_day/cubit/sales_order_list_by_day_cubit.dart';
- import '../../bloc/list/list_by_status/cubit/sales_order_list_by_status_cubit.dart';
- import 'sales_order_list_by_status_view.dart';
- class SalesOrderListByDayStatusView extends HookWidget {
- const SalesOrderListByDayStatusView({
- super.key,
- required this.branchIdSelected,
- required this.branchSelected,
- });
- final int branchIdSelected;
- final String branchSelected;
- @override
- Widget build(BuildContext context) {
- final PagingController<int, SalesOrderListByDayModel> _pagingController =
- useMemoized(() => PagingController(firstPageKey: 1));
- useEffect(() {
- _pagingController.addPageRequestListener((pageKey) {
- context.read<SalesOrderListByDayCubit>().fetchSalesOrderListByDay(
- pageKey: pageKey,
- pagingController: _pagingController,
- retryData: pageKey != 1 ? false : true,
- );
- });
- _pagingController.refresh();
- return () {
- _pagingController.dispose();
- };
- }, [_pagingController]);
- return Container(
- width: 1.sw,
- height: 1.sh,
- color: AccurateColor.grayBlue,
- child: MultiBlocListener(
- listeners: [
- BlocListener<TriggerFetchPagingListCubit, bool>(
- listener: (context, state) => {
- if (state)
- {
- Future.sync(
- () => _pagingController.refresh(),
- ),
- }
- },
- ),
- BlocListener<SalesOrderListByDayCubit, SalesOrderListByDayState>(
- listener: (context, state) => state.maybeWhen(
- orElse: () => null,
- failed: (failure) {
- return _pagingController.error = failure;
- },
- ),
- ),
- ],
- child: CustomPaginationView(
- pagingController: _pagingController,
- customRefresh: () {
- return context
- .read<SalesOrderListByStatusCubit>()
- .getSalesOrderByStatus();
- },
- topWidget: () => Column(
- children: [
- SalesOrderListByStatusView(
- branchSelected: branchSelected,
- branchIdSelected: branchIdSelected,
- ),
- BlocBuilder<SalesOrderListByDayCubit, SalesOrderListByDayState>(
- builder: (context, state) => state.maybeWhen(
- orElse: () => const SizedBox.shrink(),
- loading: () => const SizedBox.shrink(),
- failed: (_) => const SizedBox.shrink(),
- success: () => context
- .read<SalesOrderListByDayCubit>()
- .listData
- .isNotEmpty
- ? Container(
- margin: EdgeInsets.all(kDefLeftRight),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- 'Daftar Faktur Penjualan',
- style: context.textTheme.titleLarge,
- ),
- GestureDetector(
- onTap: () {
- context.pushRoute(
- SalesOrderRoute(
- isInitialData: false,
- soTitle: 'Semua Pesanan Penjualan',
- branchSelected: branchSelected,
- branchIdSelected: branchIdSelected,
- ),
- );
- },
- child: Text(
- 'Lihat Semua',
- style: context.textTheme.titleLarge!.copyWith(
- color: AccurateColor.blueAccurate,
- ),
- ),
- ),
- ],
- ),
- )
- : const SizedBox.shrink(),
- ),
- ),
- ],
- ),
- onEmptyData: () => Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- SvgPicture.asset('assets/svg/ic_no_data.svg'),
- SpaceComponentHeight(
- height: 15.h,
- ),
- Text(
- 'Belum memiliki Catatan Pesanan',
- style: context.textTheme.headlineLarge!,
- ),
- SpaceComponentHeight(
- height: 10.h,
- ),
- RichText(
- text: TextSpan(
- text:
- 'Anda belum memiliki catatan pesanan penjualan. Silakan klik tombol',
- style: context.textTheme.bodyLarge!.copyWith(
- color: AccurateColor.black50,
- ),
- children: [
- TextSpan(
- text: ' + ',
- style: context.textTheme.titleLarge,
- ),
- TextSpan(
- text: 'untuk membuat catatan pesanan penjualan',
- style: context.textTheme.bodyLarge!.copyWith(
- color: AccurateColor.black50,
- ),
- )
- ],
- ),
- textAlign: TextAlign.center,
- ),
- ],
- ),
- listItemBuilder: (item) {
- return GestureDetector(
- onTap: () async {
- context.pushRoute(
- SalesOrderRoute(
- isInitialData: false,
- soTitle:
- '${item.transDateView!.contains('Hari Ini') || item.transDateView!.contains('Kemarin') ? 'Pesanan Penjualan' : 'Pesanan'} ${item.transDateView}',
- branchSelected: branchSelected,
- branchIdSelected: branchIdSelected,
- transDate: item.transDate,
- ),
- );
- },
- child: Container(
- width: 0.9.sw,
- height: 80.h,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(10.r),
- ),
- margin: EdgeInsets.only(
- bottom: kDefTopBottom,
- left: kDefLeftRight,
- right: kDefLeftRight,
- ),
- child: Row(
- children: [
- Container(
- width: 10.w,
- height: 80.h,
- decoration: BoxDecoration(
- color: item.transDateView!.contains('Hari ini')
- ? AccurateColor.blueAccurate
- : AccurateColor.black50,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(10.r),
- bottomLeft: Radius.circular(10.r),
- ),
- ),
- ),
- Container(
- padding: EdgeInsets.all(kDefLeftRight),
- width: 0.85.sw,
- child: Column(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- item.transDateView!,
- style: context.textTheme.bodyLarge,
- ),
- Container(
- constraints: BoxConstraints(maxWidth: 0.35.sw),
- child: Text(
- CurrencyUtil.applyCurrencyFormatting(
- item.totalAmount.toString(),
- ),
- style: context.textTheme.titleLarge,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ],
- ),
- const SpaceComponentHeight(),
- Row(
- children: [
- SvgPicture.asset(
- 'assets/svg/sales_order/ic_so_item_amount.svg'),
- SpaceComponentWidth(
- width: 6.w,
- ),
- Text(
- '${item.count} Pesanan',
- style: context.textTheme.bodySmall!.copyWith(
- color: AccurateColor.black50,
- ),
- ),
- ],
- )
- ],
- ),
- ),
- ],
- ),
- ),
- );
- },
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement