settings: added coordinate format example
This commit is contained in:
parent
01b148139b
commit
65b6c9b355
3 changed files with 39 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class Constants {
|
||||
// as of Flutter v1.11.0, overflowing `Text` miscalculates height and some text (e.g. 'Å') is clipped
|
||||
|
@ -17,6 +18,8 @@ class Constants {
|
|||
offset: Offset(0.5, 1.0),
|
||||
);
|
||||
|
||||
static const pointNemo = Tuple2(-48.876667, -123.393333);
|
||||
|
||||
static const List<Dependency> androidDependencies = [
|
||||
Dependency(
|
||||
name: 'CWAC-Document',
|
||||
|
|
|
@ -3,14 +3,18 @@ import 'package:flutter/widgets.dart';
|
|||
|
||||
import 'aves_dialog.dart';
|
||||
|
||||
typedef TextBuilder<T> = String Function(T value);
|
||||
|
||||
class AvesSelectionDialog<T> extends StatefulWidget {
|
||||
final T initialValue;
|
||||
final Map<T, String> options;
|
||||
final TextBuilder<T> optionSubtitleBuilder;
|
||||
final String title;
|
||||
|
||||
const AvesSelectionDialog({
|
||||
@required this.initialValue,
|
||||
@required this.options,
|
||||
this.optionSubtitleBuilder,
|
||||
@required this.title,
|
||||
});
|
||||
|
||||
|
@ -41,7 +45,8 @@ class _AvesSelectionDialogState<T> extends State<AvesSelectionDialog> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _buildRadioListTile(T value, String title) => RadioListTile<T>(
|
||||
Widget _buildRadioListTile(T value, String title) {
|
||||
return RadioListTile<T>(
|
||||
key: Key(value.toString()),
|
||||
value: value,
|
||||
groupValue: _selectedValue,
|
||||
|
@ -56,5 +61,14 @@ class _AvesSelectionDialogState<T> extends State<AvesSelectionDialog> {
|
|||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
),
|
||||
subtitle: widget.optionSubtitleBuilder != null
|
||||
? Text(
|
||||
widget.optionSubtitleBuilder(value),
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:aves/model/settings/coordinate_format.dart';
|
|||
import 'package:aves/model/settings/home_page.dart';
|
||||
import 'package:aves/model/settings/screen_on.dart';
|
||||
import 'package:aves/model/settings/settings.dart';
|
||||
import 'package:aves/utils/constants.dart';
|
||||
import 'package:aves/widgets/common/aves_selection_dialog.dart';
|
||||
import 'package:aves/widgets/common/data_providers/media_query_data_provider.dart';
|
||||
import 'package:aves/widgets/common/highlight_title.dart';
|
||||
|
@ -80,6 +81,11 @@ class SettingsPage extends StatelessWidget {
|
|||
builder: (context) => AvesSelectionDialog<CoordinateFormat>(
|
||||
initialValue: settings.coordinateFormat,
|
||||
options: Map.fromEntries(CoordinateFormat.values.map((v) => MapEntry(v, v.name))),
|
||||
optionSubtitleBuilder: (dynamic value) {
|
||||
// dynamic declaration followed by cast, as workaround for generics limitation
|
||||
final formatter = (value as CoordinateFormat);
|
||||
return formatter.format(Constants.pointNemo);
|
||||
},
|
||||
title: 'Coordinate Format',
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue