Skip to content

Commit 70e9433

Browse files
Update profile screen to use dynamic theme settings
- Integrated ThemeSettingsProvider in profile screen - Replaced hardcoded colors and background with dynamic theme settings - Added support for both asset and network background images - Updated UI elements to use theme-specific colors - Removed unused configuration files (app_url.dart and exceptions.dart)
1 parent 51ca3d4 commit 70e9433

File tree

4 files changed

+46
-47
lines changed

4 files changed

+46
-47
lines changed

lib/configs/app_url.dart

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/configs/exceptions.dart

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/data/view/profile/profile_screen.dart

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '../../../configs/routes/routes_name.dart';
99
import '../../services/shared_prefs_service.dart';
1010
import '../../providers/chat_provider.dart';
1111
import '../../../data/view/settings/theme_settings_screen.dart';
12+
import '../../providers/theme_settings_provider.dart';
1213

1314
class ProfileScreen extends ConsumerStatefulWidget {
1415
const ProfileScreen({super.key});
@@ -20,7 +21,8 @@ class ProfileScreen extends ConsumerStatefulWidget {
2021
class _ProfileScreenState extends ConsumerState<ProfileScreen> {
2122
@override
2223
Widget build(BuildContext context) {
23-
final chats = ref.watch(chatProvider); // Get chats from provider
24+
final chats = ref.watch(chatProvider);
25+
final themeSettings = ref.watch(themeSettingsProvider);
2426

2527
// Calculate stats
2628
final totalChats = chats.length;
@@ -39,20 +41,33 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
3941
),
4042
body: Stack(
4143
children: [
42-
// Background Image with error handling
44+
// Updated Background Image
4345
Positioned.fill(
44-
child: CachedNetworkImage(
45-
imageUrl: '${AppImages.profileBg}?auto=format&fit=crop&w=800&q=80',
46-
fit: BoxFit.cover,
47-
color: Colors.black.withOpacity(0.7),
48-
colorBlendMode: BlendMode.darken,
49-
errorWidget: (context, url, error) => Container(
50-
color: Theme.of(context).scaffoldBackgroundColor,
51-
),
52-
placeholder: (context, url) => Container(
53-
color: Theme.of(context).scaffoldBackgroundColor,
54-
),
55-
),
46+
child: themeSettings.backgroundImage.startsWith('assets/')
47+
? Container(
48+
decoration: BoxDecoration(
49+
image: DecorationImage(
50+
image: AssetImage(themeSettings.backgroundImage),
51+
fit: BoxFit.cover,
52+
colorFilter: ColorFilter.mode(
53+
Colors.black.withOpacity(0.7),
54+
BlendMode.darken,
55+
),
56+
),
57+
),
58+
)
59+
: CachedNetworkImage(
60+
imageUrl: themeSettings.backgroundImage,
61+
fit: BoxFit.cover,
62+
color: Colors.black.withOpacity(0.7),
63+
colorBlendMode: BlendMode.darken,
64+
errorWidget: (context, url, error) => Container(
65+
color: Theme.of(context).scaffoldBackgroundColor,
66+
),
67+
placeholder: (context, url) => Container(
68+
color: Theme.of(context).scaffoldBackgroundColor,
69+
),
70+
),
5671
),
5772
// Content
5873
SafeArea(
@@ -70,7 +85,7 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
7085
decoration: BoxDecoration(
7186
shape: BoxShape.circle,
7287
border: Border.all(
73-
color: AppTheme.primaryColor,
88+
color: themeSettings.primaryColor,
7489
width: 3,
7590
),
7691
),
@@ -89,8 +104,8 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
89104
bottom: 0,
90105
child: Container(
91106
padding: const EdgeInsets.all(4),
92-
decoration: const BoxDecoration(
93-
color: AppTheme.primaryColor,
107+
decoration: BoxDecoration(
108+
color: themeSettings.primaryColor,
94109
shape: BoxShape.circle,
95110
),
96111
child: const Icon(
@@ -155,10 +170,11 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
155170
}
156171

157172
Widget _buildStatItem(String label, String value) {
173+
final themeSettings = ref.watch(themeSettingsProvider);
158174
return Container(
159175
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
160176
decoration: BoxDecoration(
161-
color: Colors.white.withOpacity(0.1),
177+
color: themeSettings.systemBubbleColor.withOpacity(0.1),
162178
borderRadius: BorderRadius.circular(16),
163179
),
164180
child: Column(
@@ -306,13 +322,15 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
306322
required String title,
307323
required VoidCallback onTap,
308324
}) {
325+
final themeSettings = ref.watch(themeSettingsProvider);
309326
return ListTile(
310-
leading: Icon(icon, color: Colors.white70),
327+
tileColor: themeSettings.systemBubbleColor.withOpacity(0.1),
328+
leading: Icon(icon, color: themeSettings.primaryColor),
311329
title: Text(
312330
title,
313-
style: const TextStyle(color: Colors.white),
331+
style: TextStyle(color: themeSettings.primaryColor),
314332
),
315-
trailing: const Icon(Icons.chevron_right, color: Colors.white70),
333+
trailing: Icon(Icons.chevron_right, color: themeSettings.primaryColor),
316334
onTap: onTap,
317335
);
318336
}

lib/data/view/settings/theme_settings_screen.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ class _ThemeSettingsScreenState extends ConsumerState<ThemeSettingsScreen> {
145145
_buildColorButton(
146146
color: settings.userBubbleColor,
147147
label: 'User Bubble',
148-
onTap: () => ref.read(themeSettingsProvider.notifier).updateThemeColors(
149-
userBubbleColor: settings.userBubbleColor,
150-
),
148+
onTap: () => _pickColor(
149+
context,
150+
settings.userBubbleColor,
151+
(color) => ref.read(themeSettingsProvider.notifier).updateThemeColors(
152+
userBubbleColor: color,
153+
),
154+
),
151155
),
152156
],
153157
),

0 commit comments

Comments
 (0)