|
| 1 | +import 'package:fluent_ui/fluent_ui.dart'; |
| 2 | +import 'package:flutter_bloc/flutter_bloc.dart'; |
| 3 | +import 'package:squadron_en_route/components/kancolle_model/kancolle_model.dart'; |
| 4 | +import 'package:squadron_en_route/helper/mod.dart'; |
| 5 | + |
| 6 | +class QuestlistView extends StatefulWidget { |
| 7 | + const QuestlistView({super.key}); |
| 8 | + |
| 9 | + @override |
| 10 | + State<StatefulWidget> createState() => QuestlistViewState(); |
| 11 | +} |
| 12 | + |
| 13 | +class QuestlistViewState extends State<QuestlistView> { |
| 14 | + late int apiCount; |
| 15 | + late int apiCompletedKind; |
| 16 | + late List<Quest> apiList = []; |
| 17 | + late int apiExecCount; |
| 18 | + late List<ApiClist> apiCList; |
| 19 | + late int apiExecType; |
| 20 | + |
| 21 | + @override |
| 22 | + void initState() { |
| 23 | + super.initState(); |
| 24 | + apiList = []; |
| 25 | + } |
| 26 | + |
| 27 | + @override |
| 28 | + Widget build(BuildContext context) { |
| 29 | + return BlocListener<QuestlistCubit, QuestlistState>( |
| 30 | + listener: (context, state) { |
| 31 | + state.when( |
| 32 | + initial: () {}, |
| 33 | + loaded: (apiCount, apiCompletedKind, apiList, apiExecCount, |
| 34 | + apiCList, apiExecType) { |
| 35 | + this.apiCount = apiCount; |
| 36 | + this.apiCompletedKind = apiCompletedKind; |
| 37 | + this.apiList = List.from(apiList); |
| 38 | + this.apiExecCount = apiExecCount; |
| 39 | + this.apiCList = apiCList; |
| 40 | + this.apiExecType = apiExecType; |
| 41 | + setState(() {}); |
| 42 | + }, |
| 43 | + ); |
| 44 | + }, |
| 45 | + child: Column(children: [ |
| 46 | + CommandBar(primaryItems: [ |
| 47 | + CommandBarBuilderItem( |
| 48 | + builder: (context, mode, w) => Tooltip( |
| 49 | + message: context.L.webviewCameraTakePic, |
| 50 | + child: w, |
| 51 | + ), |
| 52 | + wrappedItem: CommandBarButton( |
| 53 | + icon: const Icon(FluentIcons.increase_indent), |
| 54 | + onPressed: () { |
| 55 | + setState(() { |
| 56 | + apiList.sort( |
| 57 | + (a, b) => b.apiState.index.compareTo(a.apiState.index)); |
| 58 | + }); |
| 59 | + }, |
| 60 | + ), |
| 61 | + ), |
| 62 | + ]), |
| 63 | + Expanded( |
| 64 | + child: ListView.builder( |
| 65 | + itemBuilder: (context, index) { |
| 66 | + return Tooltip( |
| 67 | + message: apiList[index].apiDetail, |
| 68 | + child: ListTile.selectable( |
| 69 | + leading: Text('月'), |
| 70 | + title: Text(apiList[index].apiTitle), |
| 71 | + trailing: Text(apiList[index].apiState.toString()), |
| 72 | + selected: |
| 73 | + apiList[index].apiState != QuestState.unaccepted, |
| 74 | + )); |
| 75 | + }, |
| 76 | + itemCount: apiList.length)), |
| 77 | + ])); |
| 78 | + } |
| 79 | +} |
0 commit comments