Compare commits

..

7 Commits

Author SHA1 Message Date
Prateek Sunal
29c67bd5dd fix: refactor Theme.of(context) to a variable 2025-08-22 02:27:35 +05:30
Prateek Sunal
da15842597 fix: deprecated normal functions for getting theme 2025-08-22 02:27:00 +05:30
Prateek Sunal
eb959046cd fix: all theme undefined errors 2025-08-22 01:27:16 +05:30
Prateek Sunal
1178ae26d0 fix: get things back 2025-08-21 23:54:47 +05:30
Prateek Sunal
4a2f5b4676 Merge remote-tracking branch 'origin/main' into optimize-widget-dependencies 2025-08-21 23:49:48 +05:30
Prateek Sunal
0fece5666b feat: optimize ente color scheme and text theme 2025-08-21 19:04:56 +05:30
Prateek Sunal
26e564aec2 fix: optimize theme dependencies for many files 2025-08-21 18:50:44 +05:30
310 changed files with 5000 additions and 5045 deletions

View File

@@ -8,7 +8,7 @@ on:
env:
FLUTTER_VERSION: "3.32.8"
RUST_VERSION: "1.86.0"
RUST_VERSION: "1.85.1"
permissions:
contents: read
@@ -47,9 +47,6 @@ jobs:
- name: Install Flutter Rust Bridge
run: cargo install flutter_rust_bridge_codegen
- name: Generate Rust bindings
run: flutter_rust_bridge_codegen generate
- name: Increment version code for build
run: |
CURRENT_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')

View File

