Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][locker] Migrate empty and search states to component theme

aman-pilot08a39c9e4a8e
diff --git a/mobile/apps/locker/lib/ui/components/home_empty_state_widget.dart b/mobile/apps/locker/lib/ui/components/home_empty_state_widget.dart
index c83581c8ef..2c33546423 100644
--- a/mobile/apps/locker/lib/ui/components/home_empty_state_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/home_empty_state_widget.dart
@@ -1,5 +1,5 @@
import "package:dotted_border/dotted_border.dart";
-import "package:ente_ui/theme/ente_theme.dart";
+import "package:ente_components/ente_components.dart";
import "package:flutter/material.dart";
import 'package:locker/l10n/l10n.dart';
@@ -10,24 +10,20 @@ class HomeEmptyStateWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
return isLoading
- ? CircularProgressIndicator(
- strokeWidth: 3,
- color: colorScheme.primary700,
- )
+ ? CircularProgressIndicator(strokeWidth: 3, color: colors.primary)
: DottedBorder(
options: RoundedRectDottedBorderOptions(
strokeWidth: 1,
- color: colorScheme.textFaint,
+ color: colors.textLighter,
dashPattern: const [5, 5],
radius: const Radius.circular(24),
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
- color: colorScheme.backdropBase,
+ color: colors.fillLight,
borderRadius: BorderRadius.circular(24),
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 42),
@@ -37,17 +33,12 @@ class HomeEmptyStateWidget extends StatelessWidget {
children: [
Image.asset('assets/upload_file.png'),
const SizedBox(height: 12),
- Text(
- context.l10n.homeLockerEmptyTitle,
- style: textTheme.h3Bold.copyWith(
- color: colorScheme.textBase,
- ),
- ),
+ Text(context.l10n.homeLockerEmptyTitle, style: TextStyles.h2),
const SizedBox(height: 8),
Text(
context.l10n.homeLockerEmptySubtitle,
- style: textTheme.small.copyWith(
- color: colorScheme.primary700,
+ style: TextStyles.body.copyWith(
+ color: colors.primary,
decoration: TextDecoration.none,
),
),
diff --git a/mobile/apps/locker/lib/ui/mixins/search_mixin.dart b/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
index a3189545c1..ace085b11c 100644
--- a/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
+++ b/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
@@ -1,6 +1,6 @@
import 'dart:async';
-import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:locker/extensions/collection_extension.dart';
@@ -48,6 +48,7 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
}
Widget buildSearchAction() {
+ final colors = context.componentColors;
if (_isSearchActive) {
return Flexible(
child: Container(
@@ -63,17 +64,13 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
onChanged: _onSearchChanged,
decoration: InputDecoration(
hintText: context.l10n.searchHint,
- hintStyle: TextStyle(
- color: Theme.of(
- context,
- ).textTheme.bodyMedium?.color?.withValues(alpha: 0.6),
- ),
+ hintStyle: TextStyles.body.copyWith(color: colors.textLight),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: BorderSide.none,
),
filled: true,
- fillColor: getEnteColorScheme(context).backdropBase,
+ fillColor: context.componentColors.fillLight,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
@@ -86,24 +83,13 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
- Theme.of(context).textTheme.bodyMedium?.color
- ?.withValues(alpha: 0.6) ??
- Colors.grey,
+ colors.textLight,
),
),
)
- : Icon(
- Icons.search,
- size: 20,
- color: Theme.of(
- context,
- ).textTheme.bodyMedium?.color?.withValues(alpha: 0.6),
- ),
- ),
- style: TextStyle(
- fontSize: 14,
- color: Theme.of(context).textTheme.bodyMedium?.color,
+ : Icon(Icons.search, size: 20, color: colors.textLight),
),
+ style: TextStyles.body,
),
),
);
@@ -327,6 +313,9 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
bool get isSearchActive => _isSearchActive;
bool get isSearching => _isSearching;
TextEditingController get searchController => _searchController;
+ FocusNode get searchFocusNode => _searchFocusNode;
+
+ void updateSearchQuery(String query) => _onSearchChanged(query);
/// Programmatically activate search with a specific query
void activateSearchWithQuery(String query) {
diff --git a/mobile/packages/ente_components/lib/theme/theme.dart b/mobile/packages/ente_components/lib/theme/theme.dart
index 427230d7a0..10d16347ea 100644
--- a/mobile/packages/ente_components/lib/theme/theme.dart
+++ b/mobile/packages/ente_components/lib/theme/theme.dart
@@ -69,6 +69,10 @@ class ComponentTheme {
labelMedium: TextStyles.mini,
labelSmall: TextStyles.tiny,
),
+ dialogTheme: DialogThemeData(
+ backgroundColor: colors.fillLight,
+ surfaceTintColor: Colors.transparent,
+ ),
extensions: [ComponentColorTokens(colors)],
);
}