mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
wip
This commit is contained in:
parent
a7e0cca687
commit
6b3088ea04
7 changed files with 103 additions and 41 deletions
1
flutter_01.sksl.json
Normal file
1
flutter_01.sksl.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,10 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
|
|||
import 'mocks/application_mock.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const ApplicationMock(child: AnimatedPickerTest()));
|
||||
}
|
||||
|
||||
void main2() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('AnimatedDialogPicker test', () {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:lightmeter/data/models/film.dart';
|
||||
import 'package:lightmeter/data/models/supported_locale.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/providers.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart';
|
||||
import 'package:lightmeter/screens/metering/flow_metering.dart';
|
||||
import 'package:lightmeter/screens/settings/flow_settings.dart';
|
||||
import 'package:lightmeter/utils/inherited_generics.dart';
|
||||
|
@ -69,3 +72,61 @@ class _AnnotatedRegionWrapper extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedPickerTest extends StatefulWidget {
|
||||
const AnimatedPickerTest({super.key});
|
||||
|
||||
@override
|
||||
State<AnimatedPickerTest> createState() => _AnimatedPickerTestState();
|
||||
}
|
||||
|
||||
class _AnimatedPickerTestState extends State<AnimatedPickerTest> {
|
||||
Film _selectedFilm = Film.values.first;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: _FilmPicker(
|
||||
values: Film.values,
|
||||
selectedValue: _selectedFilm,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedFilm = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FilmPicker extends StatelessWidget {
|
||||
final List<Film> values;
|
||||
final Film selectedValue;
|
||||
final ValueChanged<Film> onChanged;
|
||||
|
||||
const _FilmPicker({
|
||||
required this.values,
|
||||
required this.selectedValue,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedDialogPicker<Film>(
|
||||
icon: Icons.camera_roll,
|
||||
title: "Film",
|
||||
selectedValue: selectedValue,
|
||||
values: values,
|
||||
itemTitleBuilder: (_, value) => Text(value.name.isEmpty ? 'None' : value.name),
|
||||
onChanged: onChanged,
|
||||
closedChild: ReadingValueContainer.singleValue(
|
||||
value: ReadingValue(
|
||||
label: "Film",
|
||||
value: selectedValue.name.isEmpty ? 'None' : selectedValue.name,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:lightmeter/application.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
//debugRepaintRainbowEnabled = true;
|
||||
runApp(const Application(Environment.dev()));
|
||||
}
|
||||
|
|
|
@ -22,15 +22,9 @@ class AnimatedDialog extends StatefulWidget {
|
|||
class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProviderStateMixin {
|
||||
final GlobalKey _key = GlobalKey();
|
||||
|
||||
late final Size _closedSize;
|
||||
late final Offset _closedOffset;
|
||||
|
||||
late final AnimationController _animationController;
|
||||
late final CurvedAnimation _defaultCurvedAnimation;
|
||||
late final Animation<Color?> _barrierColorAnimation;
|
||||
late final SizeTween _sizeTween;
|
||||
late final Animation<Size?> _sizeAnimation;
|
||||
late final Animation<Size?> _offsetAnimation;
|
||||
late final Animation<double> _borderRadiusAnimation;
|
||||
late final Animation<double> _closedOpacityAnimation;
|
||||
late final Animation<double> _openedOpacityAnimation;
|
||||
|
@ -87,36 +81,6 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
|||
),
|
||||
),
|
||||
);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
|
||||
_closedSize = _key.currentContext!.size!;
|
||||
_sizeTween = SizeTween(
|
||||
begin: _closedSize,
|
||||
end: widget.openedSize ??
|
||||
Size(
|
||||
mediaQuery.size.width -
|
||||
mediaQuery.padding.horizontal -
|
||||
Dimens.dialogMargin.horizontal,
|
||||
mediaQuery.size.height - mediaQuery.padding.vertical - Dimens.dialogMargin.vertical,
|
||||
),
|
||||
);
|
||||
_sizeAnimation = _sizeTween.animate(_defaultCurvedAnimation);
|
||||
|
||||
final renderBox = _key.currentContext!.findRenderObject()! as RenderBox;
|
||||
_closedOffset = renderBox.localToGlobal(Offset.zero);
|
||||
_offsetAnimation = SizeTween(
|
||||
begin: Size(
|
||||
_closedOffset.dx + _closedSize.width / 2,
|
||||
_closedOffset.dy + _closedSize.height / 2,
|
||||
),
|
||||
end: Size(
|
||||
mediaQuery.size.width / 2,
|
||||
mediaQuery.size.height / 2 + mediaQuery.padding.top / 2 - mediaQuery.padding.bottom / 2,
|
||||
),
|
||||
).animate(_defaultCurvedAnimation);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -152,6 +116,30 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
|||
}
|
||||
|
||||
void _openDialog() {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final closedSize = _key.currentContext!.size!;
|
||||
final sizeTween = SizeTween(
|
||||
begin: closedSize,
|
||||
end: widget.openedSize ??
|
||||
Size(
|
||||
mediaQuery.size.width - mediaQuery.padding.horizontal - Dimens.dialogMargin.horizontal,
|
||||
mediaQuery.size.height - mediaQuery.padding.vertical - Dimens.dialogMargin.vertical,
|
||||
),
|
||||
);
|
||||
final sizeAnimation = sizeTween.animate(_defaultCurvedAnimation);
|
||||
final renderBox = _key.currentContext!.findRenderObject()! as RenderBox;
|
||||
final closedOffset = renderBox.localToGlobal(Offset.zero);
|
||||
final offsetAnimation = SizeTween(
|
||||
begin: Size(
|
||||
closedOffset.dx + closedSize.width / 2,
|
||||
closedOffset.dy + closedSize.height / 2,
|
||||
),
|
||||
end: Size(
|
||||
mediaQuery.size.width / 2,
|
||||
mediaQuery.size.height / 2 + mediaQuery.padding.top / 2 - mediaQuery.padding.bottom / 2,
|
||||
),
|
||||
).animate(_defaultCurvedAnimation);
|
||||
|
||||
Navigator.of(context).push(
|
||||
PageRouteBuilder(
|
||||
barrierColor: Colors.transparent,
|
||||
|
@ -163,19 +151,19 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
|||
child: _AnimatedOverlay(
|
||||
controller: _animationController,
|
||||
barrierColorAnimation: _barrierColorAnimation,
|
||||
sizeAnimation: _sizeAnimation,
|
||||
offsetAnimation: _offsetAnimation,
|
||||
sizeAnimation: sizeAnimation,
|
||||
offsetAnimation: offsetAnimation,
|
||||
borderRadiusAnimation: _borderRadiusAnimation,
|
||||
foregroundColorAnimation: _foregroundColorAnimation,
|
||||
elevationAnimation: _elevationAnimation,
|
||||
onDismiss: close,
|
||||
builder: widget.closedChild != null && widget.openedChild != null
|
||||
? (_) => _AnimatedSwitcher(
|
||||
sizeAnimation: _sizeAnimation,
|
||||
sizeAnimation: sizeAnimation,
|
||||
closedOpacityAnimation: _closedOpacityAnimation,
|
||||
openedOpacityAnimation: _openedOpacityAnimation,
|
||||
closedSize: _sizeTween.begin!,
|
||||
openedSize: _sizeTween.end!,
|
||||
closedSize: sizeTween.begin!,
|
||||
openedSize: sizeTween.end!,
|
||||
closedChild: widget.closedChild!,
|
||||
openedChild: widget.openedChild!,
|
||||
)
|
||||
|
|
|
@ -139,6 +139,7 @@ class _MeteringContainerBuidler extends StatelessWidget {
|
|||
if (ev.isNaN || ev.isInfinite) {
|
||||
return List.empty();
|
||||
}
|
||||
return List.empty();
|
||||
|
||||
/// Depending on the `stopType` the exposure pairs list length is multiplied by 1,2 or 3
|
||||
final StopType stopType = context.listen<StopType>();
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
https://github.com/gskinnerTeam/flutter-folio/tree/master/benchmark
|
||||
https://github.com/2d-inc/developer_quest/blob/master/test_driver/performance_test.dart
|
||||
|
||||
|
||||
|
||||
Trace actions
|
||||
```console
|
||||
flutter drive \
|
||||
|
|
Loading…
Reference in a new issue