@@ -47,8 +47,4 @@ android/app/build/
# FVM Version Cache
.fvm/
lib/generated/intl/app_localizations*.dart
# Generated rust bindings
lib/src/rust/*
rust/src/frb_generated*
lib/generated/intl/app_localizations*.dart

View File

@@ -48,7 +48,7 @@ You can alternatively install the build from PlayStore or F-Droid.
1. Install [Flutter v3.32.8](https://flutter.dev/docs/get-started/install) and [Rust](https://www.rust-lang.org/tools/install).
2. Install [Flutter Rust Bridge](https://cjycode.com/flutter_rust_bridge/) with `cargo install flutter_rust_bridge_codegen` and run `flutter_rust_bridge_codegen generate` to generate the Rust bindings.
2. Install [Flutter Rust Bridge](https://cjycode.com/flutter_rust_bridge/) with `cargo install flutter_rust_bridge_codegen`
3. Pull in all submodules with `git submodule update --init --recursive`

View File

@@ -73,5 +73,3 @@ analyzer:
- thirdparty/**
- lib/generated/**
- rust_builder/**
- lib/src/rust/**
- rust/src/**

File diff suppressed because it is too large Load Diff

View File

@@ -3,4 +3,3 @@ output-dir: lib/generated/intl
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false
use-named-parameters: true

View File

@@ -76,7 +76,8 @@ class _EmergencyPageState extends State<EmergencyPage> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final currentUserID = Configuration.instance.getUserID()!;
final List<EmergencyContact> othersTrustedContacts =
info?.othersEmergencyContact ?? [];
@@ -180,7 +181,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
currentUserID: currentUserID,
),
menuItemColor:
getEnteColorScheme(context).fillFaint,
EnteTheme.getColorScheme(theme).fillFaint,
trailingIcon: Icons.chevron_right,
trailingIconIsMuted: true,
onTap: () async {
@@ -192,7 +193,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
),
DividerWidget(
dividerType: DividerType.menu,
bgColor: getEnteColorScheme(context).fillFaint,
bgColor: EnteTheme.getColorScheme(theme).fillFaint,
),
],
);
@@ -203,13 +204,13 @@ class _EmergencyPageState extends State<EmergencyPage> {
const SizedBox(height: 20),
Text(
context.l10n.legacyPageDesc,
style: getEnteTextTheme(context).body,
style: EnteTheme.getTextTheme(theme).body,
),
SizedBox(
height: 200,
width: 200,
child: SvgPicture.asset(
getEnteColorScheme(context).backdropBase ==
EnteTheme.getColorScheme(theme).backdropBase ==
backgroundBaseDark
? "assets/icons/legacy-light.svg"
: "assets/icons/legacy-dark.svg",
@@ -219,7 +220,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
),
Text(
context.l10n.legacyPageDesc2,
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
),
const SizedBox(height: 16),
ButtonWidget(
@@ -248,7 +249,8 @@ class _EmergencyPageState extends State<EmergencyPage> {
),
leadingIcon: Icons.add_outlined,
surfaceExecutionStates: false,
menuItemColor: getEnteColorScheme(context).fillFaint,
menuItemColor:
EnteTheme.getColorScheme(theme).fillFaint,
onTap: () async {
await routeToPage(
context,
@@ -308,7 +310,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
currentUserID: currentUserID,
),
menuItemColor:
getEnteColorScheme(context).fillFaint,
EnteTheme.getColorScheme(theme).fillFaint,
trailingIcon: Icons.chevron_right,
trailingIconIsMuted: true,
onTap: () async {
@@ -351,7 +353,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
: DividerWidget(
dividerType: DividerType.menu,
bgColor:
getEnteColorScheme(context).fillFaint,
EnteTheme.getColorScheme(theme).fillFaint,
),
],
);
@@ -497,8 +499,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
isInAlert: true,
),
],
body:
AppLocalizations.of(context).legacyInvite(email: contact.user.email),
body: AppLocalizations.of(context).legacyInvite(contact.user.email),
actionSheetType: ActionSheetType.defaultActionSheet,
);
return;
@@ -551,7 +552,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
isInAlert: true,
),
],
body: context.l10n.recoveryWarningBody(email: emergencyContactEmail),
body: context.l10n.recoveryWarningBody(emergencyContactEmail),
actionSheetType: ActionSheetType.defaultActionSheet,
);
return;

View File

@@ -79,8 +79,9 @@ class _OtherContactPageState extends State<OtherContactPage> {
);
waitTill = getFormattedTime(context, dateTime);
}
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
return Scaffold(
appBar: AppBar(),
body: Padding(
@@ -117,7 +118,7 @@ class _OtherContactPageState extends State<OtherContactPage> {
)
: (recoverySession!.status == "READY"
? Text(
context.l10n.recoveryReady(email: accountEmail),
context.l10n.recoveryReady(accountEmail),
style: textTheme.body,
)
: Text(
@@ -155,8 +156,8 @@ class _OtherContactPageState extends State<OtherContactPage> {
context,
context.l10n.recoveryInitiated,
context.l10n.recoveryInitiatedDesc(
days: widget.contact.recoveryNoticeInDays,
email: Configuration.instance.getEmail()!,
widget.contact.recoveryNoticeInDays,
Configuration.instance.getEmail()!,
),
);
}
@@ -229,7 +230,7 @@ class _OtherContactPageState extends State<OtherContactPage> {
),
leadingIcon: Icons.not_interested_outlined,
leadingIconColor: warning500,
menuItemColor: getEnteColorScheme(context).fillFaint,
menuItemColor: EnteTheme.getColorScheme(theme).fillFaint,
surfaceExecutionStates: false,
onTap: () async {
await showRemoveSheet();

View File

@@ -80,12 +80,13 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
String title = AppLocalizations.of(context).setPasswordTitle;
title = AppLocalizations.of(context).resetPasswordTitle;
final theme = Theme.of(context);
return Scaffold(
resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -118,6 +119,7 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
passwordStrengthText = AppLocalizations.of(context).moderateStrength;
passwordStrengthColor = Colors.orangeAccent;
}
final theme = Theme.of(context);
return Column(
children: [
Expanded(
@@ -129,7 +131,7 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
buttonTextAndHeading,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -138,10 +140,7 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
"Enter new password for $email account. You will be able "
"to use this password to login into $email account.",
textAlign: TextAlign.start,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 14),
style: theme.textTheme.titleMedium!.copyWith(fontSize: 14),
),
),
const Padding(padding: EdgeInsets.all(12)),
@@ -179,7 +178,7 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
_password1Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -191,11 +190,8 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
: _isPasswordValid
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
),
@@ -241,7 +237,7 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
_password2Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -253,11 +249,8 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
: _passwordsMatch
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
border: UnderlineInputBorder(
@@ -284,9 +277,8 @@ class _RecoverOthersAccountState extends State<RecoverOthersAccount> {
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
child: Text(
AppLocalizations.of(context).passwordStrength(
passwordStrengthValue: passwordStrengthText,
),
AppLocalizations.of(context)
.passwordStrength(passwordStrengthText),
style: TextStyle(
color: passwordStrengthColor,
),

View File

@@ -58,8 +58,9 @@ class _AddContactPage extends State<AddContactPage> {
@override
Widget build(BuildContext context) {
isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final enteTextTheme = getEnteTextTheme(context);
final enteColorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final enteTextTheme = EnteTheme.getTextTheme(theme);
final enteColorScheme = EnteTheme.getColorScheme(theme);
final List<User> suggestedUsers = _getSuggestedUser();
isEmailListEmpty = suggestedUsers.isEmpty;
return Scaffold(
@@ -85,7 +86,7 @@ class _AddContactPage extends State<AddContactPage> {
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: _getEmailField(),
child: _getEmailField(theme),
),
if (isEmailListEmpty)
const Expanded(child: SizedBox.shrink())
@@ -128,9 +129,9 @@ class _AddContactPage extends State<AddContactPage> {
type: AvatarType.mini,
),
menuItemColor:
getEnteColorScheme(context).fillFaint,
EnteTheme.getColorScheme(theme).fillFaint,
pressedColor:
getEnteColorScheme(context).fillFaint,
EnteTheme.getColorScheme(theme).fillFaint,
trailingIcon:
(selectedEmail == currentUser.email)
? Icons.check
@@ -152,8 +153,8 @@ class _AddContactPage extends State<AddContactPage> {
? const SizedBox.shrink()
: DividerWidget(
dividerType: DividerType.menu,
bgColor:
getEnteColorScheme(context).fillFaint,
bgColor: EnteTheme.getColorScheme(theme)
.fillFaint,
),
],
);
@@ -193,8 +194,8 @@ class _AddContactPage extends State<AddContactPage> {
title: AppLocalizations.of(context).warning,
body: AppLocalizations.of(context)
.confirmAddingTrustedContact(
email: emailToAdd,
numOfDays: 30,
emailToAdd,
30,
),
firstButtonLabel:
AppLocalizations.of(context).proceed,
@@ -269,19 +270,19 @@ class _AddContactPage extends State<AddContactPage> {
setState(() => {});
}
Widget _getEmailField() {
Widget _getEmailField(ThemeData theme) {
return TextFormField(
controller: _textController,
focusNode: textFieldFocusNode,
style: getEnteTextTheme(context).body,
style: EnteTheme.getTextTheme(theme).body,
autofillHints: const [AutofillHints.email],
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
borderSide:
BorderSide(color: getEnteColorScheme(context).strokeMuted),
BorderSide(color: EnteTheme.getColorScheme(theme).strokeMuted),
),
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).enterEmail,
contentPadding: const EdgeInsets.symmetric(
@@ -294,7 +295,7 @@ class _AddContactPage extends State<AddContactPage> {
),
prefixIcon: Icon(
Icons.email_outlined,
color: getEnteColorScheme(context).strokeMuted,
color: EnteTheme.getColorScheme(theme).strokeMuted,
),
suffixIcon: _email == ''
? null
@@ -302,7 +303,7 @@ class _AddContactPage extends State<AddContactPage> {
onPressed: clearFocus,
icon: Icon(
Icons.cancel,
color: getEnteColorScheme(context).strokeMuted,
color: EnteTheme.getColorScheme(theme).strokeMuted,
),
),
),

View File

@@ -22,6 +22,6 @@ class FillerMemory extends SmartMemory {
@override
String createTitle(AppLocalizations locals, String languageCode) {
return locals.yearsAgo(count: yearsAgo);
return locals.yearsAgo(yearsAgo);
}
}

View File

@@ -75,25 +75,25 @@ String activityTitle(
) {
switch (activity) {
case PeopleActivity.admiring:
return locals.admiringThem(name: personName);
return locals.admiringThem(personName);
case PeopleActivity.embracing:
return locals.embracingThem(name: personName);
return locals.embracingThem(personName);
case PeopleActivity.party:
return locals.partyWithThem(name: personName);
return locals.partyWithThem(personName);
case PeopleActivity.hiking:
return locals.hikingWithThem(name: personName);
return locals.hikingWithThem(personName);
case PeopleActivity.feast:
return locals.feastingWithThem(name: personName);
return locals.feastingWithThem(personName);
case PeopleActivity.selfies:
return locals.selfiesWithThem(name: personName);
return locals.selfiesWithThem(personName);
case PeopleActivity.posing:
return locals.posingWithThem(name: personName);
return locals.posingWithThem(personName);
case PeopleActivity.background:
return locals.backgroundWithThem(name: personName);
return locals.backgroundWithThem(personName);
case PeopleActivity.sports:
return locals.sportsWithThem(name: personName);
return locals.sportsWithThem(personName);
case PeopleActivity.roadtrip:
return locals.roadtripWithThem(name: personName);
return locals.roadtripWithThem(personName);
}
}
@@ -154,7 +154,7 @@ class PeopleMemory extends SmartMemory {
switch (peopleMemoryType) {
case PeopleMemoryType.youAndThem:
assert(personName != null);
return locals.youAndThem(name: personName!);
return locals.youAndThem(personName!);
case PeopleMemoryType.doingSomethingTogether:
assert(activity != null);
assert(personName != null);
@@ -163,16 +163,16 @@ class PeopleMemory extends SmartMemory {
if (personName == null) {
return locals.spotlightOnYourself;
} else if (newAge == null) {
return locals.spotlightOnThem(name: personName!);
return locals.spotlightOnThem(personName!);
} else {
if (isBirthday!) {
return locals.personIsAge(name: personName!, age: newAge!);
return locals.personIsAge(personName!, newAge!);
} else {
return locals.personTurningAge(name: personName!, age: newAge!);
return locals.personTurningAge(personName!, newAge!);
}
}
case PeopleMemoryType.lastTimeYouSawThem:
return locals.lastTimeWithThem(name: personName!);
return locals.lastTimeWithThem(personName!);
}
}
}

View File

@@ -31,21 +31,21 @@ class TimeMemory extends SmartMemory {
if (day != null) {
final dayFormat = DateFormat.MMMd(languageCode).format(day!);
if (yearsAgo != null) {
return "$dayFormat, " + locals.yearsAgo(count: yearsAgo!);
return "$dayFormat, " + locals.yearsAgo(yearsAgo!);
} else {
return locals.throughTheYears(dateFormat: dayFormat);
return locals.throughTheYears(dayFormat);
}
}
if (month != null) {
final monthFormat = DateFormat.MMMM(languageCode).format(month!);
if (yearsAgo != null) {
return "$monthFormat, " + locals.yearsAgo(count: yearsAgo!);
return "$monthFormat, " + locals.yearsAgo(yearsAgo!);
} else {
return locals.throughTheYears(dateFormat: monthFormat);
return locals.throughTheYears(monthFormat);
}
}
if (yearsAgo != null) {
return locals.thisWeekXYearsAgo(count: yearsAgo!);
return locals.thisWeekXYearsAgo(yearsAgo!);
} else {
return locals.thisWeekThroughTheYears;
}

View File

@@ -51,13 +51,13 @@ class TripMemory extends SmartMemory {
assert(locationName != null || tripYear != null);
if (locationName != null) {
if (locationName!.toLowerCase().contains("base")) return locationName!;
return locals.tripToLocation(location: locationName!);
return locals.tripToLocation(locationName!);
}
if (tripYear != null) {
if (tripYear == DateTime.now().year - 1) {
return locals.lastYearsTrip;
} else {
return locals.tripInYear(year: tripYear!);
return locals.tripInYear(tripYear!);
}
}
throw ArgumentError("TripMemory must have a location name or trip year");

View File

@@ -1,3 +1,4 @@
// https://discover.ente.io/v1.json
class Prompt {
final String id;
final int position;
@@ -8,17 +9,6 @@ class Prompt {
final bool showVideo;
final bool recentFirst;
Prompt({
String? id,
this.position = 0,
required this.query,
required this.minScore,
required this.minSize,
required this.title,
this.showVideo = true,
this.recentFirst = false,
}) : id = id ?? title;
// fromJson
Prompt.fromJson(Map<String, dynamic> json)
: id = json['id'] ?? json['title'],

View File

@@ -527,7 +527,7 @@ class UserService {
if (response.statusCode == 200) {
showShortToast(
context,
AppLocalizations.of(context).emailChangedTo(newEmail: email),
AppLocalizations.of(context).emailChangedTo(email),
);
await setEmail(email);
Navigator.of(context).popUntil((route) => route.isFirst);

View File

@@ -193,13 +193,22 @@ class SemanticSearchService {
return results;
}
Future<Map<String, List<int>>> getMatchingFileIDsWithEmbeddings(
Map<String, List<double>> queryToEmbedding,
Future<Map<String, List<int>>> getMatchingFileIDs(
Map<String, double> queryToScore,
) async {
final textEmbeddings = <String, List<double>>{};
final minimumSimilarityMap = <String, double>{};
for (final entry in queryToScore.entries) {
final query = entry.key;
final score = entry.value;
final textEmbedding = await _getTextEmbedding(query);
textEmbeddings[query] = textEmbedding;
minimumSimilarityMap[query] = score;
}
final queryResults = await _getSimilarities(
queryToEmbedding,
minimumSimilarityMap: queryToScore,
textEmbeddings,
minimumSimilarityMap: minimumSimilarityMap,
);
final result = <String, List<int>>{};
for (final entry in queryResults.entries) {

View File

@@ -2,6 +2,7 @@ import "dart:async";
import "dart:convert";
import "dart:io";
import "package:computer/computer.dart";
import "package:flutter/foundation.dart";
import "package:flutter/widgets.dart";
import "package:logging/logging.dart";
@@ -20,12 +21,12 @@ import "package:photos/models/search/hierarchical/magic_filter.dart";
import "package:photos/models/search/search_types.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/machine_learning/semantic_search/semantic_search_service.dart";
import "package:photos/services/remote_assets_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/ui/viewer/search/result/magic_result_screen.dart";
import "package:photos/utils/cache_util.dart";
import "package:photos/utils/file_util.dart";
import "package:photos/utils/navigation_util.dart";
import "package:photos/utils/text_embeddings_util.dart";
import "package:shared_preferences/shared_preferences.dart";
class MagicCache {
@@ -118,13 +119,8 @@ GenericSearchResult? toGenericSearchResult(
}
if (!prompt.recentFirst) {
enteFilesInMagicCache.sort((a, b) {
final aID = a.uploadedFileID;
final bID = b.uploadedFileID;
if (aID == null || bID == null) return 0;
final aPos = fileIdToPositionMap[aID];
final bPos = fileIdToPositionMap[bID];
if (aPos == null || bPos == null) return 0;
return aPos.compareTo(bPos);
return fileIdToPositionMap[a.uploadedFileID!]!
.compareTo(fileIdToPositionMap[b.uploadedFileID!]!);
});
}
final String title = getLocalizedTitle(context, prompt.title);
@@ -172,6 +168,7 @@ GenericSearchResult? toGenericSearchResult(
class MagicCacheService {
static const _lastMagicCacheUpdateTime = "last_magic_cache_update_time";
static const _kMagicPromptsDataUrl = "https://discover.ente.io/v2.json";
/// Delay is for cache update to be done not during app init, during which a
/// lot of other things are happening.
@@ -181,6 +178,7 @@ class MagicCacheService {
late final Logger _logger = Logger((MagicCacheService).toString());
Future<List<MagicCache>>? _magicCacheFuture;
Future<List<Prompt>>? _promptFuture;
final Set<String> _pendingUpdateReason = {};
bool _isUpdateInProgress = false;
@@ -215,7 +213,11 @@ class MagicCacheService {
if (!enableDiscover) {
return;
}
if (lastMagicCacheUpdateTime <
final updatedJSONFile = await RemoteAssetsService.instance
.getAssetIfUpdated(_kMagicPromptsDataUrl);
if (updatedJSONFile != null) {
queueUpdate("Prompts data updated");
} else if (lastMagicCacheUpdateTime <
DateTime.now()
.subtract(const Duration(hours: 12))
.millisecondsSinceEpoch) {
@@ -245,7 +247,10 @@ class MagicCacheService {
_isUpdateInProgress = true;
final EnteWatch? w = kDebugMode ? EnteWatch("magicCacheWatch") : null;
w?.start();
final List<MagicCache> magicCaches = await _nonEmptyMagicResults();
final magicPromptsData = await getPrompts();
w?.log("loadedPrompts");
final List<MagicCache> magicCaches =
await _nonEmptyMagicResults(magicPromptsData);
w?.log("resultComputed");
_magicCacheFuture = Future.value(magicCaches);
await writeToJsonFile<List<MagicCache>>(
@@ -257,6 +262,7 @@ class MagicCacheService {
await _resetLastMagicCacheUpdateTime();
w?.logAndReset('done');
_pendingUpdateReason.clear();
Bus.instance.fire(MagicCacheUpdatedEvent());
} catch (e, s) {
_logger.info("Error updating magic cache", e, s);
} finally {
@@ -265,6 +271,14 @@ class MagicCacheService {
}
}
Future<List<Prompt>> getPrompts() async {
if (_promptFuture != null) {
return _promptFuture!;
}
_promptFuture = _readPromptFromDiskOrNetwork();
return _promptFuture!;
}
Future<List<MagicCache>> getMagicCache() async {
if (_magicCacheFuture != null) {
return _magicCacheFuture!;
@@ -273,6 +287,17 @@ class MagicCacheService {
return _magicCacheFuture!;
}
Future<List<Prompt>> _readPromptFromDiskOrNetwork() async {
final String path =
await RemoteAssetsService.instance.getAssetPath(_kMagicPromptsDataUrl);
return Computer.shared().compute(
_loadMagicPrompts,
param: <String, dynamic>{
"path": path,
},
);
}
Future<List<MagicCache>> _readResultFromDisk() async {
_logger.info("Reading magic cache result from disk");
final cache = await decodeJsonFile<List<MagicCache>>(
@@ -287,7 +312,6 @@ class MagicCacheService {
if (file.existsSync()) {
await file.delete();
}
_magicCacheFuture = null;
}
Future<List<GenericSearchResult>> getMagicGenericSearchResult(
@@ -298,30 +322,7 @@ class MagicCacheService {
kDebugMode ? EnteWatch("magicGenericSearchResult") : null;
w?.start();
final magicCaches = await getMagicCache();
// Load discover embeddings to get prompts
final discoverEmbeddings = await loadDiscoverEmbeddings();
if (discoverEmbeddings == null) {
_logger.severe("No discover embeddings available in assets");
throw Exception("No discover embeddings available in assets");
}
final prompts = <Prompt>[];
for (final entry in discoverEmbeddings.queryToPromptData.entries) {
final query = entry.key;
final promptData = entry.value;
prompts.add(
Prompt(
query: query,
title: promptData.title,
minScore: promptData.minScore,
minSize: promptData.minSize,
showVideo: promptData.showVideo ?? true,
recentFirst: promptData.recentFirst ?? false,
),
);
}
final List<Prompt> prompts = await getPrompts();
if (magicCaches.isEmpty) {
w?.log("No magic cache found");
return [];
@@ -374,53 +375,35 @@ class MagicCacheService {
}
}
Future<List<MagicCache>> _nonEmptyMagicResults() async {
static Future<List<Prompt>> _loadMagicPrompts(
Map<String, dynamic> args,
) async {
final String path = args["path"] as String;
final File file = File(path);
final String contents = await file.readAsString();
final Map<String, dynamic> promptsJson = jsonDecode(contents);
final List<dynamic> promptData = promptsJson['prompts'];
return promptData
.map<Prompt>((jsonItem) => Prompt.fromJson(jsonItem))
.toList();
}
///Returns non-empty magic results from magicPromptsData
///Length is number of prompts, can be less if there are not enough non-empty
///results
Future<List<MagicCache>> _nonEmptyMagicResults(
List<Prompt> magicPromptsData,
) async {
final TimeLogger t = TimeLogger();
final results = <MagicCache>[];
final List<int> matchCount = [];
// Uncomment this code to generate embeddings and save them to a JSON file
// await generateAndSaveDiscoverEmbeddings();
// (from package:photos/utils/text_embeddings_util.dart)
// Load pre-computed discover embeddings from assets
final discoverEmbeddings = await loadDiscoverEmbeddings();
if (discoverEmbeddings == null) {
_logger.severe('Failed to load discover embeddings');
throw Exception('Failed to load discover embeddings');
}
// Build the embeddings and score maps
final Map<String, List<double>> queryToEmbedding = {};
final Map<String, double> queryToScore = {};
final List<Prompt> prompts = [];
for (final entry in discoverEmbeddings.queryToPromptData.entries) {
final query = entry.key;
final promptData = entry.value;
final vector = discoverEmbeddings.queryToVector[query];
if (vector != null) {
queryToEmbedding[query] = vector.toList();
queryToScore[query] = promptData.minScore;
prompts.add(
Prompt(
query: query,
title: promptData.title,
minScore: promptData.minScore,
minSize: promptData.minSize,
showVideo: promptData.showVideo ?? true,
recentFirst: promptData.recentFirst ?? false,
),
);
}
for (Prompt prompt in magicPromptsData) {
queryToScore[prompt.query] = prompt.minScore;
}
_logger.info('Using pre-computed discover embeddings from assets');
final clipResults = await SemanticSearchService.instance
.getMatchingFileIDsWithEmbeddings(queryToEmbedding, queryToScore);
for (final prompt in prompts) {
final clipResults =
await SemanticSearchService.instance.getMatchingFileIDs(queryToScore);
for (Prompt prompt in magicPromptsData) {
final List<int> fileUploadedIDs = clipResults[prompt.query] ?? [];
if (fileUploadedIDs.isNotEmpty) {
results.add(

View File

@@ -764,7 +764,7 @@ class MemoriesCacheService {
final s = await LanguageService.locals;
await NotificationService.instance.scheduleNotification(
memory.personName != null
? s.wishThemAHappyBirthday(name: memory.personName!)
? s.wishThemAHappyBirthday(memory.personName!)
: s.happyBirthday,
id: memory.id.hashCode,
channelID: "birthday",

View File

@@ -104,7 +104,7 @@ class SmartMemoriesService {
);
// Load pre-computed text embeddings from assets
final textEmbeddings = await loadMemoriesEmbeddings();
final textEmbeddings = await loadTextEmbeddingsFromAssets();
if (textEmbeddings == null) {
_logger.severe('Failed to load pre-computed text embeddings');
throw Exception(

View File

@@ -0,0 +1,12 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.11.1.
// ignore_for_file: require_trailing_commas
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:photos/src/rust/frb_generated.dart';
String greet({required String name}) =>
RustLib.instance.api.crateApiSimpleGreet(name: name);

View File

@@ -0,0 +1,57 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.11.1.
// ignore_for_file: require_trailing_commas
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:photos/src/rust/frb_generated.dart';
// These functions are ignored because they are not marked as `pub`: `ensure_capacity`, `save_index`
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<VectorDB>>
abstract class VectorDb implements RustOpaqueInterface {
Future<void> addVector({required BigInt key, required List<double> vector});
Future<void> bulkAddVectors(
{required Uint64List keys, required List<Float32List> vectors});
Future<List<Float32List>> bulkGetVectors({required Uint64List keys});
Future<BigInt> bulkRemoveVectors({required Uint64List keys});
Future<(Uint64List, List<Uint64List>, List<Float32List>)> bulkSearchKeys(
{required Uint64List potentialKeys,
required BigInt count,
required bool exact});
Future<(List<Uint64List>, List<Float32List>)> bulkSearchVectors(
{required List<Float32List> queries,
required BigInt count,
required bool exact});
/// Check if a vector with the given key exists in the index.
/// `true` if the index contains the vector with the given key, `false` otherwise.
Future<bool> containsVector({required BigInt key});
Future<void> deleteIndex();
Future<(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)>
getIndexStats();
Future<Float32List> getVector({required BigInt key});
factory VectorDb({required String filePath, required BigInt dimensions}) =>
RustLib.instance.api.crateApiUsearchApiVectorDbNew(
filePath: filePath, dimensions: dimensions);
Future<BigInt> removeVector({required BigInt key});
Future<void> resetIndex();
Future<(Uint64List, Float32List)> searchVectors(
{required List<double> query,
required BigInt count,
required bool exact});
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,315 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.11.1.
// ignore_for_file: require_trailing_commas
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
import 'dart:async';
import 'dart:convert';
import 'dart:ffi' as ffi;
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart';
import 'package:photos/src/rust/api/simple.dart';
import 'package:photos/src/rust/api/usearch_api.dart';
import 'package:photos/src/rust/frb_generated.dart';
abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
RustLibApiImplPlatform({
required super.handler,
required super.wire,
required super.generalizedFrbRustBinding,
required super.portManager,
});
CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_VectorDbPtr => wire
._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDBPtr;
@protected
VectorDb
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
dynamic raw);
@protected
VectorDb
dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
dynamic raw);
@protected
VectorDb
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
dynamic raw);
@protected
String dco_decode_String(dynamic raw);
@protected
bool dco_decode_bool(dynamic raw);
@protected
double dco_decode_f_32(dynamic raw);
@protected
List<Float32List> dco_decode_list_list_prim_f_32_strict(dynamic raw);
@protected
List<Uint64List> dco_decode_list_list_prim_u_64_strict(dynamic raw);
@protected
List<double> dco_decode_list_prim_f_32_loose(dynamic raw);
@protected
Float32List dco_decode_list_prim_f_32_strict(dynamic raw);
@protected
Uint64List dco_decode_list_prim_u_64_strict(dynamic raw);
@protected
Uint8List dco_decode_list_prim_u_8_strict(dynamic raw);
@protected
(List<Uint64List>, List<Float32List>)
dco_decode_record_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
dynamic raw);
@protected
(
Uint64List,
List<Uint64List>,
List<Float32List>
) dco_decode_record_list_prim_u_64_strict_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
dynamic raw);
@protected
(
Uint64List,
Float32List
) dco_decode_record_list_prim_u_64_strict_list_prim_f_32_strict(dynamic raw);
@protected
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
dco_decode_record_usize_usize_usize_usize_usize_usize_usize(dynamic raw);
@protected
BigInt dco_decode_u_64(dynamic raw);
@protected
int dco_decode_u_8(dynamic raw);
@protected
void dco_decode_unit(dynamic raw);
@protected
BigInt dco_decode_usize(dynamic raw);
@protected
VectorDb
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
SseDeserializer deserializer);
@protected
VectorDb
sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
SseDeserializer deserializer);
@protected
VectorDb
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
SseDeserializer deserializer);
@protected
String sse_decode_String(SseDeserializer deserializer);
@protected
bool sse_decode_bool(SseDeserializer deserializer);
@protected
double sse_decode_f_32(SseDeserializer deserializer);
@protected
List<Float32List> sse_decode_list_list_prim_f_32_strict(
SseDeserializer deserializer);
@protected
List<Uint64List> sse_decode_list_list_prim_u_64_strict(
SseDeserializer deserializer);
@protected
List<double> sse_decode_list_prim_f_32_loose(SseDeserializer deserializer);
@protected
Float32List sse_decode_list_prim_f_32_strict(SseDeserializer deserializer);
@protected
Uint64List sse_decode_list_prim_u_64_strict(SseDeserializer deserializer);
@protected
Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer);
@protected
(List<Uint64List>, List<Float32List>)
sse_decode_record_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
SseDeserializer deserializer);
@protected
(
Uint64List,
List<Uint64List>,
List<Float32List>
) sse_decode_record_list_prim_u_64_strict_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
SseDeserializer deserializer);
@protected
(Uint64List, Float32List)
sse_decode_record_list_prim_u_64_strict_list_prim_f_32_strict(
SseDeserializer deserializer);
@protected
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt)
sse_decode_record_usize_usize_usize_usize_usize_usize_usize(
SseDeserializer deserializer);
@protected
BigInt sse_decode_u_64(SseDeserializer deserializer);
@protected
int sse_decode_u_8(SseDeserializer deserializer);
@protected
void sse_decode_unit(SseDeserializer deserializer);
@protected
BigInt sse_decode_usize(SseDeserializer deserializer);
@protected
int sse_decode_i_32(SseDeserializer deserializer);
@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
VectorDb self, SseSerializer serializer);
@protected
void
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
VectorDb self, SseSerializer serializer);
@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
VectorDb self, SseSerializer serializer);
@protected
void sse_encode_String(String self, SseSerializer serializer);
@protected
void sse_encode_bool(bool self, SseSerializer serializer);
@protected
void sse_encode_f_32(double self, SseSerializer serializer);
@protected
void sse_encode_list_list_prim_f_32_strict(
List<Float32List> self, SseSerializer serializer);
@protected
void sse_encode_list_list_prim_u_64_strict(
List<Uint64List> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_f_32_loose(
List<double> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_f_32_strict(
Float32List self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_64_strict(
Uint64List self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_8_strict(
Uint8List self, SseSerializer serializer);
@protected
void sse_encode_record_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
(List<Uint64List>, List<Float32List>) self, SseSerializer serializer);
@protected
void
sse_encode_record_list_prim_u_64_strict_list_list_prim_u_64_strict_list_list_prim_f_32_strict(
(Uint64List, List<Uint64List>, List<Float32List>) self,
SseSerializer serializer);
@protected
void sse_encode_record_list_prim_u_64_strict_list_prim_f_32_strict(
(Uint64List, Float32List) self, SseSerializer serializer);
@protected
void sse_encode_record_usize_usize_usize_usize_usize_usize_usize(
(BigInt, BigInt, BigInt, BigInt, BigInt, BigInt, BigInt) self,
SseSerializer serializer);
@protected
void sse_encode_u_64(BigInt self, SseSerializer serializer);
@protected
void sse_encode_u_8(int self, SseSerializer serializer);
@protected
void sse_encode_unit(void self, SseSerializer serializer);
@protected
void sse_encode_usize(BigInt self, SseSerializer serializer);
@protected
void sse_encode_i_32(int self, SseSerializer serializer);
}
// Section: wire_class
class RustLibWire implements BaseWire {
factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) =>
RustLibWire(lib.ffiDynamicLibrary);
/// Holds the symbol lookup function.
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
_lookup;
/// The symbols are looked up in [dynamicLibrary].
RustLibWire(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;
void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
ptr,
);
}
late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDBPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_photos_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB');
late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB =
_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDBPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
void
rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB(
ptr,
);
}
late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDBPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_photos_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB');
late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDB =
_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerVectorDBPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
}

View File

@@ -19,8 +19,26 @@ class EnteTheme {
required this.shadowButton,
});
static bool isDark(BuildContext context) {
return Theme.of(context).brightness == Brightness.dark;
static bool isDark(ThemeData theme) {
return theme.brightness == Brightness.dark;
}
static EnteColorScheme getColorScheme(
ThemeData theme, {
bool inverse = false,
}) {
return inverse
? theme.colorScheme.inverseEnteTheme.colorScheme
: theme.colorScheme.enteTheme.colorScheme;
}
static EnteTextTheme getTextTheme(
ThemeData theme, {
bool inverse = false,
}) {
return inverse
? theme.colorScheme.inverseEnteTheme.textTheme
: theme.colorScheme.enteTheme.textTheme;
}
}
@@ -40,6 +58,7 @@ EnteTheme darkTheme = EnteTheme(
shadowButton: shadowButtonDark,
);
@Deprecated('Use EnteTheme.getColorScheme instead')
EnteColorScheme getEnteColorScheme(
BuildContext context, {
bool inverse = false,
@@ -49,6 +68,7 @@ EnteColorScheme getEnteColorScheme(
: Theme.of(context).colorScheme.enteTheme.colorScheme;
}
@Deprecated('Use EnteTheme.getTextTheme instead')
EnteTextTheme getEnteTextTheme(
BuildContext context, {
bool inverse = false,

View File

@@ -43,14 +43,15 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
_dropdownValue ??= _defaultSelection;
final double dropDownTextSize = MediaQuery.of(context).size.width - 120;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(AppLocalizations.of(context).deleteAccount),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -68,7 +69,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
AppLocalizations.of(context).askDeleteReason,
style: getEnteTextTheme(context).body,
style: EnteTheme.getTextTheme(theme).body,
),
),
const SizedBox(height: 8),
@@ -98,7 +99,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
width: dropDownTextSize,
child: Text(
value,
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
overflow: TextOverflow.visible,
),
),
@@ -111,12 +112,12 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
AppLocalizations.of(context).deleteAccountFeedbackPrompt,
style: getEnteTextTheme(context).body,
style: EnteTheme.getTextTheme(theme).body,
),
),
const SizedBox(height: 8),
TextFormField(
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide:
@@ -155,7 +156,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
child: Text(
AppLocalizations.of(context)
.kindlyHelpUsWithThisInformation,
style: getEnteTextTheme(context)
style: EnteTheme.getTextTheme(theme)
.smallBold
.copyWith(color: colorScheme.warning700),
),
@@ -174,7 +175,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
children: [
Checkbox(
value: _hasConfirmedDeletion,
side: CheckboxTheme.of(context).side,
side: theme.checkboxTheme.side,
onChanged: (value) {
setState(() {
_hasConfirmedDeletion = value!;
@@ -186,7 +187,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
padding: const EdgeInsets.symmetric(vertical: 12),
child: Text(
AppLocalizations.of(context).confirmDeletePrompt,
style: getEnteTextTheme(context).bodyMuted,
style: EnteTheme.getTextTheme(theme).bodyMuted,
textAlign: TextAlign.left,
),
),

View File

@@ -74,6 +74,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -87,7 +88,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -97,17 +98,16 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
child: StepProgressIndicator(
totalSteps: 4,
currentStep: 1,
selectedColor: Theme.of(context).colorScheme.greenAlternative,
selectedColor: theme.colorScheme.greenAlternative,
roundedEdges: const Radius.circular(10),
unselectedColor:
Theme.of(context).colorScheme.stepProgressUnselectedColor,
unselectedColor: theme.colorScheme.stepProgressUnselectedColor,
),
),
);
return Scaffold(
resizeToAvoidBottomInset: isKeypadOpen,
appBar: appBar,
body: _getBody(),
body: _getBody(theme),
floatingActionButton: DynamicFAB(
isKeypadOpen: isKeypadOpen,
isFormValid: _isFormValid(),
@@ -130,7 +130,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
);
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
var passwordStrengthText = AppLocalizations.of(context).weakStrength;
var passwordStrengthColor = Colors.redAccent;
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
@@ -151,18 +151,18 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
AppLocalizations.of(context).createNewAccount,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: TextFormField(
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
autofillHints: const [AutofillHints.email],
decoration: InputDecoration(
fillColor: _emailIsValid
? _validFieldValueColor
: getEnteColorScheme(context).fillFaint,
: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).email,
contentPadding: const EdgeInsets.symmetric(
@@ -176,11 +176,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
suffixIcon: _emailIsValid
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme.focusedBorder!
.borderSide.color,
)
: null,
),
@@ -210,7 +207,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
decoration: InputDecoration(
fillColor: _passwordIsValid
? _validFieldValueColor
: getEnteColorScheme(context).fillFaint,
: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).password,
contentPadding: const EdgeInsets.symmetric(
@@ -223,7 +220,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
_password1Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -235,11 +232,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
: _passwordIsValid
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
border: UnderlineInputBorder(
@@ -279,7 +273,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
decoration: InputDecoration(
fillColor: _passwordsMatch && _passwordIsValid
? _validFieldValueColor
: getEnteColorScheme(context).fillFaint,
: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).confirmPassword,
contentPadding: const EdgeInsets.symmetric(
@@ -292,7 +286,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
_password2Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -304,11 +298,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
: _passwordsMatch
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
border: UnderlineInputBorder(
@@ -345,9 +336,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
child: Row(
children: [
Text(
AppLocalizations.of(context).passwordStrength(
passwordStrengthValue: passwordStrengthText,
),
AppLocalizations.of(context)
.passwordStrength(passwordStrengthText),
style: TextStyle(
color: passwordStrengthColor,
fontWeight: FontWeight.w500,
@@ -358,7 +348,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
Icon(
Icons.info_outline,
size: 16,
color: getEnteColorScheme(context).fillStrong,
color: EnteTheme.getColorScheme(theme).fillStrong,
),
],
),
@@ -371,16 +361,16 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
const EdgeInsets.symmetric(vertical: 0, horizontal: 20),
child: Text(
AppLocalizations.of(context).hearUsWhereTitle,
style: getEnteTextTheme(context).smallFaint,
style: EnteTheme.getTextTheme(theme).smallFaint,
),
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: TextFormField(
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
decoration: InputDecoration(
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
@@ -400,7 +390,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
},
child: Icon(
Icons.info_outline_rounded,
color: getEnteColorScheme(context).fillStrong,
color: EnteTheme.getColorScheme(theme).fillStrong,
),
),
),
@@ -414,10 +404,10 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
),
Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
const SizedBox(height: 12),
_getAgreement(),
_getAgreement(theme),
const SizedBox(height: 40),
],
),
@@ -427,19 +417,19 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
);
}
Container _getAgreement() {
Container _getAgreement(ThemeData theme) {
return Container(
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
child: Column(
children: [
_getTOSAgreement(),
_getPasswordAgreement(),
_getTOSAgreement(theme),
_getPasswordAgreement(theme),
],
),
);
}
Widget _getTOSAgreement() {
Widget _getTOSAgreement(ThemeData theme) {
return GestureDetector(
onTap: () {
setState(() {
@@ -451,7 +441,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
children: [
Checkbox(
value: _hasAgreedToTOS,
side: CheckboxTheme.of(context).side,
side: theme.checkboxTheme.side,
onChanged: (value) {
setState(() {
_hasAgreedToTOS = value!;
@@ -461,10 +451,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
Expanded(
child: StyledText(
text: AppLocalizations.of(context).signUpTerms,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 12),
style: theme.textTheme.titleMedium!.copyWith(fontSize: 12),
tags: {
'u-terms': StyledTextActionTag(
(String? text, Map<String?, String?> attrs) =>
@@ -506,7 +493,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
);
}
Widget _getPasswordAgreement() {
Widget _getPasswordAgreement(ThemeData theme) {
return GestureDetector(
onTap: () {
setState(() {
@@ -518,7 +505,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
children: [
Checkbox(
value: _hasAgreedToE2E,
side: CheckboxTheme.of(context).side,
side: theme.checkboxTheme.side,
onChanged: (value) {
setState(() {
_hasAgreedToE2E = value!;
@@ -528,10 +515,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
Expanded(
child: StyledText(
text: AppLocalizations.of(context).ackPasswordLostWarning,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 12),
style: theme.textTheme.titleMedium!.copyWith(fontSize: 12),
tags: {
'underline': StyledTextActionTag(
(String? text, Map<String?, String?> attrs) =>

View File

@@ -41,6 +41,7 @@ class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -56,7 +57,7 @@ class _LoginPageState extends State<LoginPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -110,6 +111,7 @@ class _LoginPageState extends State<LoginPage> {
Widget _getBody() {
final l10n = context.l10n;
final theme = Theme.of(context);
return Column(
children: [
Expanded(
@@ -121,7 +123,7 @@ class _LoginPageState extends State<LoginPage> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
l10n.accountWelcomeBack,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -145,11 +147,8 @@ class _LoginPageState extends State<LoginPage> {
? Icon(
Icons.check,
size: 20,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme.focusedBorder!
.borderSide.color,
)
: null,
),
@@ -168,7 +167,7 @@ class _LoginPageState extends State<LoginPage> {
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
),
Padding(
@@ -179,9 +178,7 @@ class _LoginPageState extends State<LoginPage> {
flex: 5,
child: StyledText(
text: AppLocalizations.of(context).loginTerms,
style: Theme.of(context)
.textTheme
.titleMedium!
style: theme.textTheme.titleMedium!
.copyWith(fontSize: 12),
tags: {
'u-terms': StyledTextActionTag(
@@ -243,7 +240,9 @@ class _LoginPageState extends State<LoginPage> {
if (_emailIsValid) {
_emailInputFieldColor = const Color.fromRGBO(45, 194, 98, 0.2);
} else {
_emailInputFieldColor = getEnteColorScheme(context).fillFaint;
// Using Theme.of(context) directly since this method is outside build and 'theme' isn't stored.
_emailInputFieldColor =
EnteTheme.getColorScheme(Theme.of(context)).fillFaint;
}
}
}

View File

@@ -61,6 +61,7 @@ class _LoginPasswordVerificationPageState
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
late final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -76,13 +77,13 @@ class _LoginPasswordVerificationPageState
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: _getBody(),
body: _getBody(theme),
floatingActionButton: DynamicFAB(
key: const ValueKey("verifyPasswordButton"),
isKeypadOpen: isKeypadOpen,
@@ -201,7 +202,7 @@ class _LoginPasswordVerificationPageState
}
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
return Column(
children: [
Expanded(
@@ -212,7 +213,7 @@ class _LoginPasswordVerificationPageState
padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
child: Text(
AppLocalizations.of(context).enterPassword,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -223,7 +224,7 @@ class _LoginPasswordVerificationPageState
),
child: Text(
email ?? '',
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
),
),
Visibility(
@@ -253,14 +254,14 @@ class _LoginPasswordVerificationPageState
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(6),
),
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
suffixIcon: _passwordInFocus
? IconButton(
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -289,7 +290,7 @@ class _LoginPasswordVerificationPageState
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
),
Padding(
@@ -309,13 +310,10 @@ class _LoginPasswordVerificationPageState
child: Center(
child: Text(
AppLocalizations.of(context).forgotPassword,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
),
@@ -335,13 +333,10 @@ class _LoginPasswordVerificationPageState
child: Center(
child: Text(
AppLocalizations.of(context).changeEmail,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
),

View File

@@ -31,6 +31,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -46,7 +47,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -57,15 +58,15 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
child: StepProgressIndicator(
totalSteps: 4,
currentStep: 2,
selectedColor: Theme.of(context).colorScheme.greenAlternative,
selectedColor: theme.colorScheme.greenAlternative,
roundedEdges: const Radius.circular(10),
unselectedColor:
Theme.of(context).colorScheme.stepProgressUnselectedColor,
theme.colorScheme.stepProgressUnselectedColor,
),
)
: null,
),
body: _getBody(),
body: _getBody(theme),
floatingActionButton: DynamicFAB(
key: const ValueKey("verifyOttButton"),
isKeypadOpen: isKeypadOpen,
@@ -93,7 +94,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
);
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
return ListView(
children: [
Column(
@@ -103,7 +104,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
padding: const EdgeInsets.fromLTRB(20, 30, 20, 15),
child: Text(
AppLocalizations.of(context).verifyEmail,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -118,17 +119,13 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
padding: const EdgeInsets.fromLTRB(0, 0, 0, 12),
child: StyledText(
text: AppLocalizations.of(context)
.weHaveSendEmailTo(email: widget.email),
style: Theme.of(context)
.textTheme
.titleMedium!
.weHaveSendEmailTo(widget.email),
style: theme.textTheme.titleMedium!
.copyWith(fontSize: 14),
tags: {
'green': StyledTextTag(
style: TextStyle(
color: Theme.of(context)
.colorScheme
.greenAlternative,
color: theme.colorScheme.greenAlternative,
),
),
},
@@ -137,17 +134,13 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
widget.isResetPasswordScreen
? Text(
AppLocalizations.of(context).toResetVerifyEmail,
style: Theme.of(context)
.textTheme
.titleMedium!
style: theme.textTheme.titleMedium!
.copyWith(fontSize: 14),
)
: Text(
AppLocalizations.of(context)
.checkInboxAndSpamFolder,
style: Theme.of(context)
.textTheme
.titleMedium!
style: theme.textTheme.titleMedium!
.copyWith(fontSize: 14),
),
],
@@ -164,7 +157,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
padding: const EdgeInsets.fromLTRB(20, 16, 20, 16),
child: TextFormField(
key: const ValueKey("ottVerificationInputField"),
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
decoration: InputDecoration(
filled: true,
hintText: AppLocalizations.of(context).tapToEnterCode,
@@ -173,7 +166,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(6),
),
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
),
controller: _verificationCodeController,
autofocus: false,
@@ -186,7 +179,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
),
Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
Padding(
padding: const EdgeInsets.all(20),
@@ -205,10 +198,10 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
},
child: Text(
AppLocalizations.of(context).resendEmail,
style: Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
],

View File

@@ -88,6 +88,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -112,14 +113,14 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
? const SizedBox.shrink()
: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
),
elevation: 0,
),
body: _getBody(title),
body: _getBody(title, theme),
floatingActionButton: DynamicFAB(
isKeypadOpen: isKeypadOpen,
isFormValid: _passwordsMatch && _isPasswordValid,
@@ -138,7 +139,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
);
}
Widget _getBody(String buttonTextAndHeading) {
Widget _getBody(String buttonTextAndHeading, ThemeData theme) {
final email = Configuration.instance.getEmail();
var passwordStrengthText = AppLocalizations.of(context).weakStrength;
var passwordStrengthColor = Colors.redAccent;
@@ -163,7 +164,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
buttonTextAndHeading,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -174,10 +175,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
: AppLocalizations.of(context)
.enterNewPasswordToEncrypt,
textAlign: TextAlign.start,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 14),
style: theme.textTheme.titleMedium!.copyWith(fontSize: 14),
),
),
const Padding(padding: EdgeInsets.all(8)),
@@ -185,17 +183,13 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: StyledText(
text: AppLocalizations.of(context).passwordWarning,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 14),
style: theme.textTheme.titleMedium!.copyWith(fontSize: 14),
tags: {
'underline': StyledTextTag(
style:
Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
},
),
@@ -222,7 +216,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
decoration: InputDecoration(
fillColor: _isPasswordValid
? _validFieldValueColor
: getEnteColorScheme(context).fillFaint,
: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).password,
contentPadding: const EdgeInsets.all(20),
@@ -236,7 +230,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
_password1Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -248,11 +242,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
: _isPasswordValid
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
),
@@ -287,7 +278,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
decoration: InputDecoration(
fillColor: _passwordsMatch
? _validFieldValueColor
: getEnteColorScheme(context).fillFaint,
: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).confirmPassword,
contentPadding: const EdgeInsets.symmetric(
@@ -300,7 +291,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
_password2Visible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -312,11 +303,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
: _passwordsMatch
? Icon(
Icons.check,
color: Theme.of(context)
.inputDecorationTheme
.focusedBorder!
.borderSide
.color,
color: theme.inputDecorationTheme
.focusedBorder!.borderSide.color,
)
: null,
border: UnderlineInputBorder(
@@ -343,8 +331,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
child: Text(
AppLocalizations.of(context).passwordStrength(
passwordStrengthValue: passwordStrengthText,),
AppLocalizations.of(context)
.passwordStrength(passwordStrengthText),
style: TextStyle(
color: passwordStrengthColor,
),
@@ -371,11 +359,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
child: RichText(
text: TextSpan(
text: AppLocalizations.of(context).howItWorks,
style:
Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
),

View File

@@ -63,6 +63,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -78,13 +79,13 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: _getBody(),
body: _getBody(theme),
floatingActionButton: DynamicFAB(
key: const ValueKey("verifyPasswordButton"),
isKeypadOpen: isKeypadOpen,
@@ -186,7 +187,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
return Column(
children: [
Expanded(
@@ -198,7 +199,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
AppLocalizations.of(context).welcomeBack,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Visibility(
@@ -223,7 +224,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
decoration: InputDecoration(
hintText: AppLocalizations.of(context).enterYourPassword,
filled: true,
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
contentPadding: const EdgeInsets.all(20),
border: UnderlineInputBorder(
borderSide: BorderSide.none,
@@ -235,7 +236,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -264,7 +265,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
),
Padding(
@@ -285,11 +286,10 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
},
child: Text(
AppLocalizations.of(context).forgotPassword,
style:
Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
GestureDetector(
@@ -307,11 +307,10 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
},
child: Text(
AppLocalizations.of(context).changeEmail,
style:
Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
style: theme.textTheme.titleMedium!.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
],

View File

@@ -51,6 +51,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
@override
Widget build(BuildContext context) {
final String recoveryKey = bip39.entropyToMnemonic(widget.recoveryKey);
final theme = Theme.of(context);
if (recoveryKey.split(' ').length != mnemonicKeyWordCount) {
throw AssertionError(
'recovery code should have $mnemonicKeyWordCount words',
@@ -72,10 +73,10 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
child: StepProgressIndicator(
totalSteps: 4,
currentStep: 3,
selectedColor: Theme.of(context).colorScheme.greenAlternative,
selectedColor: theme.colorScheme.greenAlternative,
roundedEdges: const Radius.circular(10),
unselectedColor:
Theme.of(context).colorScheme.stepProgressUnselectedColor,
theme.colorScheme.stepProgressUnselectedColor,
),
),
)
@@ -107,7 +108,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
: Text(
widget.title ??
AppLocalizations.of(context).recoveryKey,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
Padding(
padding: EdgeInsets.all(widget.showAppBar! ? 0 : 12),
@@ -116,7 +117,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
widget.text ??
AppLocalizations.of(context)
.recoveryKeyOnForgotPassword,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
const Padding(padding: EdgeInsets.only(top: 24)),
DottedBorder(
@@ -162,16 +163,14 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
borderRadius: const BorderRadius.all(
Radius.circular(2),
),
color: Theme.of(context)
.colorScheme
.recoveryKeyBoxColor,
color:
theme.colorScheme.recoveryKeyBoxColor,
),
padding: const EdgeInsets.all(20),
width: double.infinity,
child: Text(
recoveryKey,
style:
Theme.of(context).textTheme.bodyLarge,
style: theme.textTheme.bodyLarge,
),
),
),
@@ -185,7 +184,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
widget.subText ??
AppLocalizations.of(context)
.recoveryKeySaveDescription,
style: Theme.of(context).textTheme.bodyLarge,
style: theme.textTheme.bodyLarge,
),
),
Expanded(
@@ -196,7 +195,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: _saveOptions(context, recoveryKey),
children: _saveOptions(context, recoveryKey, theme),
),
),
),
@@ -211,12 +210,16 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
);
}
List<Widget> _saveOptions(BuildContext context, String recoveryKey) {
List<Widget> _saveOptions(
BuildContext context,
String recoveryKey,
ThemeData theme,
) {
final List<Widget> childrens = [];
if (!_hasTriedToSave) {
childrens.add(
ElevatedButton(
style: Theme.of(context).colorScheme.optionalActionButtonStyle,
style: theme.colorScheme.optionalActionButtonStyle,
onPressed: () async {
await _saveKeys();
},

View File

@@ -20,6 +20,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
return null;
@@ -34,7 +35,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -99,7 +100,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
AppLocalizations.of(context).forgotPassword,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -107,7 +108,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
child: TextFormField(
decoration: InputDecoration(
filled: true,
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
hintText:
AppLocalizations.of(context).enterYourRecoveryKey,
contentPadding: const EdgeInsets.all(20),
@@ -134,7 +135,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
),
Row(

View File

@@ -57,6 +57,7 @@ class _RequestPasswordVerificationPageState
@override
Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
final theme = Theme.of(context);
FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) {
@@ -72,13 +73,13 @@ class _RequestPasswordVerificationPageState
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: _getBody(),
body: _getBody(theme),
floatingActionButton: DynamicFAB(
key: const ValueKey("verifyPasswordButton"),
isKeypadOpen: isKeypadOpen,
@@ -127,7 +128,7 @@ class _RequestPasswordVerificationPageState
);
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
return Column(
children: [
Expanded(
@@ -138,7 +139,7 @@ class _RequestPasswordVerificationPageState
padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
child: Text(
context.l10n.enterPassword,
style: Theme.of(context).textTheme.headlineMedium,
style: theme.textTheme.headlineMedium,
),
),
Padding(
@@ -149,7 +150,7 @@ class _RequestPasswordVerificationPageState
),
child: Text(
email ?? '',
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
),
),
Visibility(
@@ -174,7 +175,7 @@ class _RequestPasswordVerificationPageState
decoration: InputDecoration(
hintText: context.l10n.enterYourPassword,
filled: true,
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
contentPadding: const EdgeInsets.all(20),
border: UnderlineInputBorder(
borderSide: BorderSide.none,
@@ -186,7 +187,7 @@ class _RequestPasswordVerificationPageState
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
size: 20,
),
onPressed: () {
@@ -215,7 +216,7 @@ class _RequestPasswordVerificationPageState
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
),
],

View File

@@ -35,23 +35,24 @@ class _SessionsPageState extends State<SessionsPage> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(AppLocalizations.of(context).activeSessions),
),
body: _getBody(),
body: _getBody(theme),
);
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
if (_sessions == null) {
return const Center(child: EnteLoadingWidget());
}
final List<Widget> rows = [];
rows.add(const Padding(padding: EdgeInsets.all(4)));
for (final session in _sessions!.sessions) {
rows.add(_getSessionWidget(session));
rows.add(_getSessionWidget(session, theme));
}
return SingleChildScrollView(
child: Column(
@@ -60,21 +61,21 @@ class _SessionsPageState extends State<SessionsPage> {
);
}
Widget _getSessionWidget(Session session) {
Widget _getSessionWidget(Session session, ThemeData theme) {
final lastUsedTime =
DateTime.fromMicrosecondsSinceEpoch(session.lastUsedTime);
return Column(
children: [
InkWell(
onTap: () async {
_showSessionTerminationDialog(session);
_showSessionTerminationDialog(session, theme);
},
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_getUAWidget(session),
_getUAWidget(session, theme),
const Padding(padding: EdgeInsets.all(4)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -83,9 +84,7 @@ class _SessionsPageState extends State<SessionsPage> {
child: Text(
session.ip,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSurface
color: theme.colorScheme.onSurface
.withValues(alpha: 0.8),
fontSize: 14,
),
@@ -96,9 +95,7 @@ class _SessionsPageState extends State<SessionsPage> {
child: Text(
getFormattedTime(context, lastUsedTime),
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSurface
color: theme.colorScheme.onSurface
.withValues(alpha: 0.8),
fontSize: 12,
),
@@ -111,7 +108,7 @@ class _SessionsPageState extends State<SessionsPage> {
),
),
Divider(
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
],
);
@@ -152,7 +149,7 @@ class _SessionsPageState extends State<SessionsPage> {
}
}
void _showSessionTerminationDialog(Session session) {
void _showSessionTerminationDialog(Session session, ThemeData theme) {
final isLoggingOutFromThisDevice =
session.token == Configuration.instance.getToken();
Widget text;
@@ -171,7 +168,7 @@ class _SessionsPageState extends State<SessionsPage> {
const Padding(padding: EdgeInsets.all(8)),
Text(
session.ua,
style: Theme.of(context).textTheme.bodySmall,
style: theme.textTheme.bodySmall,
),
],
),
@@ -202,8 +199,8 @@ class _SessionsPageState extends State<SessionsPage> {
AppLocalizations.of(context).cancel,
style: TextStyle(
color: isLoggingOutFromThisDevice
? Theme.of(context).colorScheme.greenAlternative
: Theme.of(context).colorScheme.defaultTextColor,
? theme.colorScheme.greenAlternative
: theme.colorScheme.defaultTextColor,
),
),
onPressed: () {
@@ -222,13 +219,13 @@ class _SessionsPageState extends State<SessionsPage> {
);
}
Widget _getUAWidget(Session session) {
Widget _getUAWidget(Session session, ThemeData theme) {
if (session.token == Configuration.instance.getToken()) {
return Text(
AppLocalizations.of(context).thisDevice,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.greenAlternative,
color: theme.colorScheme.greenAlternative,
),
);
}

View File

@@ -28,6 +28,7 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: Text(
@@ -91,7 +92,7 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
context,
AppLocalizations.of(context).contactSupport,
AppLocalizations.of(context)
.dropSupportEmail(supportEmail: "support@ente.io"),
.dropSupportEmail("support@ente.io"),
);
},
child: Container(
@@ -102,7 +103,7 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: 12,
color: getEnteColorScheme(context)
color: EnteTheme.getColorScheme(theme)
.textBase
.withValues(alpha: 0.9),
),

View File

@@ -76,6 +76,7 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
elevation: 0,
@@ -83,11 +84,11 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
AppLocalizations.of(context).twofactorSetup,
),
),
body: _getBody(),
body: _getBody(theme),
);
}
Widget _getBody() {
Widget _getBody(ThemeData theme) {
return SingleChildScrollView(
reverse: true,
child: Center(
@@ -99,7 +100,7 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
child: Column(
children: [
TabBar(
labelColor: Theme.of(context).colorScheme.greenAlternative,
labelColor: theme.colorScheme.greenAlternative,
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
@@ -116,7 +117,7 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
child: TabBarView(
controller: _tabController,
children: [
_getSecretCode(),
_getSecretCode(theme),
_getBarCode(),
],
),
@@ -127,7 +128,7 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
Divider(
height: 1,
thickness: 1,
color: Theme.of(context).colorScheme.secondary,
color: theme.colorScheme.secondary,
),
_getVerificationWidget(),
],
@@ -136,8 +137,8 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
);
}
Widget _getSecretCode() {
final Color textColor = Theme.of(context).colorScheme.onSurface;
Widget _getSecretCode(ThemeData theme) {
final Color textColor = theme.colorScheme.onSurface;
return GestureDetector(
onTap: () async {
await Clipboard.setData(ClipboardData(text: widget.secretCode));

View File

@@ -120,13 +120,14 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
@override
Widget build(BuildContext context) {
final enteTheme = Theme.of(context).colorScheme.enteTheme;
final theme = Theme.of(context);
final enteTheme = theme.colorScheme.enteTheme;
return Scaffold(
appBar: AppBar(
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
onPressed: () {
Navigator.of(context).pop();
},
@@ -164,7 +165,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
TextFormField(
decoration: InputDecoration(
filled: true,
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
hintText:
AppLocalizations.of(context).enterYourRecoveryKey,
contentPadding: const EdgeInsets.all(20),

View File

@@ -18,7 +18,7 @@ import 'package:photos/services/account/user_service.dart';
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/hidden_service.dart';
import 'package:photos/theme/colors.dart';
import 'package:photos/theme/ente_theme.dart';
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/common/progress_dialog.dart';
import "package:photos/ui/common/user_dialogs.dart";
import 'package:photos/ui/components/action_sheet_widget.dart';
@@ -93,7 +93,7 @@ class CollectionActions {
body:
//'This will remove the public link for accessing "${collection.name}".',
AppLocalizations.of(context)
.disableLinkMessage(albumName: collection.displayName),
.disableLinkMessage(collection.displayName),
);
if (actionResult?.action != null) {
if (actionResult!.action == ButtonAction.error) {
@@ -195,7 +195,7 @@ class CollectionActions {
],
title: AppLocalizations.of(context).removeWithQuestionMark,
body: AppLocalizations.of(context)
.removeParticipantBody(userEmail: user.displayName ?? user.email),
.removeParticipantBody(user.displayName ?? user.email),
);
if (actionResult?.action != null) {
if (actionResult!.action == ButtonAction.error) {
@@ -296,7 +296,7 @@ class CollectionActions {
context: context,
title: AppLocalizations.of(context).inviteToEnte,
icon: Icons.info_outline,
body: AppLocalizations.of(context).emailNoEnteAccount(email: email),
body: AppLocalizations.of(context).emailNoEnteAccount(email),
isDismissible: true,
buttons: [
ButtonWidget(
@@ -339,7 +339,8 @@ class CollectionActions {
BuildContext context,
List<Collection> collections,
) async {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final actionResult = await showActionSheet(
context: context,
buttons: [
@@ -394,7 +395,7 @@ class CollectionActions {
],
bodyWidget: StyledText(
text: AppLocalizations.of(context)
.deleteMultipleAlbumDialog(count: collections.length),
.deleteMultipleAlbumDialog(collections.length),
style: textTheme.body.copyWith(color: textMutedDark),
tags: {
'bold': StyledTextTag(
@@ -422,26 +423,27 @@ class CollectionActions {
// deleteCollectionSheet returns true if the album is successfully deleted
Future<bool> deleteCollectionSheet(
BuildContext bContext,
BuildContext context,
Collection collection,
) async {
final textTheme = getEnteTextTheme(bContext);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final currentUserID = Configuration.instance.getUserID()!;
if (collection.owner.id != currentUserID) {
throw AssertionError("Can not delete album owned by others");
}
if (collection.hasSharees) {
final bool confirmDelete =
await _confirmSharedAlbumDeletion(bContext, collection);
await _confirmSharedAlbumDeletion(context, collection);
if (!confirmDelete) {
return false;
}
}
final actionResult = await showActionSheet(
context: bContext,
context: context,
buttons: [
ButtonWidget(
labelText: AppLocalizations.of(bContext).keepPhotos,
labelText: AppLocalizations.of(context).keepPhotos,
buttonType: ButtonType.neutral,
buttonSize: ButtonSize.large,
buttonAction: ButtonAction.first,
@@ -449,7 +451,7 @@ class CollectionActions {
isInAlert: true,
onTap: () async {
try {
await trashCollectionKeepingPhotos(collection, bContext);
await trashCollectionKeepingPhotos(collection, context);
} catch (e, s) {
logger.severe("Failed to keep photos & delete collection", e, s);
rethrow;
@@ -457,7 +459,7 @@ class CollectionActions {
},
),
ButtonWidget(
labelText: AppLocalizations.of(bContext).deletePhotos,
labelText: AppLocalizations.of(context).deletePhotos,
buttonType: ButtonType.critical,
buttonSize: ButtonSize.large,
buttonAction: ButtonAction.second,
@@ -473,7 +475,7 @@ class CollectionActions {
},
),
ButtonWidget(
labelText: AppLocalizations.of(bContext).cancel,
labelText: AppLocalizations.of(context).cancel,
buttonType: ButtonType.secondary,
buttonSize: ButtonSize.large,
buttonAction: ButtonAction.third,
@@ -482,7 +484,7 @@ class CollectionActions {
),
],
bodyWidget: StyledText(
text: AppLocalizations.of(bContext).deleteAlbumDialog,
text: AppLocalizations.of(context).deleteAlbumDialog,
style: textTheme.body.copyWith(color: textMutedDark),
tags: {
'bold': StyledTextTag(
@@ -495,7 +497,7 @@ class CollectionActions {
if (actionResult?.action != null &&
actionResult!.action == ButtonAction.error) {
await showGenericErrorDialog(
context: bContext,
context: context,
error: actionResult.exception,
);
return false;

View File

@@ -1,6 +1,7 @@
import "dart:async";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/details_sheet_event.dart";
@@ -35,14 +36,12 @@ Future<void> showSingleFileDeleteSheet(
AppLocalizations.of(context).singleFileDeleteHighlight;
String body = "";
if (isBothLocalAndRemote) {
body = AppLocalizations.of(context)
.singleFileInBothLocalAndRemote(fileType: fileType);
} else if (isRemoteOnly) {
body =
AppLocalizations.of(context).singleFileInRemoteOnly(fileType: fileType);
AppLocalizations.of(context).singleFileInBothLocalAndRemote(fileType);
} else if (isRemoteOnly) {
body = AppLocalizations.of(context).singleFileInRemoteOnly(fileType);
} else if (isLocalOnly) {
body = AppLocalizations.of(context)
.singleFileDeleteFromDevice(fileType: fileType);
body = AppLocalizations.of(context).singleFileDeleteFromDevice(fileType);
} else {
throw AssertionError("Unexpected state");
}
@@ -143,7 +142,8 @@ Future<void> showSingleFileDeleteSheet(
Future<void> showDetailsSheet(BuildContext context, EnteFile file) async {
guardedCheckPanorama(file).ignore();
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
Bus.instance.fire(
DetailsSheetEvent(
localID: file.localID,

View File

@@ -27,7 +27,8 @@ class _AutoCastDialogState extends State<AutoCastDialog> {
@override
Widget build(BuildContext context) {
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final textStyle = EnteTheme.getTextTheme(theme);
final AlertDialog alert = AlertDialog(
title: Text(
AppLocalizations.of(context).connectToDevice,

View File

@@ -19,7 +19,8 @@ class _CastChooseDialogState extends State<CastChooseDialog> {
@override
Widget build(BuildContext context) {
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final textStyle = EnteTheme.getTextTheme(theme);
final AlertDialog alert = AlertDialog(
title: Text(
context.l10n.playOnTv,

View File

@@ -23,8 +23,9 @@ class AlbumColumnItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final colorScheme = EnteTheme.getColorScheme(theme);
const sideOfThumbnail = 60.0;
final isSelected = selectedCollections.contains(collection);
return AnimatedContainer(
@@ -89,9 +90,8 @@ class AlbumColumnItemWidget extends StatelessWidget {
if (snapshot.hasData) {
return Text(
AppLocalizations.of(context).memoryCount(
count: snapshot.data!,
formattedCount:
NumberFormat().format(snapshot.data!),
snapshot.data!,
NumberFormat().format(snapshot.data!),
),
style: textTheme.miniMuted,
);

View File

@@ -2,6 +2,7 @@ import "dart:async";
import "dart:math";
import "package:flutter/cupertino.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/collection_updated_event.dart";
@@ -62,6 +63,7 @@ class _AlbumHorizontalListState extends State<AlbumHorizontalList> {
return FutureBuilder<List<Collection>>(
future: widget.collectionsFuture(),
builder: (context, snapshot) {
final theme = Theme.of(context);
if (snapshot.hasError) {
_logger.severe("failed to fetch albums", snapshot.error);
return Text(AppLocalizations.of(context).somethingWentWrong);
@@ -80,7 +82,7 @@ class _AlbumHorizontalListState extends State<AlbumHorizontalList> {
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Text(
AppLocalizations.of(context).albums,
style: getEnteTextTheme(context).large,
style: EnteTheme.getTextTheme(theme).large,
),
),
Align(

View File

@@ -27,8 +27,9 @@ class AlbumListItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final colorScheme = EnteTheme.getColorScheme(theme);
const sideOfThumbnail = 60.0;
final albumWidget = Flexible(
@@ -75,8 +76,8 @@ class AlbumListItemWidget extends StatelessWidget {
if (snapshot.hasData) {
return Text(
AppLocalizations.of(context).memoryCount(
count: snapshot.data!,
formattedCount: NumberFormat().format(snapshot.data!),
snapshot.data!,
NumberFormat().format(snapshot.data!),
),
style: textTheme.small.copyWith(
color: colorScheme.textMuted,

View File

@@ -12,8 +12,9 @@ class NewAlbumListItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final colorScheme = EnteTheme.getColorScheme(theme);
const sideOfThumbnail = 60.0;
return LayoutBuilder(
builder: (context, constraints) {
@@ -27,7 +28,7 @@ class NewAlbumListItemWidget extends StatelessWidget {
child: Container(
height: sideOfThumbnail,
width: sideOfThumbnail,
color: Theme.of(context).brightness == Brightness.light
color: !EnteTheme.isDark(theme)
? colorScheme.backdropBase
: colorScheme.backdropFaint,
child: Icon(

View File

@@ -23,7 +23,8 @@ class NewAlbumRowItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return GestureDetector(
onTap: () async {
final result = await showTextInputDialog(
@@ -73,7 +74,7 @@ class NewAlbumRowItemWidget extends StatelessWidget {
child: Container(
height: height,
width: width,
color: Theme.of(context).brightness == Brightness.light
color: theme.brightness == Brightness.light
? colorScheme.backdropBase
: colorScheme.backdropFaint,
child: DottedBorder(
@@ -95,7 +96,7 @@ class NewAlbumRowItemWidget extends StatelessWidget {
const SizedBox(height: 6),
Text(
AppLocalizations.of(context).addNew,
style: getEnteTextTheme(context).smallFaint,
style: EnteTheme.getTextTheme(theme).smallFaint,
),
],
),

View File

@@ -48,7 +48,8 @@ class AlbumRowItemWidget extends StatelessWidget {
tag +
"_" +
c.id.toString();
final enteTextTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final enteTextTheme = EnteTheme.getTextTheme(theme);
final Widget? linkIcon = c.hasLink && isOwner
? Icon(
Icons.link,
@@ -73,7 +74,7 @@ class AlbumRowItemWidget extends StatelessWidget {
cornerSmoothing: _cornerSmoothing,
),
child: Container(
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
width: sideOfThumbnail,
height: sideOfThumbnail,
),
@@ -131,7 +132,8 @@ class AlbumRowItemWidget extends StatelessWidget {
);
} else {
return Container(
color: getEnteColorScheme(context).backdropBase,
color: EnteTheme.getColorScheme(theme)
.backdropBase,
child: const NoThumbnailWidget(
borderRadius: 12,
addBorder: false,

View File

@@ -243,24 +243,24 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
bool hasVerifiedLock = false;
if (widget.actionType == CollectionActionType.addFiles) {
toastMessage = AppLocalizations.of(context)
.addedSuccessfullyTo(albumName: item.displayName);
toastMessage =
AppLocalizations.of(context).addedSuccessfullyTo(item.displayName);
shouldNavigateToCollection = true;
} else if (widget.actionType == CollectionActionType.moveFiles ||
widget.actionType == CollectionActionType.restoreFiles ||
widget.actionType == CollectionActionType.unHide) {
toastMessage = AppLocalizations.of(context)
.movedSuccessfullyTo(albumName: item.displayName);
toastMessage =
AppLocalizations.of(context).movedSuccessfullyTo(item.displayName);
shouldNavigateToCollection = true;
} else if (widget.actionType ==
CollectionActionType.moveToHiddenCollection) {
toastMessage = AppLocalizations.of(context)
.movedSuccessfullyTo(albumName: item.displayName);
toastMessage =
AppLocalizations.of(context).movedSuccessfullyTo(item.displayName);
shouldNavigateToCollection = true;
hasVerifiedLock = true;
} else if (widget.actionType == CollectionActionType.addToHiddenAlbum) {
toastMessage = AppLocalizations.of(context)
.addedSuccessfullyTo(albumName: item.displayName);
toastMessage =
AppLocalizations.of(context).addedSuccessfullyTo(item.displayName);
shouldNavigateToCollection = true;
hasVerifiedLock = true;
} else {

View File

@@ -17,18 +17,19 @@ class ArchivedCollectionsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final Set<int> hiddenCollectionId =
CollectionsService.instance.getHiddenCollectionIds();
return OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.surface,
backgroundColor: theme.colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(0),
side: BorderSide(
width: 0.5,
color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.24),
color: theme.iconTheme.color!.withValues(alpha: 0.24),
),
),
child: SizedBox(
@@ -43,7 +44,7 @@ class ArchivedCollectionsButton extends StatelessWidget {
children: [
Icon(
Icons.archive_outlined,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
const Padding(padding: EdgeInsets.all(6)),
FutureBuilder<int>(
@@ -60,7 +61,7 @@ class ArchivedCollectionsButton extends StatelessWidget {
children: [
TextSpan(
text: AppLocalizations.of(context).archive,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
const TextSpan(text: " \u2022 "),
TextSpan(
@@ -77,7 +78,7 @@ class ArchivedCollectionsButton extends StatelessWidget {
children: [
TextSpan(
text: AppLocalizations.of(context).archive,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
//need to query in db and bring this value
],
@@ -90,7 +91,7 @@ class ArchivedCollectionsButton extends StatelessWidget {
),
Icon(
Icons.chevron_right,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
],
),

View File

@@ -14,16 +14,16 @@ class HiddenCollectionsButtonWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.surface,
backgroundColor: theme.colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(0),
side: BorderSide(
width: 0.5,
color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.24),
color: theme.iconTheme.color!.withValues(alpha: 0.24),
),
),
child: SizedBox(
@@ -38,7 +38,7 @@ class HiddenCollectionsButtonWidget extends StatelessWidget {
children: [
Icon(
Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
const Padding(padding: EdgeInsets.all(6)),
RichText(
@@ -47,14 +47,14 @@ class HiddenCollectionsButtonWidget extends StatelessWidget {
children: [
TextSpan(
text: AppLocalizations.of(context).hidden,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
const TextSpan(text: " \u2022 "),
WidgetSpan(
child: Icon(
Icons.lock_outline,
size: 16,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
),
//need to query in db and bring this value
@@ -65,7 +65,7 @@ class HiddenCollectionsButtonWidget extends StatelessWidget {
),
Icon(
Icons.chevron_right,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
],
),

View File

@@ -43,16 +43,17 @@ class _TrashSectionButtonState extends State<TrashSectionButton> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.surface,
backgroundColor: theme.colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(0),
side: BorderSide(
width: 0.5,
color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.24),
color: theme.iconTheme.color!.withValues(alpha: 0.24),
),
),
child: SizedBox(
@@ -67,7 +68,7 @@ class _TrashSectionButtonState extends State<TrashSectionButton> {
children: [
Icon(
Icons.delete,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
const Padding(padding: EdgeInsets.all(6)),
FutureBuilder<int>(
@@ -80,7 +81,7 @@ class _TrashSectionButtonState extends State<TrashSectionButton> {
children: [
TextSpan(
text: AppLocalizations.of(context).trash,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
const TextSpan(text: " \u2022 "),
TextSpan(
@@ -97,7 +98,7 @@ class _TrashSectionButtonState extends State<TrashSectionButton> {
children: [
TextSpan(
text: AppLocalizations.of(context).trash,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
//need to query in db and bring this value
],
@@ -110,7 +111,7 @@ class _TrashSectionButtonState extends State<TrashSectionButton> {
),
Icon(
Icons.chevron_right,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
],
),

View File

@@ -17,6 +17,7 @@ class UnCategorizedCollections extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final Collection? collection = CollectionsService.instance
.getActiveCollections()
.firstWhereOrNull((e) => e.type == CollectionType.uncategorized);
@@ -26,14 +27,14 @@ class UnCategorizedCollections extends StatelessWidget {
}
return OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.surface,
backgroundColor: theme.colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(0),
side: BorderSide(
width: 0.5,
color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.24),
color: theme.iconTheme.color!.withValues(alpha: 0.24),
),
),
child: SizedBox(
@@ -48,7 +49,7 @@ class UnCategorizedCollections extends StatelessWidget {
children: [
Icon(
Icons.category_outlined,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
const Padding(padding: EdgeInsets.all(6)),
FutureBuilder<int>(
@@ -64,7 +65,7 @@ class UnCategorizedCollections extends StatelessWidget {
TextSpan(
text:
AppLocalizations.of(context).uncategorized,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
const TextSpan(text: " \u2022 "),
TextSpan(
@@ -82,7 +83,7 @@ class UnCategorizedCollections extends StatelessWidget {
TextSpan(
text:
AppLocalizations.of(context).uncategorized,
style: Theme.of(context).textTheme.titleMedium,
style: theme.textTheme.titleMedium,
),
//need to query in db and bring this value
],
@@ -95,7 +96,7 @@ class UnCategorizedCollections extends StatelessWidget {
),
Icon(
Icons.chevron_right,
color: Theme.of(context).iconTheme.color,
color: theme.iconTheme.color,
),
],
),

View File

@@ -55,10 +55,10 @@ String _actionName(
String text = "";
switch (type) {
case CollectionActionType.addFiles:
text = AppLocalizations.of(context).addItem(count: fileCount);
text = AppLocalizations.of(context).addItem(fileCount);
break;
case CollectionActionType.moveFiles:
text = AppLocalizations.of(context).moveItem(count: fileCount);
text = AppLocalizations.of(context).moveItem(fileCount);
break;
case CollectionActionType.restoreFiles:
text = AppLocalizations.of(context).restoreToAlbum;
@@ -108,7 +108,9 @@ void showCollectionActionSheet(
),
),
topControl: const SizedBox.shrink(),
backgroundColor: getEnteColorScheme(context).backgroundElevated,
// Use current theme (cannot rely on an existing 'theme' variable here)
backgroundColor:
EnteTheme.getColorScheme(Theme.of(context)).backgroundElevated,
barrierColor: backdropFaintDark,
enableDrag: true,
);
@@ -170,6 +172,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final filesCount = widget.sharedFiles != null
? widget.sharedFiles!.length
: widget.selectedPeople != null
@@ -242,7 +245,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
border: Border(
top: BorderSide(
color: _enableSelection
? getEnteColorScheme(context).strokeFaint
? EnteTheme.getColorScheme(theme).strokeFaint
: Colors.transparent,
),
),
@@ -312,7 +315,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
showShortToast(
context,
AppLocalizations.of(context)
.addedToAlbums(count: _selectedCollections.length),
.addedToAlbums(_selectedCollections.length),
);
widget.selectedFiles?.clearAll();
}

View File

@@ -141,8 +141,9 @@ class _CollectionListPageState extends State<CollectionListPage> {
}
Widget _sortMenu(List<Collection> collections) {
final colorTheme = getEnteColorScheme(context);
final isLightMode = Theme.of(context).brightness == Brightness.light;
final theme = Theme.of(context);
final colorTheme = EnteTheme.getColorScheme(theme);
final isLightMode = !EnteTheme.isDark(theme);
Widget sortOptionText(AlbumSortKey key) {
String text = key.toString();
switch (key) {
@@ -174,7 +175,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
}
return Theme(
data: Theme.of(context).copyWith(
data: theme.copyWith(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
),

View File

@@ -25,6 +25,7 @@ class DeviceFolderItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isBackedUp = deviceCollection.shouldBackup;
return GestureDetector(
child: Column(
@@ -43,7 +44,7 @@ class DeviceFolderItem extends StatelessWidget {
cornerSmoothing: _cornerSmoothing,
),
child: Container(
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
width: sideOfThumbnail,
height: sideOfThumbnail,
),
@@ -89,7 +90,7 @@ class DeviceFolderItem extends StatelessWidget {
child: Text(
deviceCollection.name,
textAlign: TextAlign.left,
style: Theme.of(context).colorScheme.enteTheme.textTheme.small,
style: theme.colorScheme.enteTheme.textTheme.small,
overflow: TextOverflow.ellipsis,
),
),
@@ -99,8 +100,7 @@ class DeviceFolderItem extends StatelessWidget {
child: Text(
deviceCollection.count.toString(),
textAlign: TextAlign.left,
style:
Theme.of(context).colorScheme.enteTheme.textTheme.miniMuted,
style: theme.colorScheme.enteTheme.textTheme.miniMuted,
overflow: TextOverflow.ellipsis,
),
),

View File

@@ -7,13 +7,14 @@ class BottomShadowWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
height: 8,
decoration: BoxDecoration(
color: Colors.transparent,
boxShadow: [
BoxShadow(
color: shadowColor ?? Theme.of(context).colorScheme.surface,
color: shadowColor ?? theme.colorScheme.surface,
spreadRadius: 42,
blurRadius: 42,
offset: Offset(0, offsetDy), // changes position of shadow

View File

@@ -144,6 +144,7 @@ class _DatePickerFieldState extends State<DatePickerField> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return TextFormField(
controller: _controller,
onChanged: (value) => _tryParseDate(value),
@@ -151,14 +152,14 @@ class _DatePickerFieldState extends State<DatePickerField> {
focusedBorder: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide(
color: getEnteColorScheme(context).strokeMuted,
color: EnteTheme.getColorScheme(theme).strokeMuted,
),
),
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: widget.hintText ??
"Enter date (DD/MM/YYYY)${widget.isRequired ? '' : ' (optional)'}",
hintStyle: getEnteTextTheme(context).bodyFaint,
hintStyle: EnteTheme.getTextTheme(theme).bodyFaint,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 14,
@@ -171,8 +172,8 @@ class _DatePickerFieldState extends State<DatePickerField> {
icon: const Icon(Icons.calendar_today),
onPressed: _showDatePicker,
color: _hasError
? getEnteColorScheme(context).warning500
: getEnteColorScheme(context).strokeMuted,
? EnteTheme.getColorScheme(theme).warning500
: EnteTheme.getColorScheme(theme).strokeMuted,
),
),
);

View File

@@ -19,12 +19,13 @@ class DynamicFAB extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
if (isKeypadOpen!) {
return Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.surface,
color: theme.colorScheme.surface,
spreadRadius: 200,
blurRadius: 100,
offset: const Offset(0, 230),
@@ -37,10 +38,8 @@ class DynamicFAB extends StatelessWidget {
children: [
FloatingActionButton(
heroTag: 'FAB',
backgroundColor:
Theme.of(context).colorScheme.dynamicFABBackgroundColor,
foregroundColor:
Theme.of(context).colorScheme.dynamicFABTextColor,
backgroundColor: theme.colorScheme.dynamicFABBackgroundColor,
foregroundColor: theme.colorScheme.dynamicFABTextColor,
onPressed: isFormValid!
? onPressedFunction as void Function()?
: () {

View File

@@ -28,6 +28,7 @@ class GradientButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
Widget buttonContent;
if (iconData == null) {
buttonContent = Text(
@@ -73,8 +74,8 @@ class GradientButton extends StatelessWidget {
colors: onTap != null
? linearGradientColors
: [
getEnteColorScheme(context).fillMuted,
getEnteColorScheme(context).fillMuted,
EnteTheme.getColorScheme(theme).fillMuted,
EnteTheme.getColorScheme(theme).fillMuted,
],
),
borderRadius: BorderRadius.circular(8),

View File

@@ -54,12 +54,13 @@ class LinearProgressDialogState extends State<LinearProgressDialog>
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return PopScope(
canPop: false,
child: AlertDialog(
title: Text(
widget.message,
style: getEnteTextTheme(context).smallMuted,
style: EnteTheme.getTextTheme(theme).smallMuted,
textAlign: TextAlign.center,
),
content: AnimatedBuilder(
@@ -68,7 +69,7 @@ class LinearProgressDialogState extends State<LinearProgressDialog>
return LinearProgressIndicator(
value: _animation.value,
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).colorScheme.greenAlternative,
theme.colorScheme.greenAlternative,
),
);
},

View File

@@ -16,6 +16,7 @@ class EnteLoadingWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Align(
alignment: alignment,
child: Padding(
@@ -25,7 +26,7 @@ class EnteLoadingWidget extends StatelessWidget {
child: RepaintBoundary(
child: CircularProgressIndicator(
strokeWidth: 2,
color: color ?? getEnteColorScheme(context).strokeBase,
color: color ?? EnteTheme.getColorScheme(theme).strokeBase,
strokeCap: StrokeCap.round,
),
),

View File

@@ -12,7 +12,7 @@ Future<void> showInviteDialog(BuildContext context, String email) async {
context: context,
title: AppLocalizations.of(context).inviteToEnte,
icon: Icons.info_outline,
body: AppLocalizations.of(context).emailNoEnteAccount(email: email),
body: AppLocalizations.of(context).emailNoEnteAccount(email),
isDismissible: true,
buttons: [
ButtonWidget(

View File

@@ -145,7 +145,8 @@ class ContentContainerWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final bool bodyMissing = body == null && bodyWidget == null;
debugPrint("body missing $bodyMissing");
return Column(
@@ -179,7 +180,7 @@ class ContentContainerWidget extends StatelessWidget {
Icons.check_outlined,
size: 48,
color: isCheckIconGreen
? getEnteColorScheme(context).primary700
? EnteTheme.getColorScheme(theme).primary700
: strokeBaseDark,
),
actionSheetType == ActionSheetType.defaultActionSheet &&

View File

@@ -40,7 +40,8 @@ class _BlurMenuItemWidgetState extends State<BlurMenuItemWidget> {
@override
Widget build(BuildContext context) {
isDisabled = (widget.onTap == null);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return GestureDetector(
onTap: widget.onTap,
onTapDown: _onTapDown,
@@ -77,12 +78,13 @@ class _BlurMenuItemWidgetState extends State<BlurMenuItemWidget> {
widget.labelText!,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style:
getEnteTextTheme(context).bodyBold.copyWith(
color: isDisabled
? colorScheme.textFaint
: colorScheme.blurTextBase,
),
style: EnteTheme.getTextTheme(theme)
.bodyBold
.copyWith(
color: isDisabled
? colorScheme.textFaint
: colorScheme.blurTextBase,
),
),
),
],

View File

@@ -41,7 +41,8 @@ class _ActionBarWidgetState extends State<ActionBarWidget> {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
return SizedBox(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
@@ -57,11 +58,11 @@ class _ActionBarWidgetState extends State<ActionBarWidget> {
_selectedOwnedFilesNotifier.value !=
_selectedFilesNotifier.value
? AppLocalizations.of(context).selectedPhotosWithYours(
count: _selectedFilesNotifier.value,
yourCount: _selectedOwnedFilesNotifier.value,
_selectedFilesNotifier.value,
_selectedOwnedFilesNotifier.value,
)
: AppLocalizations.of(context).selectedPhotos(
count: _selectedFilesNotifier.value,
_selectedFilesNotifier.value,
),
style: textTheme.miniMuted,
);

View File

@@ -34,7 +34,8 @@ class _AlbumActionBarWidgetState extends State<AlbumActionBarWidget> {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
return SizedBox(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
@@ -48,7 +49,7 @@ class _AlbumActionBarWidgetState extends State<AlbumActionBarWidget> {
builder: (context, value, child) {
return Text(
AppLocalizations.of(context).selectedAlbums(
count: widget.selectedAlbums?.albums.length ?? 0,
widget.selectedAlbums?.albums.length ?? 0,
),
style: textTheme.miniMuted,
);

View File

@@ -25,7 +25,8 @@ class AlbumBottomActionBarWidget extends StatelessWidget {
Widget build(BuildContext context) {
final bottomPadding = MediaQuery.paddingOf(context).bottom;
final widthOfScreen = MediaQuery.sizeOf(context).width;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final double leftRightPadding = widthOfScreen > restrictedMaxWidth
? (widthOfScreen - restrictedMaxWidth) / 2
: 0;

View File

@@ -33,7 +33,8 @@ class BottomActionBarWidget extends StatelessWidget {
Widget build(BuildContext context) {
final bottomPadding = MediaQuery.paddingOf(context).bottom;
final widthOfScreen = MediaQuery.of(context).size.width;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final double leftRightPadding = widthOfScreen > restrictedMaxWidth
? (widthOfScreen - restrictedMaxWidth) / 2
: 0;

View File

@@ -34,7 +34,8 @@ class _PeopleActionBarWidgetState extends State<PeopleActionBarWidget> {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
return SizedBox(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
@@ -48,7 +49,7 @@ class _PeopleActionBarWidgetState extends State<PeopleActionBarWidget> {
builder: (context, value, child) {
final count = widget.selectedPeople?.personIds.length ?? 0;
return Text(
AppLocalizations.of(context).selectedPhotos(count: count),
AppLocalizations.of(context).selectedPhotos(count),
style: textTheme.miniMuted,
);
},

View File

@@ -22,7 +22,8 @@ class PeopleBottomActionBarWidget extends StatelessWidget {
Widget build(BuildContext context) {
final bottomPadding = MediaQuery.paddingOf(context).bottom;
final widthOfScreen = MediaQuery.sizeOf(context).width;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final double leftRightPadding = widthOfScreen > restrictedMaxWidth
? (widthOfScreen - restrictedMaxWidth) / 2
: 0;

View File

@@ -73,7 +73,8 @@ class __BodyState extends State<_Body> {
@override
Widget build(BuildContext context) {
widthOfButton = getWidthOfButton();
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return GestureDetector(
onTap: widget.onTap,
onTapDown: (details) {
@@ -110,7 +111,7 @@ class __BodyState extends State<_Body> {
child: Icon(
widget.icon,
size: 24,
color: getEnteColorScheme(context).primary300,
color: EnteTheme.getColorScheme(theme).primary300,
shadows: const [
BoxShadow(
color: Color.fromARGB(12, 0, 179, 60),
@@ -137,7 +138,7 @@ class __BodyState extends State<_Body> {
SvgPicture.asset(
widget.svgAssetPath!,
colorFilter: ColorFilter.mode(
getEnteColorScheme(context).textMuted,
EnteTheme.getColorScheme(theme).textMuted,
BlendMode.srcIn,
),
width: 24,
@@ -149,14 +150,14 @@ class __BodyState extends State<_Body> {
Icon(
widget.icon,
size: 24,
color: getEnteColorScheme(context).textMuted,
color: EnteTheme.getColorScheme(theme).textMuted,
),
const SizedBox(height: 4),
Text(
widget.labelText,
textAlign: TextAlign.center,
//textTheme in [getWidthOfLongestWord] should be same as this
style: getEnteTextTheme(context).miniMuted,
style: EnteTheme.getTextTheme(theme).miniMuted,
),
],
),
@@ -180,8 +181,10 @@ class __BodyState extends State<_Body> {
double maxWidth = 0.0;
for (String word in words) {
final width =
computeWidthOfWord(word, getEnteTextTheme(context).miniMuted);
final width = computeWidthOfWord(
word,
EnteTheme.getTextTheme(Theme.of(context)).miniMuted,
);
if (width > maxWidth) {
maxWidth = width;
}

View File

@@ -17,6 +17,7 @@ class BottomOfTitleBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Row(
mainAxisAlignment: showCloseButton
? MainAxisAlignment.spaceBetween
@@ -32,8 +33,8 @@ class BottomOfTitleBarWidget extends StatelessWidget {
caption != null
? Text(
caption!,
style: getEnteTextTheme(context).small.copyWith(
color: getEnteColorScheme(context).textMuted,
style: EnteTheme.getTextTheme(theme).small.copyWith(
color: EnteTheme.getColorScheme(theme).textMuted,
),
)
: const SizedBox.shrink(),
@@ -45,7 +46,7 @@ class BottomOfTitleBarWidget extends StatelessWidget {
IconButton(
icon: Icon(
Icons.close,
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
),
onPressed: () {
Navigator.of(context).pop();

View File

@@ -87,16 +87,17 @@ class ButtonWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme =
shouldStickToDarkTheme ? darkScheme : getEnteColorScheme(context);
shouldStickToDarkTheme ? darkScheme : EnteTheme.getColorScheme(theme);
final inverseColorScheme = shouldStickToDarkTheme
? lightScheme
: getEnteColorScheme(context, inverse: true);
: EnteTheme.getColorScheme(theme, inverse: true);
final textTheme =
shouldStickToDarkTheme ? darkTextTheme : getEnteTextTheme(context);
shouldStickToDarkTheme ? darkTextTheme : EnteTheme.getTextTheme(theme);
final inverseTextTheme = shouldStickToDarkTheme
? lightTextTheme
: getEnteTextTheme(context, inverse: true);
: EnteTheme.getTextTheme(theme, inverse: true);
final buttonStyle = CustomButtonStyle(
//Dummy default values since we need to keep these properties non-nullable
defaultButtonColor: Colors.transparent,

View File

@@ -17,12 +17,13 @@ class ChipButtonWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return GestureDetector(
onTap: onTap?.call,
child: Container(
width: noChips ? double.infinity : null,
decoration: BoxDecoration(
color: getEnteColorScheme(context).fillFaint,
color: EnteTheme.getColorScheme(theme).fillFaint,
borderRadius: const BorderRadius.all(Radius.circular(4)),
),
child: Padding(
@@ -44,7 +45,7 @@ class ChipButtonWidget extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
label!,
style: getEnteTextTheme(context).miniBold,
style: EnteTheme.getTextTheme(theme).miniBold,
),
),
],

View File

@@ -49,8 +49,9 @@ class _IconButtonWidgetState extends State<IconButtonWidget> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final bool hasPressedState = widget.onTap != null;
final colorTheme = getEnteColorScheme(context);
final colorTheme = EnteTheme.getColorScheme(theme);
iconStateColor ??
(iconStateColor = widget.defaultColor ??
(widget.iconButtonType == IconButtonType.rounded
@@ -99,7 +100,7 @@ class _IconButtonWidgetState extends State<IconButtonWidget> {
}
_onTapDown(details) {
final colorTheme = getEnteColorScheme(context);
final colorTheme = EnteTheme.getColorScheme(Theme.of(context));
setState(() {
iconStateColor = widget.pressedColor ??
(widget.iconButtonType == IconButtonType.rounded

View File

@@ -1,4 +1,5 @@
import "package:flutter/cupertino.dart";
import 'package:flutter/material.dart';
import "package:photos/theme/ente_theme.dart";
class InlineButtonWidget extends StatelessWidget {
@@ -9,11 +10,12 @@ class InlineButtonWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return GestureDetector(
onTap: onTap?.call,
child: Text(
label,
style: textStyle ?? getEnteTextTheme(context).smallMuted,
style: textStyle ?? EnteTheme.getTextTheme(theme).smallMuted,
),
);
}

View File

@@ -21,8 +21,9 @@ class CaptionedTextWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final enteColorScheme = Theme.of(context).colorScheme.enteTheme.colorScheme;
final enteTextTheme = Theme.of(context).colorScheme.enteTheme.textTheme;
final theme = Theme.of(context);
final enteColorScheme = theme.colorScheme.enteTheme.colorScheme;
final enteTextTheme = theme.colorScheme.enteTheme.textTheme;
final capitalized = title.capitalizeFirst();

View File

@@ -65,7 +65,8 @@ class DialogWidget extends StatelessWidget {
Widget build(BuildContext context) {
final widthOfScreen = MediaQuery.of(context).size.width;
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return Container(
width: min(widthOfScreen, 320),
padding: isMobileSmall
@@ -110,8 +111,9 @@ class ContentContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final colorScheme = EnteTheme.getColorScheme(theme);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -243,7 +245,8 @@ class _TextInputDialogState extends State<TextInputDialog> {
Widget build(BuildContext context) {
final widthOfScreen = MediaQuery.sizeOf(context).width;
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return Container(
width: min(widthOfScreen, 320),
padding: isMobileSmall

View File

@@ -23,15 +23,16 @@ class DividerWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final dividerColor = divColorHasBlur
? getEnteColorScheme(context).blurStrokeFaint
: getEnteColorScheme(context).strokeFaint;
? EnteTheme.getColorScheme(theme).blurStrokeFaint
: EnteTheme.getColorScheme(theme).strokeFaint;
if (dividerType == DividerType.solid) {
return Padding(
padding: padding ?? EdgeInsets.zero,
child: Container(
color: getEnteColorScheme(context).strokeFaint,
color: EnteTheme.getColorScheme(theme).strokeFaint,
width: double.infinity,
height: 1,
),

View File

@@ -9,8 +9,9 @@ class EmptyStateItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

View File

@@ -20,8 +20,9 @@ class EndToEndBanner extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
return GestureDetector(
onTap: onTap,
child: Container(

View File

@@ -42,13 +42,14 @@ class _ExpandableMenuItemWidgetState extends State<ExpandableMenuItemWidget> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isAnySectionExpanded =
InheritedSettingsState.maybeOf(context)?.isAnySectionExpanded ?? false;
final isCurrentSectionExpanded = expandableController.expanded;
final isSuppressed = isAnySectionExpanded && !isCurrentSectionExpanded;
final enteColorScheme = Theme.of(context).colorScheme.enteTheme.colorScheme;
final backgroundColor = Theme.of(context).brightness == Brightness.light
final enteColorScheme = theme.colorScheme.enteTheme.colorScheme;
final backgroundColor = theme.brightness == Brightness.light
? enteColorScheme.backgroundElevated2
: enteColorScheme.backgroundElevated;
return Padding(

View File

@@ -27,14 +27,15 @@ class InfoItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final children = <Widget>[];
if (title != null) {
children.addAll([
Text(
title!,
style: hasChipButtons
? getEnteTextTheme(context).miniMuted
: getEnteTextTheme(context).small,
? EnteTheme.getTextTheme(theme).miniMuted
: EnteTheme.getTextTheme(theme).small,
),
SizedBox(height: hasChipButtons ? 8 : 4),
]);
@@ -61,7 +62,7 @@ class InfoItemWidget extends StatelessWidget {
child = EnteLoadingWidget(
padding: biggerSpinner ? 6 : 3,
size: biggerSpinner ? 20 : 11,
color: getEnteColorScheme(context).strokeMuted,
color: EnteTheme.getColorScheme(theme).strokeMuted,
alignment:
biggerSpinner ? Alignment.center : Alignment.centerLeft,
);

View File

@@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import "package:flutter/material.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/effects.dart";
import 'package:photos/theme/ente_theme.dart';
@@ -19,8 +20,9 @@ class KeyboardTopButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final enteTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final enteTheme = EnteTheme.getTextTheme(theme);
final colorScheme = EnteTheme.getColorScheme(theme);
return Container(
width: double.infinity,
decoration: BoxDecoration(

View File

@@ -55,7 +55,8 @@ class _TrailingWidgetState extends State<TrailingWidget> {
}
void _executionStateListener() {
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
setState(() {
if (widget.executionStateNotifier.value == ExecutionState.idle) {
_setTrailingIcon();
@@ -78,6 +79,7 @@ class _TrailingWidgetState extends State<TrailingWidget> {
}
void _setTrailingIcon() {
final theme = Theme.of(context);
if (widget.trailingIcon != null) {
trailingWidget = Padding(
padding: EdgeInsets.only(
@@ -86,7 +88,7 @@ class _TrailingWidgetState extends State<TrailingWidget> {
child: Icon(
widget.trailingIcon,
color: widget.trailingIconIsMuted
? getEnteColorScheme(context).strokeMuted
? EnteTheme.getColorScheme(theme).strokeMuted
: widget.trailingIconColor,
),
);
@@ -147,6 +149,7 @@ class LeadingWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.only(right: 10),
child: SizedBox(
@@ -164,7 +167,7 @@ class LeadingWidget extends StatelessWidget {
child: Icon(
leadingIcon,
color: leadingIconColor ??
getEnteColorScheme(context).strokeBase,
EnteTheme.getColorScheme(theme).strokeBase,
),
),
),

View File

@@ -251,6 +251,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
}
void _onTapDown(details) {
final theme = Theme.of(context);
if (executionStateNotifier.value == ExecutionState.inProgress ||
executionStateNotifier.value == ExecutionState.successful) {
return;
@@ -258,7 +259,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
setState(() {
if (widget.pressedColor == null) {
hasPassedGestureCallbacks()
? menuItemColor = getEnteColorScheme(context).fillFaintPressed
? menuItemColor = EnteTheme.getColorScheme(theme).fillFaintPressed
: menuItemColor = widget.menuItemColor;
} else {
menuItemColor = widget.pressedColor;

View File

@@ -7,14 +7,15 @@ class MenuSectionDescriptionWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
child: Text(
content,
textAlign: TextAlign.left,
style: getEnteTextTheme(context)
style: EnteTheme.getTextTheme(theme)
.mini
.copyWith(color: getEnteColorScheme(context).textMuted),
.copyWith(color: EnteTheme.getColorScheme(theme).textMuted),
),
);
}

View File

@@ -1,3 +1,4 @@
import "package:flutter/material.dart";
import 'package:flutter/widgets.dart';
import 'package:photos/theme/ente_theme.dart';
@@ -9,7 +10,8 @@ class MenuSectionTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return Padding(
padding: const EdgeInsets.only(left: 8, top: 6, bottom: 6),
child: Row(
@@ -24,7 +26,7 @@ class MenuSectionTitle extends StatelessWidget {
iconData != null ? const SizedBox(width: 8) : const SizedBox.shrink(),
Text(
title,
style: getEnteTextTheme(context).small.copyWith(
style: EnteTheme.getTextTheme(theme).small.copyWith(
color: colorScheme.textMuted,
),
),

View File

@@ -41,8 +41,9 @@ class NotificationWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
EnteTextTheme textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
EnteTextTheme textTheme = EnteTheme.getTextTheme(theme);
TextStyle mainTextStyle = this.mainTextStyle ?? darkTextTheme.bodyBold;
TextStyle subTextStyle = darkTextTheme.miniMuted;
LinearGradient? backgroundGradient;
@@ -54,7 +55,7 @@ class NotificationWidget extends StatelessWidget {
backgroundColor = warning500;
break;
case NotificationType.banner:
textTheme = getEnteTextTheme(context);
textTheme = EnteTheme.getTextTheme(theme);
backgroundColor = colorScheme.backgroundElevated2;
mainTextStyle = textTheme.bodyBold;
subTextStyle = textTheme.miniMuted;
@@ -70,26 +71,26 @@ class NotificationWidget extends StatelessWidget {
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
);
boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;
boxShadow = theme.colorScheme.enteTheme.shadowMenu;
break;
case NotificationType.greenBanner:
backgroundGradient = LinearGradient(
colors: [
getEnteColorScheme(context).primary700,
getEnteColorScheme(context).primary500,
EnteTheme.getColorScheme(theme).primary700,
EnteTheme.getColorScheme(theme).primary500,
],
stops: const [0.25, 1],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
);
boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;
boxShadow = theme.colorScheme.enteTheme.shadowMenu;
break;
case NotificationType.notice:
backgroundColor = colorScheme.backgroundElevated2;
mainTextStyle = textTheme.bodyBold;
subTextStyle = textTheme.miniMuted;
strokeColorScheme = colorScheme;
boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;
boxShadow = theme.colorScheme.enteTheme.shadowMenu;
break;
}
return Center(
@@ -186,8 +187,9 @@ class NotificationTipWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
return Container(
padding: const EdgeInsets.fromLTRB(16, 12, 12, 12),
decoration: BoxDecoration(
@@ -223,8 +225,9 @@ class NotificationNoteWidget extends StatelessWidget {
const NotificationNoteWidget(this.note, {super.key});
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(

View File

@@ -56,7 +56,8 @@ class _SearchableAppBarState extends State<SearchableAppBar> {
@override
Widget build(BuildContext context) {
final isLightMode = Theme.of(context).brightness == Brightness.light;
final theme = Theme.of(context);
final isLightMode = !EnteTheme.isDark(theme);
return SliverAppBar(
floating: true,
elevation: 0,
@@ -103,7 +104,8 @@ class _SearchableAppBarState extends State<SearchableAppBar> {
}
Widget _buildSearchField() {
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
return Container(
key: const ValueKey('searchBar'),
alignment: Alignment.center,

View File

@@ -146,8 +146,9 @@ class _TextInputWidgetState extends State<TextInputWidget> {
}
});
}
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textTheme = EnteTheme.getTextTheme(theme);
var textInputChildren = <Widget>[];
if (widget.label != null) {
textInputChildren.add(Text(widget.label!));
@@ -438,7 +439,8 @@ class SuffixIconWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Widget? trailingWidget;
final colorScheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
if (executionState == ExecutionState.idle ||
!shouldSurfaceExecutionStates) {
if (isClearable) {

View File

@@ -18,8 +18,9 @@ class TitleBarTitleWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorTheme = getEnteColorScheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
final colorTheme = EnteTheme.getColorScheme(theme);
if (title != null) {
late final Widget widget;
if (icon != null) {

View File

@@ -164,7 +164,8 @@ class TitleWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
return Padding(
padding: EdgeInsets.only(left: isTitleH2WithoutLeading ? 16 : 0),
child: Column(
@@ -207,7 +208,8 @@ class FlexibleSpaceBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final theme = Theme.of(context);
final textTheme = EnteTheme.getTextTheme(theme);
return FlexibleSpaceBar(
background: SafeArea(
child: Column(

View File

@@ -34,7 +34,8 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
@override
Widget build(BuildContext context) {
final enteColorScheme = Theme.of(context).colorScheme.enteTheme.colorScheme;
final theme = Theme.of(context);
final enteColorScheme = theme.colorScheme.enteTheme.colorScheme;
final Widget stateIcon = _stateIcon(enteColorScheme);
return Row(

View File

@@ -50,8 +50,9 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textStyle = EnteTheme.getTextTheme(theme);
textFieldFocusNode.requestFocus();
return Scaffold(
body: CustomScrollView(
@@ -153,19 +154,20 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
}
Widget _getInputField() {
final theme = Theme.of(context);
return TextFormField(
controller: _textController,
focusNode: textFieldFocusNode,
style: getEnteTextTheme(context).body,
style: EnteTheme.getTextTheme(theme).body,
inputFormatters: [UpperCaseTextFormatter()],
textCapitalization: TextCapitalization.sentences,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
borderSide:
BorderSide(color: getEnteColorScheme(context).strokeMuted),
BorderSide(color: EnteTheme.getColorScheme(theme).strokeMuted),
),
fillColor: getEnteColorScheme(context).fillFaint,
fillColor: EnteTheme.getColorScheme(theme).fillFaint,
filled: true,
hintText: AppLocalizations.of(context).enterReferralCode,
contentPadding: const EdgeInsets.symmetric(

View File

@@ -22,8 +22,9 @@ class CodeSuccessScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textStyle = EnteTheme.getTextTheme(theme);
return Scaffold(
body: CustomScrollView(
primary: false,
@@ -74,8 +75,7 @@ class CodeSuccessScreen extends StatelessWidget {
),
Text(
AppLocalizations.of(context).storageInGB(
storageAmountInGB:
referralView.planInfo.storageInGB,
referralView.planInfo.storageInGB,
),
style: textStyle.h2Bold,
),
@@ -109,9 +109,8 @@ class CodeSuccessScreen extends StatelessWidget {
shareText(
AppLocalizations.of(context)
.shareTextReferralCode(
referralCode: referralView.code,
referralStorageInGB:
referralView.planInfo.storageInGB,
referralView.code,
referralView.planInfo.storageInGB,
),
);
},
@@ -140,8 +139,7 @@ class CodeSuccessScreen extends StatelessWidget {
Text(
AppLocalizations.of(context)
.freeStorageOnReferralSuccess(
storageAmountInGB:
referralView.planInfo.storageInGB,
referralView.planInfo.storageInGB,
),
style: textStyle.smallMuted,
textAlign: TextAlign.center,
@@ -151,8 +149,7 @@ class CodeSuccessScreen extends StatelessWidget {
const SizedBox(height: 16),
Text(
AppLocalizations.of(context).theyAlsoGetXGb(
storageAmountInGB:
referralView.planInfo.storageInGB,
referralView.planInfo.storageInGB,
),
style: textStyle.smallMuted,
textAlign: TextAlign.center,

View File

@@ -25,8 +25,9 @@ class ReferralCodeWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textStyle = EnteTheme.getTextTheme(theme);
return Center(
child: Container(
color: colorScheme.backgroundElevated2,
@@ -65,9 +66,7 @@ class ReferralCodeWidget extends StatelessWidget {
context,
title: AppLocalizations.of(context).error,
body: AppLocalizations.of(context)
.onlyFamilyAdminCanChangeCode(
familyAdminEmail: familyAdmin,
),
.onlyFamilyAdminCanChangeCode(familyAdmin),
icon: Icons.error,
);
} else {

View File

@@ -129,8 +129,9 @@ class ReferralWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textStyle = getEnteTextTheme(context);
final theme = Theme.of(context);
final colorScheme = EnteTheme.getColorScheme(theme);
final textStyle = EnteTheme.getTextTheme(theme);
final bool isReferralEnabled = referralView.planInfo.isEnabled;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -141,8 +142,8 @@ class ReferralWidget extends StatelessWidget {
onTap: () {
shareText(
AppLocalizations.of(context).shareTextReferralCode(
referralCode: referralView.code,
referralStorageInGB: referralView.planInfo.storageInGB,
referralView.code,
referralView.planInfo.storageInGB,
),
);
},
@@ -182,7 +183,7 @@ class ReferralWidget extends StatelessWidget {
const SizedBox(height: 12),
Text(
AppLocalizations.of(context).referralStep3(
storageInGB: referralView.planInfo.storageInGB,
referralView.planInfo.storageInGB,
),
),
],
@@ -291,10 +292,8 @@ class ReferralWidget extends StatelessWidget {
),
child: Text(
AppLocalizations.of(context).claimedStorageSoFar(
isFamilyMember:
referralView.isFamilyMember.toString().toLowerCase(),
storageAmountInGb:
convertBytesToAbsoluteGBs(referralView.claimedStorage),
referralView.isFamilyMember.toString().toLowerCase(),
convertBytesToAbsoluteGBs(referralView.claimedStorage),
),
style: textStyle.small.copyWith(
color: colorScheme.textMuted,

Some files were not shown because too many files have changed in this diff Show More