import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/gas_refill/gas_refill_list.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import '../../../../models/enums/translation_keys.dart'; import '../../../../new_views/app_style/app_color.dart'; import '../../../../new_views/common_widgets/app_search_field.dart'; import '../../../widgets/switch_button.dart'; class TrackGasRefillPage extends StatefulWidget { static const String id = "/track-gas-refill"; const TrackGasRefillPage({Key key}) : super(key: key); @override State createState() => _TrackGasRefillPageState(); } class _TrackGasRefillPageState extends State with TickerProviderStateMixin { GasRefillProvider _gasRefillProvider; UserProvider _userProvider; SettingProvider _settingProvider; bool mostRecent = true; @override Widget build(BuildContext context) { if (_gasRefillProvider == null) { _gasRefillProvider = Provider.of(context); _gasRefillProvider.reset(); } _userProvider = Provider.of(context); _settingProvider = Provider.of(context); return Scaffold( body: SafeArea( child: LoadingManager( isLoading: _gasRefillProvider.isLoading, isFailedLoading: _gasRefillProvider.items == null, stateCode: _gasRefillProvider.stateCode, onRefresh: () async { _gasRefillProvider.reset(); await _gasRefillProvider.getRequests( user: _userProvider.user, host: _settingProvider.host, mostRecent: mostRecent, ); }, child: Stack( children: [ Column( children: [ Container( color: Colors.white, padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), //margin: const EdgeInsets.all(10), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded(child: SizedBox( height: 40, child: AppSearchField())), SizedBox(width: 20,), Text(context.translate(TranslationKeys.filter), style: TextStyle( color: AppColor.primary50, fontSize: Theme.of(context).textTheme.bodySmall.fontSize, fontWeight: FontWeight.w500 ),) ], ), ), // Container( // color: AColors.white, // padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), // child: Column( // children: [ // Row( // children: [ // const ABackButton(), // Expanded( // child: Center( // child: Text( // "Gas Refill Requests", // style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic), // ), // ), // ), // const SizedBox( // width: 48, // ) // ], // ), // ], // ), // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 16.0), // child: ASwitchButton( // title: "Most Recent", // value: mostRecent, // onChange: (value) async { // mostRecent = value; // _gasRefillProvider.reset(); // await _gasRefillProvider.getRequests( // user: _userProvider.user, // host: _settingProvider.host, // mostRecent: mostRecent, // ); // }, // ), // ), Expanded( child: GasRefillList( nextPage: _gasRefillProvider.nextPage, onLazyLoad: () async { await _gasRefillProvider.getRequests( user: _userProvider.user, host: _settingProvider.host, mostRecent: mostRecent, ); }, items: _gasRefillProvider.items, ), ), ], ), ], ), ), ), ); } }