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 1 : @override
12 1 : Widget build(BuildContext context) => Padding(
13 : padding: const EdgeInsets.all(2),
14 2 : child: Text(item.code),
15 : );
16 :
17 1 : @override
18 : Widget suggest(BuildContext context) {
19 1 : return Row(
20 1 : mainAxisAlignment: AppDesign.getAlignment<MainAxisAlignment>(),
21 1 : children: [
22 1 : SizedBox(
23 : width: 42,
24 3 : child: item.flag != null ? Text(item.flag!) : null,
25 : ),
26 1 : Expanded(
27 1 : child: Column(
28 1 : children: [
29 3 : Align(alignment: Alignment.topLeft, child: Text(item.code)),
30 3 : Align(alignment: Alignment.topLeft, child: Text(item.name)),
31 : ],
32 : ),
33 : ),
34 1 : SizedBox(
35 : width: 32,
36 3 : child: Center(child: Text(item.symbol)),
37 : ),
38 : ],
39 : );
40 : }
41 :
42 1 : CodeCurrencySelectorItem(super.item);
43 : }
44 :
45 : class CodeCurrencySelector extends ListSelector<CodeCurrencySelectorItem> {
46 1 : 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 6 : }) : super(options: CurrencyProvider.getAll().map((e) => CodeCurrencySelectorItem(e)).toList());
56 : }
|