Advertisement
rifki_cs29

CategoryFilterCourierPage

Mar 8th, 2022
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 6.28 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_bloc/flutter_bloc.dart';
  3. import 'package:google_fonts/google_fonts.dart';
  4. import 'package:module_category/presentation/bloc/category_filter_courier_bloc/category_filter_courier_bloc.dart';
  5. import 'package:module_core/common/state_enum.dart';
  6. import 'package:module_core/utils/app_colors.dart';
  7.  
  8. class CategoryFilterCourierPage extends StatelessWidget {
  9.   CategoryFilterCourierPage({Key? key}) : super(key: key);
  10.  
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     Future.microtask(() =>
  14.         BlocProvider.of<CategoryFilterCourierBloc>(context, listen: false)
  15.             .add(OnClickFilterCourierDefault()));
  16.     return Container(
  17.       height: 475,
  18.       child: SingleChildScrollView(
  19.         child: Column(
  20.           mainAxisSize: MainAxisSize.min,
  21.           children: [
  22.             Stack(
  23.               alignment: Alignment.center,
  24.               children: [
  25.                 Container(
  26.                   height: 4,
  27.                   width: 150,
  28.                   decoration: BoxDecoration(
  29.                     color: Colors.grey[400],
  30.                     borderRadius: BorderRadius.circular(4),
  31.                   ),
  32.                 ),
  33.                 Padding(
  34.                   padding: const EdgeInsets.only(right: 8.0, top: 8),
  35.                   child: Row(
  36.                     mainAxisAlignment: MainAxisAlignment.end,
  37.                     children: [
  38.                       GestureDetector(
  39.                         onTap: () {
  40.                           Navigator.pop(context);
  41.                         },
  42.                         child: Icon(
  43.                           Icons.close,
  44.                           color: Color(0xffAEAFB2),
  45.                           size: 24,
  46.                         ),
  47.                       ),
  48.                     ],
  49.                   ),
  50.                 ),
  51.               ],
  52.             ),
  53.             SizedBox(height: 16),
  54.             Text(
  55.               'Pengiriman',
  56.               textAlign: TextAlign.center,
  57.               style: GoogleFonts.poppins(
  58.                 fontSize: 16,
  59.                 fontWeight: FontWeight.w600,
  60.               ),
  61.             ),
  62.             Container(
  63.               margin: EdgeInsets.symmetric(vertical: 16),
  64.               height: 1,
  65.               width: MediaQuery.of(context).size.width,
  66.               color: Color(0xffC4C4C4),
  67.             ),
  68.             Padding(
  69.               padding:
  70.                   const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
  71.               child: TextField(
  72.                 onChanged: (query) {
  73.                   context
  74.                       .read<CategoryFilterCourierBloc>()
  75.                       .add(OnChangeFilterCourierSearch(query));
  76.                 },
  77.                 decoration: InputDecoration(
  78.                     filled: true,
  79.                     fillColor: Color(0xffC6E4EC).withOpacity(0.5),
  80.                     hintText: 'Cari Lokasi...',
  81.                     labelStyle: TextStyle(
  82.                       fontFamily: GoogleFonts.poppins().fontFamily,
  83.                       color: Colors.grey[400],
  84.                     ),
  85.                     prefixIcon:
  86.                         Icon(Icons.search_sharp, color: AppColors.grueMedium),
  87.                     border: OutlineInputBorder(
  88.                         borderSide: BorderSide(
  89.                             color: Color(0xffC6E4EC).withOpacity(0.5)),
  90.                         borderRadius: BorderRadius.circular(24)),
  91.                     enabledBorder: OutlineInputBorder(
  92.                         borderSide: BorderSide(
  93.                             color: Color(0xffC6E4EC).withOpacity(0.5)),
  94.                         borderRadius: BorderRadius.circular(24)),
  95.                     focusedBorder: OutlineInputBorder(
  96.                         borderSide: BorderSide(
  97.                             color: Color(0xffC6E4EC).withOpacity(0.5)),
  98.                         borderRadius: BorderRadius.circular(24)),
  99.                     contentPadding: EdgeInsets.all(12)),
  100.                 textInputAction: TextInputAction.search,
  101.               ),
  102.             ),
  103.             BlocBuilder<CategoryFilterCourierBloc, CategoryFilterCourierState>(
  104.                 builder: (context, state) {
  105.               if (state.state == RequestState.Loading) {
  106.                 return Center(
  107.                   child: CircularProgressIndicator(),
  108.                 );
  109.               } else if (state.state == RequestState.Loaded) {
  110.                 return Container(
  111.                   margin: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
  112.                   height: 325,
  113.                   child: ListView.builder(
  114.                     itemCount: state.data?.response.data.length ?? 0,
  115.                     itemBuilder: (context, index) {
  116.                       return Container(
  117.                           margin: EdgeInsets.symmetric(vertical: 8),
  118.                           child: Column(
  119.                             children: [
  120.                               Row(
  121.                                 children: [
  122.                                   Text(
  123.                                     state.data?.response.data[index].courier ??
  124.                                         'Courirer Name',
  125.                                     style: GoogleFonts.roboto(
  126.                                         fontSize: 12,
  127.                                         fontWeight: FontWeight.w400),
  128.                                   ),
  129.                                 ],
  130.                               ),
  131.                               SizedBox(height: 12),
  132.                               Container(
  133.                                 height: 1,
  134.                                 color: Color(0xffC4C4C4),
  135.                               ),
  136.                             ],
  137.                           ));
  138.                     },
  139.                   ),
  140.                 );
  141.               } else if (state.state == RequestState.Empty) {
  142.                 return Center(
  143.                   child: Text('Data Kosong'),
  144.                 );
  145.               } else if (state.state == RequestState.Error) {
  146.                 return Center(
  147.                   child: Text('Error'),
  148.                 );
  149.               } else {
  150.                 return Container();
  151.               }
  152.             })
  153.           ],
  154.         ),
  155.       ),
  156.     );
  157.   }
  158. }
  159.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement