Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Use custom toggle widget to remove UI issues after migrating to material 3

ashilkna3f102c183b2
diff --git a/mobile/lib/models/typedefs.dart b/mobile/lib/models/typedefs.dart
index d358180da7..284d3a2445 100644
--- a/mobile/lib/models/typedefs.dart
+++ b/mobile/lib/models/typedefs.dart
@@ -18,3 +18,4 @@ typedef VoidCallbackParamSearchResutlsStream = void Function(
typedef FutureVoidCallback = Future<void> Function();
typedef FutureOrVoidCallback = FutureOr<void> Function();
typedef FutureVoidCallbackParamStr = Future<void> Function(String);
+typedef FutureVoidCallbackParamBool = Future<void> Function(bool);
diff --git a/mobile/lib/ui/sharing/manage_links_widget.dart b/mobile/lib/ui/sharing/manage_links_widget.dart
index 02878735e2..3478d1864f 100644
--- a/mobile/lib/ui/sharing/manage_links_widget.dart
+++ b/mobile/lib/ui/sharing/manage_links_widget.dart
@@ -15,6 +15,7 @@ import 'package:photos/ui/components/captioned_text_widget.dart';
import 'package:photos/ui/components/divider_widget.dart';
import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
import 'package:photos/ui/components/menu_section_description_widget.dart';
+import "package:photos/ui/components/toggle_switch_widget.dart";
import 'package:photos/ui/sharing/pickers/device_limit_picker_page.dart';
import 'package:photos/ui/sharing/pickers/link_expiry_picker_page.dart';
import 'package:photos/utils/crypto_util.dart';
@@ -78,14 +79,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
),
alignCaptionedTextToLeft: true,
menuItemColor: getEnteColorScheme(context).fillFaint,
- trailingWidget: Switch.adaptive(
- value: widget.collection!.publicURLs?.firstOrNull
- ?.enableCollect ??
- false,
- onChanged: (value) async {
+ trailingWidget: ToggleSwitchWidget(
+ value: () => isCollectEnabled,
+ onChanged: () async {
await _updateUrlSettings(
context,
- {'enableCollect': value},
+ {'enableCollect': !isCollectEnabled},
);
},
),
@@ -168,14 +167,14 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
isBottomBorderRadiusRemoved: true,
isTopBorderRadiusRemoved: true,
menuItemColor: getEnteColorScheme(context).fillFaint,
- trailingWidget: Switch.adaptive(
- value: isDownloadEnabled,
- onChanged: (value) async {
+ trailingWidget: ToggleSwitchWidget(
+ value: () => isDownloadEnabled,
+ onChanged: () async {
await _updateUrlSettings(
context,
- {'enableDownload': value},
+ {'enableDownload': !isDownloadEnabled},
);
- if (!value) {
+ if (!isDownloadEnabled) {
// ignore: unawaited_futures
showErrorDialog(
context,
@@ -198,10 +197,10 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
alignCaptionedTextToLeft: true,
isTopBorderRadiusRemoved: true,
menuItemColor: getEnteColorScheme(context).fillFaint,
- trailingWidget: Switch.adaptive(
- value: isPasswordEnabled,
- onChanged: (enablePassword) async {
- if (enablePassword) {
+ trailingWidget: ToggleSwitchWidget(
+ value: () => isPasswordEnabled,
+ onChanged: () async {
+ if (!isPasswordEnabled) {
// ignore: unawaited_futures
showTextInputDialog(
context,