transparent status bar on Android

unified metering screen dialogs
This commit is contained in:
Vadim 2022-12-04 22:46:11 +03:00
parent 1c344da29f
commit 0a45a2719b
3 changed files with 55 additions and 47 deletions

View file

@ -36,10 +36,11 @@ class _ApplicationState extends State<Application> with TickerProviderStateMixin
void initState() { void initState() {
super.initState(); super.initState();
final mySystemTheme = SystemUiOverlayStyle.light.copyWith( final mySystemTheme = SystemUiOverlayStyle.light.copyWith(
statusBarColor: lightColorScheme.surface, statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.light, statusBarBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark,
systemNavigationBarColor: lightColorScheme.surface, systemNavigationBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
); );
SystemChrome.setSystemUIOverlayStyle(mySystemTheme); SystemChrome.setSystemUIOverlayStyle(mySystemTheme);
// 0 - collapsed // 0 - collapsed

View file

@ -55,7 +55,10 @@ class _MeteringScreenDialogPickerState<T> extends State<MeteringScreenDialogPick
itemBuilder: (context, index) => RadioListTile( itemBuilder: (context, index) => RadioListTile(
value: widget.values[index], value: widget.values[index],
groupValue: _selectedValue, groupValue: _selectedValue,
title: widget.itemTitleBuilder(context, widget.values[index]), title: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyLarge!,
child: widget.itemTitleBuilder(context, widget.values[index]),
),
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
setState(() { setState(() {

View file

@ -93,31 +93,18 @@ class MeteringTopBar extends StatelessWidget {
const _InnerPadding(), const _InnerPadding(),
SizedBox( SizedBox(
width: columnWidth, width: columnWidth,
child: AnimatedDialog( child: _AnimatedDialogPicker(
key: _isoDialogKey, key: _isoDialogKey,
closedChild: ReadingContainer.singleValue( title: S.of(context).iso,
value: ReadingValue( selectedValue: iso,
label: S.of(context).iso, values: isoValues,
value: iso.value.toString(), itemTitleBuilder: (context, value) => Text(
), value.value.toString(),
), style: value.stopType == StopType.full
openedChild: MeteringScreenDialogPicker( ? null // use default
title: S.of(context).iso, : Theme.of(context).textTheme.bodySmall,
initialValue: iso,
values: isoValues,
itemTitleBuilder: (context, value) => Text(
value.value.toString(),
style: value.stopType == StopType.full
? Theme.of(context).textTheme.bodyLarge
: Theme.of(context).textTheme.bodySmall,
),
onCancel: () {
_isoDialogKey.currentState?.close();
},
onSelect: (value) {
_isoDialogKey.currentState?.close().then((_) => onIsoChanged(value));
},
), ),
onChanged: onIsoChanged,
), ),
), ),
], ],
@ -142,29 +129,15 @@ class MeteringTopBar extends StatelessWidget {
), ),
), ),
const _InnerPadding(), const _InnerPadding(),
AnimatedDialog( _AnimatedDialogPicker(
key: _ndDialogKey, key: _ndDialogKey,
closedChild: ReadingContainer.singleValue( title: S.of(context).nd,
value: ReadingValue( selectedValue: nd,
label: S.of(context).nd, values: ndValues,
value: nd.value.toString(), itemTitleBuilder: (context, value) => Text(
), value.value == 0 ? S.of(context).none : value.value.toString(),
),
openedChild: MeteringScreenDialogPicker(
title: S.of(context).nd,
initialValue: nd,
values: ndValues,
itemTitleBuilder: (context, value) => Text(
value.value == 0 ? S.of(context).none : value.value.toString(),
style: Theme.of(context).textTheme.bodyLarge,
),
onCancel: () {
_ndDialogKey.currentState?.close();
},
onSelect: (value) {
_ndDialogKey.currentState?.close().then((_) => onNdChanged(value));
},
), ),
onChanged: onNdChanged,
), ),
], ],
), ),
@ -182,3 +155,34 @@ class MeteringTopBar extends StatelessWidget {
class _InnerPadding extends SizedBox { class _InnerPadding extends SizedBox {
const _InnerPadding() : super(height: Dimens.grid16, width: Dimens.grid16); const _InnerPadding() : super(height: Dimens.grid16, width: Dimens.grid16);
} }
class _AnimatedDialogPicker<T extends PhotographyValue> extends AnimatedDialog {
_AnimatedDialogPicker({
required GlobalKey<AnimatedDialogState> key,
required String title,
required T selectedValue,
required List<T> values,
required Widget Function(BuildContext, T) itemTitleBuilder,
required ValueChanged<T> onChanged,
}) : super(
key: key,
closedChild: ReadingContainer.singleValue(
value: ReadingValue(
label: title,
value: selectedValue.value.toString(),
),
),
openedChild: MeteringScreenDialogPicker(
title: title,
initialValue: selectedValue,
values: values,
itemTitleBuilder: itemTitleBuilder,
onCancel: () {
key.currentState?.close();
},
onSelect: (value) {
key.currentState?.close().then((_) => onChanged(value));
},
),
);
}