diff --git a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart deleted file mode 100644 index f9d6d47..0000000 --- a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:lightmeter/res/dimens.dart'; - -import 'package:lightmeter/screens/metering/components/bottom_controls/widget_bottom_controls.dart'; - -class MeteringBottomControlsProvider extends StatelessWidget { - final double? ev; - final double? ev100; - final bool isMetering; - final VoidCallback? onSwitchEvSourceType; - final VoidCallback onMeasure; - final VoidCallback onSettings; - - const MeteringBottomControlsProvider({ - required this.ev, - required this.ev100, - required this.isMetering, - required this.onSwitchEvSourceType, - required this.onMeasure, - required this.onSettings, - super.key, - }); - - @override - Widget build(BuildContext context) { - final scheme = Theme.of(context).colorScheme; - return IconButtonTheme( - data: IconButtonThemeData( - style: ButtonStyle( - backgroundColor: MaterialStatePropertyAll(scheme.surface), - elevation: const MaterialStatePropertyAll(4), - iconColor: MaterialStatePropertyAll(scheme.onSurface), - shadowColor: const MaterialStatePropertyAll(Colors.transparent), - surfaceTintColor: MaterialStatePropertyAll(scheme.surfaceTint), - fixedSize: const MaterialStatePropertyAll(Size(Dimens.grid48, Dimens.grid48)), - ), - ), - child: MeteringBottomControls( - ev: ev, - ev100: ev100, - isMetering: isMetering, - onSwitchEvSourceType: onSwitchEvSourceType, - onMeasure: onMeasure, - onSettings: onSettings, - ), - ); - } -} diff --git a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart index 0eef568..5882f8d 100644 --- a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/ev_source_type.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/user_preferences_provider.dart'; -import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart'; +import 'package:lightmeter/screens/shared/bottom_controls_bar/widget_bottom_controls_bar.dart'; class MeteringBottomControls extends StatelessWidget { final double? ev; @@ -25,58 +25,30 @@ class MeteringBottomControls extends StatelessWidget { @override Widget build(BuildContext context) { - return ClipRRect( - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(Dimens.borderRadiusL), - topRight: Radius.circular(Dimens.borderRadiusL), + return BottomControlsBar( + left: onSwitchEvSourceType != null + ? IconButton( + onPressed: onSwitchEvSourceType, + icon: Icon( + UserPreferencesProvider.evSourceTypeOf(context) != EvSourceType.camera + ? Icons.camera_rear + : Icons.wb_incandescent, + ), + tooltip: UserPreferencesProvider.evSourceTypeOf(context) != EvSourceType.camera + ? S.of(context).tooltipUseCamera + : S.of(context).tooltipUseLightSensor, + ) + : null, + center: MeteringMeasureButton( + ev: ev, + ev100: ev100, + isMetering: isMetering, + onTap: onMeasure, ), - child: ColoredBox( - color: Theme.of(context).colorScheme.surface, - child: SafeArea( - top: false, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - if (onSwitchEvSourceType != null) - Expanded( - child: Center( - child: IconButton( - onPressed: onSwitchEvSourceType, - icon: Icon( - UserPreferencesProvider.evSourceTypeOf(context) != EvSourceType.camera - ? Icons.camera_rear - : Icons.wb_incandescent, - ), - tooltip: - UserPreferencesProvider.evSourceTypeOf(context) != EvSourceType.camera - ? S.of(context).tooltipUseCamera - : S.of(context).tooltipUseLightSensor, - ), - ), - ) - else - const Spacer(), - MeteringMeasureButton( - ev: ev, - ev100: ev100, - isMetering: isMetering, - onTap: onMeasure, - ), - Expanded( - child: Center( - child: IconButton( - onPressed: onSettings, - icon: const Icon(Icons.settings), - tooltip: S.of(context).tooltipOpenSettings, - ), - ), - ), - ], - ), - ), - ), + right: IconButton( + onPressed: onSettings, + icon: const Icon(Icons.settings), + tooltip: S.of(context).tooltipOpenSettings, ), ); } diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index 6674773..e558706 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -8,7 +8,7 @@ import 'package:lightmeter/providers/equipment_profile_provider.dart'; import 'package:lightmeter/providers/services_provider.dart'; import 'package:lightmeter/providers/user_preferences_provider.dart'; import 'package:lightmeter/screens/metering/bloc_metering.dart'; -import 'package:lightmeter/screens/metering/components/bottom_controls/provider_bottom_controls.dart'; +import 'package:lightmeter/screens/metering/components/bottom_controls/widget_bottom_controls.dart'; import 'package:lightmeter/screens/metering/components/camera_container/provider_container_camera.dart'; import 'package:lightmeter/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart'; import 'package:lightmeter/screens/metering/event_metering.dart'; @@ -39,7 +39,7 @@ class MeteringScreen extends StatelessWidget { ), ), BlocBuilder( - builder: (context, state) => MeteringBottomControlsProvider( + builder: (context, state) => MeteringBottomControls( ev: state is MeteringDataState ? state.ev : null, ev100: state is MeteringDataState ? state.ev100 : null, isMetering: state.isMetering, diff --git a/lib/screens/shared/bottom_controls_bar/widget_bottom_controls_bar.dart b/lib/screens/shared/bottom_controls_bar/widget_bottom_controls_bar.dart new file mode 100644 index 0000000..b8ad576 --- /dev/null +++ b/lib/screens/shared/bottom_controls_bar/widget_bottom_controls_bar.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class BottomControlsBar extends StatelessWidget { + final Widget center; + final IconButton? left; + final IconButton? right; + + const BottomControlsBar({ + required this.center, + this.left, + this.right, + super.key, + }); + + @override + Widget build(BuildContext context) { + final scheme = Theme.of(context).colorScheme; + return IconButtonTheme( + data: IconButtonThemeData( + style: ButtonStyle( + backgroundColor: MaterialStatePropertyAll(scheme.surface), + elevation: const MaterialStatePropertyAll(4), + iconColor: MaterialStatePropertyAll(scheme.onSurface), + shadowColor: const MaterialStatePropertyAll(Colors.transparent), + surfaceTintColor: MaterialStatePropertyAll(scheme.surfaceTint), + fixedSize: const MaterialStatePropertyAll(Size(Dimens.grid48, Dimens.grid48)), + ), + ), + child: ClipRRect( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(Dimens.borderRadiusL), + topRight: Radius.circular(Dimens.borderRadiusL), + ), + child: ColoredBox( + color: Theme.of(context).colorScheme.surface, + child: SafeArea( + top: false, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + if (left != null) Expanded(child: Center(child: left)) else const Spacer(), + center, + if (right != null) Expanded(child: Center(child: right)) else const Spacer(), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/screens/timer/flow_timer.dart b/lib/screens/timer/flow_timer.dart index 68b219c..99cc696 100644 --- a/lib/screens/timer/flow_timer.dart +++ b/lib/screens/timer/flow_timer.dart @@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/interactors/metering_interactor.dart'; import 'package:lightmeter/providers/services_provider.dart'; -import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/timer/bloc_timer.dart'; import 'package:lightmeter/screens/timer/screen_timer.dart'; @@ -16,36 +15,23 @@ class TimerFlow extends StatelessWidget { @override Widget build(BuildContext context) { - final scheme = Theme.of(context).colorScheme; - return IconButtonTheme( - data: IconButtonThemeData( - style: ButtonStyle( - backgroundColor: MaterialStatePropertyAll(scheme.surface), - elevation: const MaterialStatePropertyAll(4), - iconColor: MaterialStatePropertyAll(scheme.onSurface), - shadowColor: const MaterialStatePropertyAll(Colors.transparent), - surfaceTintColor: MaterialStatePropertyAll(scheme.surfaceTint), - fixedSize: const MaterialStatePropertyAll(Size(Dimens.grid48, Dimens.grid48)), + return MeteringInteractorProvider( + data: MeteringInteractor( + ServicesProvider.of(context).userPreferencesService, + ServicesProvider.of(context).caffeineService, + ServicesProvider.of(context).hapticsService, + ServicesProvider.of(context).permissionsService, + ServicesProvider.of(context).lightSensorService, + ServicesProvider.of(context).volumeEventsService, + )..initialize(), + child: BlocProvider( + create: (context) => TimerBloc( + MeteringInteractorProvider.of(context), + _duration, ), - ), - child: MeteringInteractorProvider( - data: MeteringInteractor( - ServicesProvider.of(context).userPreferencesService, - ServicesProvider.of(context).caffeineService, - ServicesProvider.of(context).hapticsService, - ServicesProvider.of(context).permissionsService, - ServicesProvider.of(context).lightSensorService, - ServicesProvider.of(context).volumeEventsService, - )..initialize(), - child: BlocProvider( - create: (context) => TimerBloc( - MeteringInteractorProvider.of(context), - _duration, - ), - child: TimerScreen( - exposurePair: exposurePair, - duration: _duration, - ), + child: TimerScreen( + exposurePair: exposurePair, + duration: _duration, ), ), ); diff --git a/lib/screens/timer/screen_timer.dart b/lib/screens/timer/screen_timer.dart index b98b6a6..0ab9a91 100644 --- a/lib/screens/timer/screen_timer.dart +++ b/lib/screens/timer/screen_timer.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/res/dimens.dart'; +import 'package:lightmeter/screens/shared/bottom_controls_bar/widget_bottom_controls_bar.dart'; import 'package:lightmeter/screens/timer/bloc_timer.dart'; import 'package:lightmeter/screens/timer/components/text/widget_text_timer.dart'; import 'package:lightmeter/screens/timer/components/timeline/widget_timeline_timer.dart'; @@ -77,14 +78,15 @@ class _TimerScreenState extends State with TickerProviderStateMixin actions: [if (Navigator.of(context).canPop()) const CloseButton()], ), body: SafeArea( + bottom: false, child: Center( - child: Padding( - padding: const EdgeInsets.all(Dimens.paddingL), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Spacer(), - SizedBox.fromSize( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Spacer(), + Padding( + padding: const EdgeInsets.all(Dimens.paddingL), + child: SizedBox.fromSize( size: Size.square(MediaQuery.sizeOf(context).width - Dimens.paddingL * 4), child: ValueListenableBuilder( valueListenable: timelineAnimation, @@ -97,44 +99,36 @@ class _TimerScreenState extends State with TickerProviderStateMixin ), ), ), - const Spacer(), - Row( - children: [ - Expanded( - child: Center( - child: IconButton( - onPressed: () { - context.read().add(const ResetTimerEvent()); - }, - icon: const Icon(Icons.restore), - ), - ), - ), - SizedBox.fromSize( - size: const Size.square(Dimens.grid72), - child: BlocBuilder( - builder: (_, state) => FloatingActionButton( - shape: state is TimerResumedState ? null : const CircleBorder(), - onPressed: () { - if (timelineAnimation.value == 0) { - return; - } - final event = - state is TimerStoppedState ? const StartTimerEvent() : const StopTimerEvent(); - context.read().add(event); - }, - child: AnimatedIcon( - icon: AnimatedIcons.play_pause, - progress: startStopIconAnimation, - ), - ), - ), - ), - const Spacer(), - ], + ), + const Spacer(), + BottomControlsBar( + left: IconButton( + onPressed: () { + context.read().add(const ResetTimerEvent()); + }, + icon: const Icon(Icons.restore), ), - ], - ), + center: SizedBox.fromSize( + size: const Size.square(Dimens.grid72), + child: BlocBuilder( + builder: (_, state) => FloatingActionButton( + shape: state is TimerResumedState ? null : const CircleBorder(), + onPressed: () { + if (timelineAnimation.value == 0) { + return; + } + final event = state is TimerStoppedState ? const StartTimerEvent() : const StopTimerEvent(); + context.read().add(event); + }, + child: AnimatedIcon( + icon: AnimatedIcons.play_pause, + progress: startStopIconAnimation, + ), + ), + ), + ), + ), + ], ), ), ),