Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_classes/herald/app_design.dart';
5 : import 'package:app_finance/design/form/currency_selector.dart';
6 : import 'package:app_finance/design/form/list_selector.dart';
7 : import 'package:material_ui/material_ui.dart';
8 : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
9 :
10 : class CodeCurrencySelectorItem extends BaseListSelectorItem {
11 2 : @override
12 2 : Widget build(BuildContext context) => Padding(
13 : padding: const EdgeInsets.all(2),
14 4 : child: Text(item.code),
15 : );
16 :
17 0 : @override
18 : Widget suggest(BuildContext context) {
19 0 : return Row(
20 0 : mainAxisAlignment: AppDesign.getAlignment<MainAxisAlignment>(),
21 0 : children: [
22 0 : SizedBox(
23 : width: 42,
24 0 : child: item.flag != null ? Text(item.flag!) : null,
25 : ),
26 0 : Expanded(
27 0 : child: Column(
28 0 : children: [
29 0 : Align(alignment: Alignment.topLeft, child: Text(item.code)),
30 0 : Align(alignment: Alignment.topLeft, child: Text(item.name)),
31 : ],
32 : ),
33 : ),
34 0 : SizedBox(
35 : width: 32,
36 0 : child: Center(child: Text(item.symbol)),
37 : ),
38 : ],
39 : );
40 : }
41 :
42 2 : CodeCurrencySelectorItem(super.item);
43 : }
44 :
45 : class CodeCurrencySelector extends ListSelector<CodeCurrencySelectorItem> {
46 2 : CodeCurrencySelector({
47 : super.key,
48 : required super.setState,
49 : super.value,
50 : super.withLabel,
51 : super.hintColor,
52 : super.hintStyle,
53 : super.hintText,
54 : super.tooltip,
55 12 : }) : super(options: CurrencyProvider.getAll().map((e) => CodeCurrencySelectorItem(e)).toList());
56 : }
|