class page
unknown
dart
2 years ago
7.4 kB
5
Indexable
// ignore_for_file: deprecated_member_use import 'package:course_coworkers/config/app_color.dart'; import 'package:course_coworkers/controllers/list_worker_controller.dart'; import 'package:course_coworkers/widgets/header_worker.dart'; import 'package:course_coworkers/widgets/section_title.dart'; import 'package:d_view/d_view.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ListWorkerPage extends StatefulWidget { const ListWorkerPage({super.key, required this.category}); final String category; @override State<ListWorkerPage> createState() => _ListWorkerPageState(); } class _ListWorkerPageState extends State<ListWorkerPage> { final listWorkerController = Get.put(ListWorkerController()); @override void initState() { listWorkerController.fetchAvailable(widget.category); super.initState(); } @override void dispose() { listWorkerController.clear(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: ListView( padding: const EdgeInsets.all(0), children: [ SizedBox( height: 172, child: Stack( children: [ Container( decoration: const BoxDecoration( color: AppColor.bgHeader, borderRadius: BorderRadius.only( bottomRight: Radius.circular(80), ), ), ), Transform.translate( offset: const Offset(0, 25), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.only(top: 40), child: HeaderWorker( title: widget.category, subTitle: '13,876', iconLeft: 'assets/ic_back.png', functionLeft: () => Navigator.pop(context), iconRight: 'assets/ic_filter.png', functionRight: () {}, ), ), searchBox(), ], ), ), ], ), ), DView.spaceHeight(50), topReatedCategory(), DView.spaceHeight(30), availableWorker(), DView.spaceHeight(30), ], ), ); } Widget searchBox() { return Container( height: 50, margin: const EdgeInsets.symmetric(horizontal: 20), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30), boxShadow: [ BoxShadow( color: const Color(0xffe5e7ec).withOpacity(0.5), blurRadius: 30, offset: const Offset(0, 6), ), ], ), alignment: Alignment.bottomLeft, padding: const EdgeInsets.only(left: 20, right: 8), child: Row( children: [ const Expanded( child: TextField( decoration: InputDecoration( hintText: 'Search by name', hintStyle: TextStyle( color: Color(0xffA7A8B3), fontSize: 16, fontWeight: FontWeight.w400, ), border: InputBorder.none, contentPadding: EdgeInsets.all(0), isDense: true, ), style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600, ), ), ), IconButton( onPressed: () {}, icon: const ImageIcon( AssetImage( 'assets/ic_search.png', ), ), ), ], ), ); } Widget topReatedCategory() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SectionTitle( text: 'Top Rated ${widget.category}', autoPadding: true, ), DView.spaceHeight(), SizedBox( height: 120, child: ListView.builder( physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, itemCount: listWorkerController.topRated.length, itemBuilder: (context, index) { Map worker = listWorkerController.topRated[index]; return Container( width: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), border: Border.all(color: const Color(0xffeaeaea)), ), margin: EdgeInsets.only( left: index == 0 ? 20 : 8, right: index == listWorkerController.topRated.length - 1 ? 20 : 8, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( worker['image'], width: 46, height: 46, ), DView.spaceHeight(6), Text( worker['name'], style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Colors.black, ), ), DView.spaceHeight(4), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/ic_star_small.png', height: 16, width: 16, ), DView.spaceHeight(2), Text( '${worker['rate']}', style: const TextStyle( color: Colors.black, ), ), ], ), ], ), ); }, ), ), ], ); } Widget availableWorker() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SectionTitle( text: 'Available Worker', autoPadding: true, ), DView.spaceHeight(), Obx(() { String statusFetch = listWorkerController.statusFetch; if (statusFetch == '') return DView.nothing(); if (statusFetch == 'Loading') return DView.loadingCircle(); if (statusFetch != 'Success') return DView.error(data: statusFetch); return DView.empty('success'); }) ], ); } }
Editor is loading...
Leave a Comment