mirror of
https://github.com/ente-io/ente.git
synced 2025-08-13 09:47:17 +00:00
[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:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user