Untitled

mail@pastecode.io avatar
unknown
dart
6 months ago
7.8 kB
1
Indexable
Never
import 'package:TrackMat/core/extension/buildcontext_extension.dart';
import 'package:TrackMat/product/constant/app_const/image_constants.dart';
import 'package:TrackMat/product/local/shared_preferences.dart';
import 'package:TrackMat/product/model/Request/work_order_fulfillment/work_ff_warehouse_baskets_request.dart';
import 'package:TrackMat/product/services/abstract/iwork_order_fulfillment_service.dart';
import 'package:auto_route/annotations.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import '../../../core/models/base_response.dart';
import '../../../core/widgets/spec_platform_circular.dart';
import '../../model/Response/work_order_fulfillment/work_ff_warehouse_baskets_response.dart';
import '../../navigator/app_router.dart';
import '../widgets/custom_container.dart';

@RoutePage()
class WorkFfBasketsView extends ConsumerStatefulWidget {
  final String warehouseId;
  const WorkFfBasketsView({super.key, required this.warehouseId});

  @override
  _WorkFfBasketsViewState createState() => _WorkFfBasketsViewState();
}

class _WorkFfBasketsViewState extends ConsumerState<WorkFfBasketsView> {
  Future<
      BaseResponse<List<WorkFfWarehouseBasketsResponse>,
          WorkFfWarehouseBasketsResponse>>? futureResponse;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    futureResponse = GetIt.instance<IWorkOrderFulfillmentService>()
        .getWareHouseBaskets(WorkFfWarehouseBasketsRequest(
            secondaryInventoryName: widget.warehouseId,
            orgId: UserPreferences.instance.getIntItem("orgId")));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('İş Emri Karşılama'),
      ),
      body: FutureBuilder<
          BaseResponse<List<WorkFfWarehouseBasketsResponse>,
              WorkFfWarehouseBasketsResponse>>(
        future: futureResponse,
        builder: (BuildContext context,
            AsyncSnapshot<
                    BaseResponse<List<WorkFfWarehouseBasketsResponse>,
                        WorkFfWarehouseBasketsResponse>>
                snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.waiting:
              return Center(
                child: SpecPlatformCircular(
                  color: Colors.black,
                ),
              );
            case ConnectionState.none:
              return Center(
                child: Text("Beklenmedik bir hata oluştu!"),
              );
            case ConnectionState.active:
              return Center(
                child: SpecPlatformCircular(
                  color: Colors.black,
                ),
              );
            case ConnectionState.done:
              if (snapshot.data!.status) {
                return ListView.builder(
                    itemCount: snapshot.data!.data!.length,
                    itemBuilder: (context, index) {
                      return CustomContainer(widgets: [
                        IntrinsicHeight(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceAround,
                            children: [
                              Column(
                                children: [
                                  Text("Hedef Depo"),
                                  Text(
                                      "${snapshot.data!.data![index].targetWarehouseName}",
                                      style: Theme.of(context)
                                          .textTheme
                                          .bodyMedium!
                                          .copyWith(color: Colors.black))
                                ],
                              ),
                              VerticalDivider(),
                              Column(
                                children: [
                                  Text("Kaynak Depo"),
                                  Text(
                                      "${snapshot.data!.data![index].sourceWarehouseName}",
                                      style: Theme.of(context)
                                          .textTheme
                                          .bodyMedium!
                                          .copyWith(color: Colors.black))
                                ],
                              ),
                            ],
                          ),
                        ),
                        Divider(),
                        IntrinsicHeight(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceAround,
                            children: [
                              Column(
                                children: [
                                  Text("Görev Sayısı"),
                                  Text("${snapshot.data!.data![index].count}",
                                      style: Theme.of(context)
                                          .textTheme
                                          .bodyMedium!
                                          .copyWith(color: Colors.black))
                                ],
                              ),
                              VerticalDivider(),
                              Column(
                                children: [
                                  Text("Sipariş Tarihi"),
                                  Text(
                                      "${snapshot.data!.data![index].requestDate}",
                                      style: Theme.of(context)
                                          .textTheme
                                          .bodyMedium!
                                          .copyWith(color: Colors.black))
                                ],
                              )
                            ],
                          ),
                        ),
                        Divider(),
                        Stack(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                ElevatedButton(
                                    onPressed: () async => context.pushRoute(
                                        WorkFfBasketDetailRoute(
                                            basketDetail:
                                            snapshot.data!.data![index])),
                                    child: Text(
                                      "Sevk Etmeye Başla",
                                      style: TextStyle(color: Colors.white),
                                    )),
                                Positioned(
                                  right: 50,
                                  left: 50,
                                  child: Image.asset(
                                    ImageConstants.minMax,
                                    width: context.screenWidth * 0.1,
                                    height: context.screenHeight * 0.05,
                                  ),
                                )
                              ],
                            )
                          ],
                        )
                      ], width: context.screenWidth);
                    });
              } else {
                return Center(
                  child: Text(snapshot.data!.message ??
                      "Beklenmedik bir hata ile karşılaşıldı"),
                );
              }
          }
        },
      ),
    );
  }
}
Leave a Comment