[mob][photos] Upgrade flutter (#1434)

## Description

- Update flutter
- Update packages
- Fix UI issues because of update (material 3)
- bump up version to v0.8.80

## Tests

- [x] Building on android and iOS.

---------

Co-authored-by: Neeraj Gupta <254676+ua741@users.noreply.github.com>
This commit is contained in:
Ashil
2024-04-15 10:21:18 +05:30
committed by GitHub
parent 5a3545e56e
commit bb90b2d3bc
40 changed files with 793 additions and 601 deletions

View File

@@ -1,3 +1,6 @@
import "dart:io";
import "package:flutter/cupertino.dart";
import 'package:flutter/material.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/models/execution_states.dart';
@@ -25,8 +28,8 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
@override
void initState() {
toggleValue = widget.value.call();
super.initState();
toggleValue = widget.value.call();
}
@override
@@ -49,54 +52,23 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
height: 31,
child: FittedBox(
fit: BoxFit.contain,
child: Switch.adaptive(
activeColor: enteColorScheme.primary400,
inactiveTrackColor: enteColorScheme.fillMuted,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: toggleValue ?? false,
onChanged: (negationOfToggleValue) async {
setState(() {
toggleValue = negationOfToggleValue;
//start showing inProgress statu icons if toggle takes more than debounce time
_debouncer.run(
() => Future(
() {
setState(() {
executionState = ExecutionState.inProgress;
});
},
child: Platform.isAndroid
? Switch(
inactiveTrackColor: Colors.transparent,
activeTrackColor: enteColorScheme.primary500,
activeColor: Colors.white,
inactiveThumbColor: enteColorScheme.primary500,
trackOutlineColor: MaterialStateColor.resolveWith(
(states) => enteColorScheme.primary500,
),
);
});
final Stopwatch stopwatch = Stopwatch()..start();
await widget.onChanged.call().onError(
(error, stackTrace) => _debouncer.cancelDebounce(),
);
//for toggle feedback on short unsuccessful onChanged
await _feedbackOnUnsuccessfulToggle(stopwatch);
//debouncer gets canceled if onChanged takes less than debounce time
_debouncer.cancelDebounce();
final newValue = widget.value.call();
setState(() {
if (toggleValue == newValue) {
if (executionState == ExecutionState.inProgress) {
executionState = ExecutionState.successful;
Future.delayed(const Duration(seconds: 2), () {
if (mounted) {
setState(() {
executionState = ExecutionState.idle;
});
}
});
}
} else {
toggleValue = !toggleValue!;
executionState = ExecutionState.idle;
}
});
},
),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: toggleValue ?? false,
onChanged: _onChanged,
)
: CupertinoSwitch(
value: toggleValue ?? false,
onChanged: _onChanged,
),
),
),
],
@@ -132,4 +104,47 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
);
}
}
Future<void> _onChanged(bool negationOfToggleValue) async {
setState(() {
toggleValue = negationOfToggleValue;
//start showing inProgress statu icons if toggle takes more than debounce time
_debouncer.run(
() => Future(
() {
setState(() {
executionState = ExecutionState.inProgress;
});
},
),
);
});
final Stopwatch stopwatch = Stopwatch()..start();
await widget.onChanged.call().onError(
(error, stackTrace) => _debouncer.cancelDebounce(),
);
//for toggle feedback on short unsuccessful onChanged
await _feedbackOnUnsuccessfulToggle(stopwatch);
//debouncer gets canceled if onChanged takes less than debounce time
_debouncer.cancelDebounce();
final newValue = widget.value.call();
setState(() {
if (toggleValue == newValue) {
if (executionState == ExecutionState.inProgress) {
executionState = ExecutionState.successful;
Future.delayed(const Duration(seconds: 2), () {
if (mounted) {
setState(() {
executionState = ExecutionState.idle;
});
}
});
}
} else {
toggleValue = !toggleValue!;
executionState = ExecutionState.idle;
}
});
}
}