[mob] UX change

This commit is contained in:
Neeraj Gupta
2024-08-20 11:48:01 +05:30
parent 359af7e2eb
commit 8b62c18171
4 changed files with 79 additions and 17 deletions

View File

@@ -949,6 +949,8 @@ class MessageLookup extends MessageLookupByLibrary {
"machineLearning":
MessageLookupByLibrary.simpleMessage("Machine learning"),
"magicSearch": MessageLookupByLibrary.simpleMessage("Magic search"),
"magicSearchHint": MessageLookupByLibrary.simpleMessage(
"Magic search allows to search photos by their contents, e.g. \'flower\', \'red car\', \'identify documents\'"),
"manage": MessageLookupByLibrary.simpleMessage("Manage"),
"manageDeviceStorage":
MessageLookupByLibrary.simpleMessage("Manage device storage"),
@@ -975,8 +977,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Please click here for more details about this feature in our privacy policy"),
"mlConsentTitle":
MessageLookupByLibrary.simpleMessage("Enable machine learning?"),
"mlIndexing":
MessageLookupByLibrary.simpleMessage("Enable ML indexing"),
"mlIndexing": MessageLookupByLibrary.simpleMessage("Enable Indexing"),
"mlIndexingDescription": MessageLookupByLibrary.simpleMessage(
"Please note that machine learning will result in a higher bandwidth and battery usage until all items are indexed."),
"mobileWebDesktop":

View File

@@ -9025,10 +9025,10 @@ class S {
);
}
/// `Enable ML indexing`
/// `Enable Indexing`
String get mlIndexing {
return Intl.message(
'Enable ML indexing',
'Enable Indexing',
name: 'mlIndexing',
desc: '',
args: [],
@@ -9055,6 +9055,16 @@ class S {
);
}
/// `Magic search allows to search photos by their contents, e.g. 'flower', 'red car', 'identify documents'`
String get magicSearchHint {
return Intl.message(
'Magic search allows to search photos by their contents, e.g. \'flower\', \'red car\', \'identify documents\'',
name: 'magicSearchHint',
desc: '',
args: [],
);
}
/// `Panorama`
String get panorama {
return Intl.message(

View File

@@ -1269,7 +1269,7 @@
}
}
},
"mlIndexing": "Enable ML indexing",
"mlIndexing": "Enable Indexing",
"moreDetails" : "More details",
"enableMLIndexingDesc": "Ente supports on-device machine learning for face recognition, magic search and other advanced search features",
"magicSearchHint": "Magic search allows to search photos by their contents, e.g. 'flower', 'red car', 'identify documents'",

View File

@@ -3,6 +3,7 @@ import "dart:async";
import "package:flutter/material.dart";
import "package:intl/intl.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/machine_learning/machine_learning_controller.dart";
import "package:photos/services/machine_learning/ml_service.dart";
@@ -13,11 +14,14 @@ import "package:photos/services/remote_assets_service.dart";
import "package:photos/services/user_remote_flag_service.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/common/web_page.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/captioned_text_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/menu_section_title.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/components/title_bar_widget.dart";
import "package:photos/ui/components/toggle_switch_widget.dart";
@@ -62,6 +66,7 @@ class _MachineLearningSettingsPageState
@override
Widget build(BuildContext context) {
final hasEnabled = localSettings.isFaceIndexingEnabled;
return Scaffold(
body: CustomScrollView(
primary: false,
@@ -86,12 +91,16 @@ class _MachineLearningSettingsPageState
delegate: SliverChildBuilderDelegate(
(delegateBuildContext, index) => Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Text(
S.of(context).mlIndexingDescription,
textAlign: TextAlign.left,
style: getEnteTextTheme(context)
.mini
.copyWith(color: getEnteColorScheme(context).textMuted),
child: Column(
children: [
Text(
S.of(context).mlIndexingDescription,
textAlign: TextAlign.left,
style: getEnteTextTheme(context).mini.copyWith(
color: getEnteColorScheme(context).textMuted,
),
),
],
),
),
childCount: 1,
@@ -103,7 +112,7 @@ class _MachineLearningSettingsPageState
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
padding: const EdgeInsets.only(top: 20),
child: _getMlSettings(context),
),
);
@@ -111,6 +120,45 @@ class _MachineLearningSettingsPageState
childCount: 1,
),
),
if (!hasEnabled)
SliverList(
delegate: SliverChildBuilderDelegate(
(delegateBuildContext, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: context.l10n.moreDetails,
onTap: () async {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
return WebPage(
S.of(context).help,
"https://help.ente.io/photos/features/machine-learning",
);
},
),
).ignore();
},
),
const SizedBox(height: 12),
Text(
S.of(context).magicSearchHint,
textAlign: TextAlign.left,
style: getEnteTextTheme(context).mini.copyWith(
color: getEnteColorScheme(context).textMuted,
),
),
],
),
);
},
childCount: 1,
),
),
],
),
);
@@ -123,15 +171,15 @@ class _MachineLearningSettingsPageState
children: [
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).mlFunctions,
title: S.of(context).mlIndexing,
),
menuItemColor: colorScheme.fillFaint,
trailingWidget: ToggleSwitchWidget(
value: () => localSettings.isFaceIndexingEnabled,
onChanged: () async {
if (!localSettings.isFaceIndexingEnabled &&
!UserRemoteFlagService.instance
.getCachedBoolValue(UserRemoteFlagService.mlEnabled)) {
final hasGivenConsent = UserRemoteFlagService.instance
.getCachedBoolValue(UserRemoteFlagService.mlEnabled);
if (!localSettings.isFaceIndexingEnabled && !hasGivenConsent) {
final result = await Navigator.push(
context,
MaterialPageRoute(
@@ -149,7 +197,10 @@ class _MachineLearningSettingsPageState
await MLService.instance.init(firstTime: true);
await SemanticSearchService.instance.init();
unawaited(MLService.instance.runAllML(force: true));
} else {}
} else {
await UserRemoteFlagService.instance
.setBoolValue(UserRemoteFlagService.mlEnabled, false);
}
if (mounted) {
setState(() {});
}