|
@@ -1,6 +1,8 @@
|
|
|
import 'package:app_flowy/startup/startup.dart';
|
|
|
import 'package:app_flowy/workspace/application/grid/field/type_option/number_bloc.dart';
|
|
|
+import 'package:app_flowy/workspace/application/grid/field/type_option/number_format_bloc.dart';
|
|
|
import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart';
|
|
|
+import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart';
|
|
|
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_switcher.dart';
|
|
|
import 'package:flowy_infra/image.dart';
|
|
|
import 'package:flowy_infra/theme.dart';
|
|
@@ -67,7 +69,10 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
|
|
|
},
|
|
|
selectedFormat: state.typeOption.format,
|
|
|
);
|
|
|
- overlayDelegate.showOverlay(context, list);
|
|
|
+ overlayDelegate.showOverlay(
|
|
|
+ context,
|
|
|
+ list,
|
|
|
+ );
|
|
|
},
|
|
|
rightIcon: svgWidget("grid/more", color: theme.iconColor),
|
|
|
);
|
|
@@ -87,28 +92,42 @@ class NumberFormatList extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- final cells = NumberFormat.values.map((format) {
|
|
|
- return NumberFormatCell(
|
|
|
- isSelected: format == selectedFormat,
|
|
|
- format: format,
|
|
|
- onSelected: (format) {
|
|
|
- onSelected(format);
|
|
|
- FlowyOverlay.of(context).remove(NumberFormatList.identifier());
|
|
|
- });
|
|
|
- }).toList();
|
|
|
+ return BlocProvider(
|
|
|
+ create: (context) => NumberFormatBloc(),
|
|
|
+ child: SizedBox(
|
|
|
+ width: 180,
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ const _FilterTextField(),
|
|
|
+ BlocBuilder<NumberFormatBloc, NumberFormatState>(
|
|
|
+ builder: (context, state) {
|
|
|
+ final cells = state.formats.map((format) {
|
|
|
+ return NumberFormatCell(
|
|
|
+ isSelected: format == selectedFormat,
|
|
|
+ format: format,
|
|
|
+ onSelected: (format) {
|
|
|
+ onSelected(format);
|
|
|
+ FlowyOverlay.of(context).remove(NumberFormatList.identifier());
|
|
|
+ });
|
|
|
+ }).toList();
|
|
|
|
|
|
- return SizedBox(
|
|
|
- width: 180,
|
|
|
- child: ListView.separated(
|
|
|
- shrinkWrap: true,
|
|
|
- controller: ScrollController(),
|
|
|
- separatorBuilder: (context, index) {
|
|
|
- return VSpace(GridSize.typeOptionSeparatorHeight);
|
|
|
- },
|
|
|
- itemCount: cells.length,
|
|
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
- return cells[index];
|
|
|
- },
|
|
|
+ final list = ListView.separated(
|
|
|
+ shrinkWrap: true,
|
|
|
+ controller: ScrollController(),
|
|
|
+ separatorBuilder: (context, index) {
|
|
|
+ return VSpace(GridSize.typeOptionSeparatorHeight);
|
|
|
+ },
|
|
|
+ itemCount: cells.length,
|
|
|
+ itemBuilder: (BuildContext context, int index) {
|
|
|
+ return cells[index];
|
|
|
+ },
|
|
|
+ );
|
|
|
+ return Expanded(child: list);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
@@ -149,98 +168,16 @@ class NumberFormatCell extends StatelessWidget {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-extension NumberFormatExtension on NumberFormat {
|
|
|
- String title() {
|
|
|
- switch (this) {
|
|
|
- case NumberFormat.ArgentinePeso:
|
|
|
- return "Argentine peso";
|
|
|
- case NumberFormat.Baht:
|
|
|
- return "Baht";
|
|
|
- case NumberFormat.CanadianDollar:
|
|
|
- return "Canadian dollar";
|
|
|
- case NumberFormat.ChileanPeso:
|
|
|
- return "Chilean peso";
|
|
|
- case NumberFormat.ColombianPeso:
|
|
|
- return "Colombian peso";
|
|
|
- case NumberFormat.DanishKrone:
|
|
|
- return "Danish krone";
|
|
|
- case NumberFormat.Dirham:
|
|
|
- return "Dirham";
|
|
|
- case NumberFormat.EUR:
|
|
|
- return "Euro";
|
|
|
- case NumberFormat.Forint:
|
|
|
- return "Forint";
|
|
|
- case NumberFormat.Franc:
|
|
|
- return "Franc";
|
|
|
- case NumberFormat.HongKongDollar:
|
|
|
- return "Hone Kong dollar";
|
|
|
- case NumberFormat.Koruna:
|
|
|
- return "Koruna";
|
|
|
- case NumberFormat.Krona:
|
|
|
- return "Krona";
|
|
|
- case NumberFormat.Leu:
|
|
|
- return "Leu";
|
|
|
- case NumberFormat.Lira:
|
|
|
- return "Lira";
|
|
|
- case NumberFormat.MexicanPeso:
|
|
|
- return "Mexican Peso";
|
|
|
- case NumberFormat.NewTaiwanDollar:
|
|
|
- return "New Taiwan dollar";
|
|
|
- case NumberFormat.NewZealandDollar:
|
|
|
- return "New Zealand dollar";
|
|
|
- case NumberFormat.NorwegianKrone:
|
|
|
- return "Norwegian krone";
|
|
|
- case NumberFormat.Number:
|
|
|
- return "Number";
|
|
|
- case NumberFormat.Percent:
|
|
|
- return "Percent";
|
|
|
- case NumberFormat.PhilippinePeso:
|
|
|
- return "Percent";
|
|
|
- case NumberFormat.Pound:
|
|
|
- return "Pound";
|
|
|
- case NumberFormat.Rand:
|
|
|
- return "Rand";
|
|
|
- case NumberFormat.Real:
|
|
|
- return "Real";
|
|
|
- case NumberFormat.Ringgit:
|
|
|
- return "Ringgit";
|
|
|
- case NumberFormat.Riyal:
|
|
|
- return "Riyal";
|
|
|
- case NumberFormat.Ruble:
|
|
|
- return "Ruble";
|
|
|
- case NumberFormat.Rupee:
|
|
|
- return "Rupee";
|
|
|
- case NumberFormat.Rupiah:
|
|
|
- return "Rupiah";
|
|
|
- case NumberFormat.Shekel:
|
|
|
- return "Skekel";
|
|
|
- case NumberFormat.USD:
|
|
|
- return "US Dollar";
|
|
|
- case NumberFormat.UruguayanPeso:
|
|
|
- return "Uruguayan peso";
|
|
|
- case NumberFormat.Won:
|
|
|
- return "Uruguayan peso";
|
|
|
- case NumberFormat.Yen:
|
|
|
- return "Yen";
|
|
|
- case NumberFormat.Yuan:
|
|
|
- return "Yuan";
|
|
|
- default:
|
|
|
- throw UnimplementedError;
|
|
|
- }
|
|
|
+class _FilterTextField extends StatelessWidget {
|
|
|
+ const _FilterTextField({Key? key}) : super(key: key);
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return InputTextField(
|
|
|
+ text: "",
|
|
|
+ onCanceled: () {},
|
|
|
+ onChanged: (text) {
|
|
|
+ context.read<NumberFormatBloc>().add(NumberFormatEvent.setFilter(text));
|
|
|
+ },
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- // String iconName() {
|
|
|
- // switch (this) {
|
|
|
- // case NumberFormat.CNY:
|
|
|
- // return "grid/field/yen";
|
|
|
- // case NumberFormat.EUR:
|
|
|
- // return "grid/field/euro";
|
|
|
- // case NumberFormat.Number:
|
|
|
- // return "grid/field/numbers";
|
|
|
- // case NumberFormat.USD:
|
|
|
- // return "grid/field/us_dollar";
|
|
|
- // default:
|
|
|
- // throw UnimplementedError;
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|