Reapply "Добавил кастомизацию+, убрал жесты потому что они мне жизнь сломали"
This reverts commit e5beed10d9.
This commit is contained in:
@@ -2000,10 +2000,40 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
if (widget.hasScaffold) {
|
if (widget.hasScaffold) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
final theme = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
|
BoxDecoration? chatsListDecoration;
|
||||||
|
if (theme.chatsListBackgroundType == ChatsListBackgroundType.gradient) {
|
||||||
|
chatsListDecoration = BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
theme.chatsListGradientColor1,
|
||||||
|
theme.chatsListGradientColor2,
|
||||||
|
],
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (theme.chatsListBackgroundType == ChatsListBackgroundType.image &&
|
||||||
|
theme.chatsListImagePath != null &&
|
||||||
|
theme.chatsListImagePath!.isNotEmpty) {
|
||||||
|
chatsListDecoration = BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: FileImage(File(theme.chatsListImagePath!)),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: _buildAppBar(context),
|
appBar: _buildAppBar(context),
|
||||||
drawer: _buildAppDrawer(context),
|
drawer: _buildAppDrawer(context),
|
||||||
body: Row(children: [Expanded(child: bodyContent)]),
|
body: chatsListDecoration != null
|
||||||
|
? Container(
|
||||||
|
decoration: chatsListDecoration,
|
||||||
|
child: Row(children: [Expanded(child: bodyContent)]),
|
||||||
|
)
|
||||||
|
: Row(children: [Expanded(child: bodyContent)]),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_showAddMenu(context);
|
_showAddMenu(context);
|
||||||
@@ -2048,7 +2078,30 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
right: 16.0,
|
right: 16.0,
|
||||||
bottom: 16.0,
|
bottom: 16.0,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(color: colors.primaryContainer),
|
decoration: () {
|
||||||
|
if (themeProvider.drawerBackgroundType == DrawerBackgroundType.gradient) {
|
||||||
|
return BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
themeProvider.drawerGradientColor1,
|
||||||
|
themeProvider.drawerGradientColor2,
|
||||||
|
],
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (themeProvider.drawerBackgroundType == DrawerBackgroundType.image &&
|
||||||
|
themeProvider.drawerImagePath != null &&
|
||||||
|
themeProvider.drawerImagePath!.isNotEmpty) {
|
||||||
|
return BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: FileImage(File(themeProvider.drawerImagePath!)),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return BoxDecoration(color: colors.primaryContainer);
|
||||||
|
}(),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -2273,7 +2326,20 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|
||||||
ListTile(
|
Container(
|
||||||
|
decoration: themeProvider.useGradientForAddAccountButton
|
||||||
|
? BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
themeProvider.addAccountButtonGradientColor1,
|
||||||
|
themeProvider.addAccountButtonGradientColor2,
|
||||||
|
],
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
child: ListTile(
|
||||||
leading: const Icon(Icons.add_circle_outline),
|
leading: const Icon(Icons.add_circle_outline),
|
||||||
title: const Text('Добавить аккаунт'),
|
title: const Text('Добавить аккаунт'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -2286,6 +2352,7 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
@@ -2296,22 +2363,23 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: () {
|
||||||
|
final menuColumn = Column(
|
||||||
children: [
|
children: [
|
||||||
_buildAccountsSection(context, colors),
|
_buildAccountsSection(context, colors),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.person_outline),
|
leading: const Icon(Icons.person_outline),
|
||||||
title: const Text('Мой профиль'),
|
title: const Text('Мой профиль'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context); // Закрыть Drawer
|
Navigator.pop(context);
|
||||||
_navigateToProfileEdit(); // Этот метод у вас уже есть
|
_navigateToProfileEdit();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.call_outlined),
|
leading: const Icon(Icons.call_outlined),
|
||||||
title: const Text('Звонки'),
|
title: const Text('Звонки'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context); // Закрыть Drawer
|
Navigator.pop(context);
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => const CallsScreen(),
|
builder: (context) => const CallsScreen(),
|
||||||
@@ -2428,22 +2496,50 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
||||||
const Divider(height: 1, indent: 16, endIndent: 16),
|
const Divider(height: 1, indent: 16, endIndent: 16),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.logout, color: colors.error),
|
leading: Icon(Icons.logout, color: colors.error),
|
||||||
title: Text('Выйти', style: TextStyle(color: colors.error)),
|
title: Text('Выйти', style: TextStyle(color: colors.error)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context); // Закрыть Drawer
|
Navigator.pop(context);
|
||||||
_showLogoutDialog();
|
_showLogoutDialog();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8), // Небольшой отступ снизу
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (themeProvider.drawerBackgroundType == DrawerBackgroundType.gradient) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
themeProvider.drawerGradientColor2,
|
||||||
|
themeProvider.drawerGradientColor1,
|
||||||
|
],
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
child: menuColumn,
|
||||||
|
);
|
||||||
|
} else if (themeProvider.drawerBackgroundType == DrawerBackgroundType.image &&
|
||||||
|
themeProvider.drawerImagePath != null &&
|
||||||
|
themeProvider.drawerImagePath!.isNotEmpty) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: FileImage(File(themeProvider.drawerImagePath!)),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: menuColumn,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return menuColumn;
|
||||||
|
}(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -3035,9 +3131,41 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final themeProvider = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
|
BoxDecoration? folderTabsDecoration;
|
||||||
|
if (themeProvider.folderTabsBackgroundType == FolderTabsBackgroundType.gradient) {
|
||||||
|
folderTabsDecoration = BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
themeProvider.folderTabsGradientColor1,
|
||||||
|
themeProvider.folderTabsGradientColor2,
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: colors.outline.withOpacity(0.2), width: 1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (themeProvider.folderTabsBackgroundType == FolderTabsBackgroundType.image &&
|
||||||
|
themeProvider.folderTabsImagePath != null &&
|
||||||
|
themeProvider.folderTabsImagePath!.isNotEmpty) {
|
||||||
|
folderTabsDecoration = BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: FileImage(File(themeProvider.folderTabsImagePath!)),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: colors.outline.withOpacity(0.2), width: 1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 48,
|
height: 48,
|
||||||
decoration: BoxDecoration(
|
decoration: folderTabsDecoration ??
|
||||||
|
BoxDecoration(
|
||||||
color: colors.surface,
|
color: colors.surface,
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: colors.outline.withOpacity(0.2), width: 1),
|
bottom: BorderSide(color: colors.outline.withOpacity(0.2), width: 1),
|
||||||
@@ -3751,9 +3879,36 @@ class _ChatsScreenState extends State<ChatsScreen>
|
|||||||
|
|
||||||
AppBar _buildAppBar(BuildContext context) {
|
AppBar _buildAppBar(BuildContext context) {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
final themeProvider = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
|
BoxDecoration? appBarDecoration;
|
||||||
|
if (themeProvider.appBarBackgroundType == AppBarBackgroundType.gradient) {
|
||||||
|
appBarDecoration = BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
themeProvider.appBarGradientColor1,
|
||||||
|
themeProvider.appBarGradientColor2,
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (themeProvider.appBarBackgroundType == AppBarBackgroundType.image &&
|
||||||
|
themeProvider.appBarImagePath != null &&
|
||||||
|
themeProvider.appBarImagePath!.isNotEmpty) {
|
||||||
|
appBarDecoration = BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: FileImage(File(themeProvider.appBarImagePath!)),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return AppBar(
|
return AppBar(
|
||||||
titleSpacing: 4.0,
|
titleSpacing: 4.0,
|
||||||
|
flexibleSpace: appBarDecoration != null
|
||||||
|
? Container(decoration: appBarDecoration)
|
||||||
|
: null,
|
||||||
|
|
||||||
leading: _isSearchExpanded
|
leading: _isSearchExpanded
|
||||||
? IconButton(
|
? IconButton(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:gwid/screens/settings/settings_screen.dart';
|
|||||||
import 'package:gwid/screens/phone_entry_screen.dart';
|
import 'package:gwid/screens/phone_entry_screen.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:gwid/utils/theme_provider.dart';
|
import 'package:gwid/utils/theme_provider.dart';
|
||||||
|
import 'package:gwid/api/api_service.dart';
|
||||||
|
|
||||||
class ProfileMenuDialog extends StatefulWidget {
|
class ProfileMenuDialog extends StatefulWidget {
|
||||||
final Profile? myProfile;
|
final Profile? myProfile;
|
||||||
@@ -195,6 +196,9 @@ class _ProfileMenuDialogState extends State<ProfileMenuDialog> {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
try {
|
||||||
|
await ApiService.instance.logout();
|
||||||
|
if (context.mounted) {
|
||||||
Navigator.of(context).pushAndRemoveUntil(
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => const PhoneEntryScreen(),
|
builder: (_) => const PhoneEntryScreen(),
|
||||||
@@ -202,6 +206,17 @@ class _ProfileMenuDialogState extends State<ProfileMenuDialog> {
|
|||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Ошибка при выходе: $e'),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
|
|||||||
@@ -242,7 +242,6 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
title: const Text("Выбрать видео"),
|
title: const Text("Выбрать видео"),
|
||||||
trailing: const Icon(Icons.chevron_right),
|
trailing: const Icon(Icons.chevron_right),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
|
||||||
final result = await FilePicker.platform.pickFiles(
|
final result = await FilePicker.platform.pickFiles(
|
||||||
type: FileType.video,
|
type: FileType.video,
|
||||||
);
|
);
|
||||||
@@ -292,7 +291,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
max: 1.0,
|
max: 1.0,
|
||||||
divisions: 18,
|
divisions: 18,
|
||||||
onChanged: (value) => theme.setMessageTextOpacity(value),
|
onChanged: (value) => theme.setMessageTextOpacity(value),
|
||||||
displayValue: "${(theme.messageTextOpacity * 100).round()}%",
|
displayValue:
|
||||||
|
"${(theme.messageTextOpacity * 100).round()}%",
|
||||||
),
|
),
|
||||||
_SliderTile(
|
_SliderTile(
|
||||||
icon: Icons.blur_circular,
|
icon: Icons.blur_circular,
|
||||||
@@ -301,7 +301,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
min: 0.0,
|
min: 0.0,
|
||||||
max: 0.5,
|
max: 0.5,
|
||||||
divisions: 10,
|
divisions: 10,
|
||||||
onChanged: (value) => theme.setMessageShadowIntensity(value),
|
onChanged: (value) =>
|
||||||
|
theme.setMessageShadowIntensity(value),
|
||||||
displayValue:
|
displayValue:
|
||||||
"${(theme.messageShadowIntensity * 100).round()}%",
|
"${(theme.messageShadowIntensity * 100).round()}%",
|
||||||
),
|
),
|
||||||
@@ -313,7 +314,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
max: 1.0,
|
max: 1.0,
|
||||||
divisions: 18,
|
divisions: 18,
|
||||||
onChanged: (value) => theme.setMessageMenuOpacity(value),
|
onChanged: (value) => theme.setMessageMenuOpacity(value),
|
||||||
displayValue: "${(theme.messageMenuOpacity * 100).round()}%",
|
displayValue:
|
||||||
|
"${(theme.messageMenuOpacity * 100).round()}%",
|
||||||
),
|
),
|
||||||
_SliderTile(
|
_SliderTile(
|
||||||
icon: Icons.blur_on,
|
icon: Icons.blur_on,
|
||||||
@@ -368,7 +370,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
value: theme.messageBubbleType,
|
value: theme.messageBubbleType,
|
||||||
underline: const SizedBox.shrink(),
|
underline: const SizedBox.shrink(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) theme.setMessageBubbleType(value);
|
if (value != null)
|
||||||
|
theme.setMessageBubbleType(value);
|
||||||
},
|
},
|
||||||
items: MessageBubbleType.values.map((type) {
|
items: MessageBubbleType.values.map((type) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
@@ -390,7 +393,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
opacity: isSystemTheme ? 0.5 : 1.0,
|
opacity: isSystemTheme ? 0.5 : 1.0,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final initial = myBubbleColorToShow ?? myBubbleFallback;
|
final initial =
|
||||||
|
myBubbleColorToShow ?? myBubbleFallback;
|
||||||
_showColorPicker(
|
_showColorPicker(
|
||||||
context,
|
context,
|
||||||
initialColor: initial,
|
initialColor: initial,
|
||||||
@@ -425,14 +429,16 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
_showColorPicker(
|
_showColorPicker(
|
||||||
context,
|
context,
|
||||||
initialColor: initial,
|
initialColor: initial,
|
||||||
onColorChanged: (color) => theirBubbleSetter(color),
|
onColorChanged: (color) =>
|
||||||
|
theirBubbleSetter(color),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: theirBubbleColorToShow ?? theirBubbleFallback,
|
color:
|
||||||
|
theirBubbleColorToShow ?? theirBubbleFallback,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: Colors.grey),
|
border: Border.all(color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -457,7 +463,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
title: "Цвет панели ответа",
|
title: "Цвет панели ответа",
|
||||||
subtitle: "Фиксированный цвет",
|
subtitle: "Фиксированный цвет",
|
||||||
color: theme.customReplyColor ?? Colors.blue,
|
color: theme.customReplyColor ?? Colors.blue,
|
||||||
onColorChanged: (color) => theme.setCustomReplyColor(color),
|
onColorChanged: (color) =>
|
||||||
|
theme.setCustomReplyColor(color),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -485,7 +492,8 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
max: 1.0,
|
max: 1.0,
|
||||||
divisions: 20,
|
divisions: 20,
|
||||||
onChanged: (value) => theme.setProfileDialogOpacity(value),
|
onChanged: (value) => theme.setProfileDialogOpacity(value),
|
||||||
displayValue: "${(theme.profileDialogOpacity * 100).round()}%",
|
displayValue:
|
||||||
|
"${(theme.profileDialogOpacity * 100).round()}%",
|
||||||
),
|
),
|
||||||
_SliderTile(
|
_SliderTile(
|
||||||
icon: Icons.blur_on,
|
icon: Icons.blur_on,
|
||||||
@@ -517,6 +525,323 @@ class _CustomizationScreenState extends State<CustomizationScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
_ExpandableSection(
|
||||||
|
title: "Кастомизация+",
|
||||||
|
initiallyExpanded: false,
|
||||||
|
children: [
|
||||||
|
_CustomSettingTile(
|
||||||
|
icon: Icons.format_color_fill,
|
||||||
|
title: "Фон списка чатов",
|
||||||
|
subtitle: "Выберите тип фона для списка чатов",
|
||||||
|
child: DropdownButton<ChatsListBackgroundType>(
|
||||||
|
value: theme.chatsListBackgroundType,
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value != null) theme.setChatsListBackgroundType(value);
|
||||||
|
},
|
||||||
|
items: ChatsListBackgroundType.values.map((type) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: type,
|
||||||
|
child: Text(type.displayName),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (theme.chatsListBackgroundType ==
|
||||||
|
ChatsListBackgroundType.gradient) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 1",
|
||||||
|
subtitle: "Начальный цвет градиента",
|
||||||
|
color: theme.chatsListGradientColor1,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setChatsListGradientColor1(color),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 2",
|
||||||
|
subtitle: "Конечный цвет градиента",
|
||||||
|
color: theme.chatsListGradientColor2,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setChatsListGradientColor2(color),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (theme.chatsListBackgroundType ==
|
||||||
|
ChatsListBackgroundType.image) ...[
|
||||||
|
const Divider(height: 24),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(Icons.photo_library_outlined),
|
||||||
|
title: const Text("Выбрать изображение"),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () async {
|
||||||
|
final picker = ImagePicker();
|
||||||
|
final image = await picker.pickImage(
|
||||||
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
theme.setChatsListImagePath(image.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (theme.chatsListImagePath?.isNotEmpty == true) ...[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
"Удалить изображение",
|
||||||
|
style: TextStyle(color: Colors.redAccent),
|
||||||
|
),
|
||||||
|
onTap: () => theme.setChatsListImagePath(null),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
const Divider(height: 24),
|
||||||
|
_CustomSettingTile(
|
||||||
|
icon: Icons.view_sidebar,
|
||||||
|
title: "Фон боковой панели",
|
||||||
|
subtitle: "Выберите тип фона для боковой панели",
|
||||||
|
child: DropdownButton<DrawerBackgroundType>(
|
||||||
|
value: theme.drawerBackgroundType,
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value != null) theme.setDrawerBackgroundType(value);
|
||||||
|
},
|
||||||
|
items: DrawerBackgroundType.values.map((type) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: type,
|
||||||
|
child: Text(type.displayName),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (theme.drawerBackgroundType ==
|
||||||
|
DrawerBackgroundType.gradient) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 1",
|
||||||
|
subtitle: "Начальный цвет градиента",
|
||||||
|
color: theme.drawerGradientColor1,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setDrawerGradientColor1(color),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 2",
|
||||||
|
subtitle: "Конечный цвет градиента",
|
||||||
|
color: theme.drawerGradientColor2,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setDrawerGradientColor2(color),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (theme.drawerBackgroundType == DrawerBackgroundType.image) ...[
|
||||||
|
const Divider(height: 24),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(Icons.photo_library_outlined),
|
||||||
|
title: const Text("Выбрать изображение"),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () async {
|
||||||
|
final picker = ImagePicker();
|
||||||
|
final image = await picker.pickImage(
|
||||||
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
theme.setDrawerImagePath(image.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (theme.drawerImagePath?.isNotEmpty == true) ...[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
"Удалить изображение",
|
||||||
|
style: TextStyle(color: Colors.redAccent),
|
||||||
|
),
|
||||||
|
onTap: () => theme.setDrawerImagePath(null),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
const Divider(height: 24),
|
||||||
|
_CustomSettingTile(
|
||||||
|
icon: Icons.person_add,
|
||||||
|
title: "Градиент для кнопки добавления аккаунта",
|
||||||
|
subtitle: "Применить градиент к кнопке в drawer",
|
||||||
|
child: Switch(
|
||||||
|
value: theme.useGradientForAddAccountButton,
|
||||||
|
onChanged: (value) =>
|
||||||
|
theme.setUseGradientForAddAccountButton(value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (theme.useGradientForAddAccountButton) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 1",
|
||||||
|
subtitle: "Начальный цвет градиента",
|
||||||
|
color: theme.addAccountButtonGradientColor1,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setAddAccountButtonGradientColor1(color),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 2",
|
||||||
|
subtitle: "Конечный цвет градиента",
|
||||||
|
color: theme.addAccountButtonGradientColor2,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setAddAccountButtonGradientColor2(color),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const Divider(height: 24),
|
||||||
|
_CustomSettingTile(
|
||||||
|
icon: Icons.view_headline,
|
||||||
|
title: "Фон верхней панели",
|
||||||
|
subtitle: "Выберите тип фона для AppBar (поиск, Сферум и т.д.)",
|
||||||
|
child: DropdownButton<AppBarBackgroundType>(
|
||||||
|
value: theme.appBarBackgroundType,
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value != null) theme.setAppBarBackgroundType(value);
|
||||||
|
},
|
||||||
|
items: AppBarBackgroundType.values.map((type) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: type,
|
||||||
|
child: Text(type.displayName),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (theme.appBarBackgroundType ==
|
||||||
|
AppBarBackgroundType.gradient) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 1",
|
||||||
|
subtitle: "Начальный цвет градиента",
|
||||||
|
color: theme.appBarGradientColor1,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setAppBarGradientColor1(color),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 2",
|
||||||
|
subtitle: "Конечный цвет градиента",
|
||||||
|
color: theme.appBarGradientColor2,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setAppBarGradientColor2(color),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (theme.appBarBackgroundType == AppBarBackgroundType.image) ...[
|
||||||
|
const Divider(height: 24),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(Icons.photo_library_outlined),
|
||||||
|
title: const Text("Выбрать изображение"),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () async {
|
||||||
|
final picker = ImagePicker();
|
||||||
|
final image = await picker.pickImage(
|
||||||
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
theme.setAppBarImagePath(image.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (theme.appBarImagePath?.isNotEmpty == true) ...[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
"Удалить изображение",
|
||||||
|
style: TextStyle(color: Colors.redAccent),
|
||||||
|
),
|
||||||
|
onTap: () => theme.setAppBarImagePath(null),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
const Divider(height: 24),
|
||||||
|
_CustomSettingTile(
|
||||||
|
icon: Icons.folder,
|
||||||
|
title: "Фон панели папок",
|
||||||
|
subtitle: "Выберите тип фона для панели с именами папок",
|
||||||
|
child: DropdownButton<FolderTabsBackgroundType>(
|
||||||
|
value: theme.folderTabsBackgroundType,
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value != null) theme.setFolderTabsBackgroundType(value);
|
||||||
|
},
|
||||||
|
items: FolderTabsBackgroundType.values.map((type) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: type,
|
||||||
|
child: Text(type.displayName),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (theme.folderTabsBackgroundType ==
|
||||||
|
FolderTabsBackgroundType.gradient) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 1",
|
||||||
|
subtitle: "Начальный цвет градиента",
|
||||||
|
color: theme.folderTabsGradientColor1,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setFolderTabsGradientColor1(color),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_ColorPickerTile(
|
||||||
|
title: "Цвет 2",
|
||||||
|
subtitle: "Конечный цвет градиента",
|
||||||
|
color: theme.folderTabsGradientColor2,
|
||||||
|
onColorChanged: (color) =>
|
||||||
|
theme.setFolderTabsGradientColor2(color),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (theme.folderTabsBackgroundType ==
|
||||||
|
FolderTabsBackgroundType.image) ...[
|
||||||
|
const Divider(height: 24),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(Icons.photo_library_outlined),
|
||||||
|
title: const Text("Выбрать изображение"),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () async {
|
||||||
|
final picker = ImagePicker();
|
||||||
|
final image = await picker.pickImage(
|
||||||
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
theme.setFolderTabsImagePath(image.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (theme.folderTabsImagePath?.isNotEmpty == true) ...[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
"Удалить изображение",
|
||||||
|
style: TextStyle(color: Colors.redAccent),
|
||||||
|
),
|
||||||
|
onTap: () => theme.setFolderTabsImagePath(null),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
_ModernSection(
|
_ModernSection(
|
||||||
title: "Панели чата",
|
title: "Панели чата",
|
||||||
children: [
|
children: [
|
||||||
@@ -1388,7 +1713,6 @@ class _ChatWallpaperPreview extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case ChatWallpaperType.video:
|
case ChatWallpaperType.video:
|
||||||
|
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return Container(
|
return Container(
|
||||||
color: isDarkTheme ? Colors.grey[850] : Colors.grey[200],
|
color: isDarkTheme ? Colors.grey[850] : Colors.grey[200],
|
||||||
@@ -1572,7 +1896,10 @@ class _ExpandableSectionState extends State<_ExpandableSection> {
|
|||||||
onTap: () => setState(() => _isExpanded = !_isExpanded),
|
onTap: () => setState(() => _isExpanded = !_isExpanded),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 4.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 12.0,
|
||||||
|
horizontal: 4.0,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
@@ -1591,10 +1918,7 @@ class _ExpandableSectionState extends State<_ExpandableSection> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_isExpanded) ...[
|
if (_isExpanded) ...[const SizedBox(height: 8), ...widget.children],
|
||||||
const SizedBox(height: 8),
|
|
||||||
...widget.children,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1646,10 +1970,7 @@ class _MessageBubblesPreview extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ChatMessageBubble(
|
child: ChatMessageBubble(message: mockMyMessage, isMe: true),
|
||||||
message: mockMyMessage,
|
|
||||||
isMe: true,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -1708,16 +2029,10 @@ class _DialogPreview extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colors.surface.withOpacity(theme.profileDialogOpacity),
|
color: colors.surface.withOpacity(theme.profileDialogOpacity),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(
|
border: Border.all(color: colors.outline.withOpacity(0.2)),
|
||||||
color: colors.outline.withOpacity(0.2),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Icon(
|
child: Icon(Icons.person, color: colors.onSurface, size: 32),
|
||||||
Icons.person,
|
|
||||||
color: colors.onSurface,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1831,7 +2146,9 @@ class _PanelsPreview extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
color: colors.surface.withOpacity(theme.bottomBarOpacity),
|
color: colors.surface.withOpacity(
|
||||||
|
theme.bottomBarOpacity,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
|
|||||||
@@ -40,11 +40,16 @@ class AvatarCacheService {
|
|||||||
final timestamp = _imageCacheTimestamps[cacheKey];
|
final timestamp = _imageCacheTimestamps[cacheKey];
|
||||||
if (timestamp != null && !_isExpired(timestamp, _imageTTL)) {
|
if (timestamp != null && !_isExpired(timestamp, _imageTTL)) {
|
||||||
final imageData = _imageMemoryCache[cacheKey]!;
|
final imageData = _imageMemoryCache[cacheKey]!;
|
||||||
|
if (_isValidImageData(imageData)) {
|
||||||
return MemoryImage(imageData);
|
return MemoryImage(imageData);
|
||||||
} else {
|
} else {
|
||||||
_imageMemoryCache.remove(cacheKey);
|
_imageMemoryCache.remove(cacheKey);
|
||||||
_imageCacheTimestamps.remove(cacheKey);
|
_imageCacheTimestamps.remove(cacheKey);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_imageMemoryCache.remove(cacheKey);
|
||||||
|
_imageCacheTimestamps.remove(cacheKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final cachedFile = await _cacheService.getCachedFile(
|
final cachedFile = await _cacheService.getCachedFile(
|
||||||
@@ -52,8 +57,9 @@ class AvatarCacheService {
|
|||||||
customKey: cacheKey,
|
customKey: cacheKey,
|
||||||
);
|
);
|
||||||
if (cachedFile != null && await cachedFile.exists()) {
|
if (cachedFile != null && await cachedFile.exists()) {
|
||||||
|
try {
|
||||||
final imageData = await cachedFile.readAsBytes();
|
final imageData = await cachedFile.readAsBytes();
|
||||||
|
if (_isValidImageData(imageData)) {
|
||||||
_imageMemoryCache[cacheKey] = imageData;
|
_imageMemoryCache[cacheKey] = imageData;
|
||||||
_imageCacheTimestamps[cacheKey] = DateTime.now();
|
_imageCacheTimestamps[cacheKey] = DateTime.now();
|
||||||
|
|
||||||
@@ -63,9 +69,13 @@ class AvatarCacheService {
|
|||||||
|
|
||||||
return MemoryImage(imageData);
|
return MemoryImage(imageData);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Ошибка чтения кешированного файла аватарки: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final imageData = await _downloadImage(avatarUrl);
|
final imageData = await _downloadImage(avatarUrl);
|
||||||
if (imageData != null) {
|
if (imageData != null && _isValidImageData(imageData)) {
|
||||||
await _cacheService.cacheFile(avatarUrl, customKey: cacheKey);
|
await _cacheService.cacheFile(avatarUrl, customKey: cacheKey);
|
||||||
|
|
||||||
_imageMemoryCache[cacheKey] = imageData;
|
_imageMemoryCache[cacheKey] = imageData;
|
||||||
@@ -73,6 +83,8 @@ class AvatarCacheService {
|
|||||||
|
|
||||||
return MemoryImage(imageData);
|
return MemoryImage(imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NetworkImage(avatarUrl);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Ошибка получения аватарки: $e');
|
print('Ошибка получения аватарки: $e');
|
||||||
}
|
}
|
||||||
@@ -111,6 +123,11 @@ class AvatarCacheService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_isValidImageData(imageData)) {
|
||||||
|
print('Невалидные данные изображения для $url');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -119,6 +136,34 @@ class AvatarCacheService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isValidImageData(Uint8List data) {
|
||||||
|
if (data.isEmpty) return false;
|
||||||
|
if (data.length < 4) return false;
|
||||||
|
|
||||||
|
final header = data.sublist(0, 4);
|
||||||
|
final pngHeader = [0x89, 0x50, 0x4E, 0x47];
|
||||||
|
final jpegHeader = [0xFF, 0xD8, 0xFF];
|
||||||
|
final gifHeader = [0x47, 0x49, 0x46, 0x38];
|
||||||
|
final webpHeader = [0x52, 0x49, 0x46, 0x46];
|
||||||
|
|
||||||
|
bool isValid = false;
|
||||||
|
if (header[0] == pngHeader[0] && header[1] == pngHeader[1] &&
|
||||||
|
header[2] == pngHeader[2] && header[3] == pngHeader[3]) {
|
||||||
|
isValid = true;
|
||||||
|
} else if (header[0] == jpegHeader[0] && header[1] == jpegHeader[1] &&
|
||||||
|
header[2] == jpegHeader[2]) {
|
||||||
|
isValid = true;
|
||||||
|
} else if (header[0] == gifHeader[0] && header[1] == gifHeader[1] &&
|
||||||
|
header[2] == gifHeader[2] && header[3] == gifHeader[3]) {
|
||||||
|
isValid = true;
|
||||||
|
} else if (header[0] == webpHeader[0] && header[1] == webpHeader[1] &&
|
||||||
|
header[2] == webpHeader[2] && header[3] == webpHeader[3]) {
|
||||||
|
isValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
String _generateCacheKey(String url, int? userId) {
|
String _generateCacheKey(String url, int? userId) {
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
return 'avatar_${userId}_${_hashUrl(url)}';
|
return 'avatar_${userId}_${_hashUrl(url)}';
|
||||||
|
|||||||
@@ -6,6 +6,14 @@ enum AppTheme { system, light, dark, black }
|
|||||||
|
|
||||||
enum ChatWallpaperType { solid, gradient, image, video }
|
enum ChatWallpaperType { solid, gradient, image, video }
|
||||||
|
|
||||||
|
enum FolderTabsBackgroundType { none, gradient, image }
|
||||||
|
|
||||||
|
enum DrawerBackgroundType { none, gradient, image }
|
||||||
|
|
||||||
|
enum ChatsListBackgroundType { none, gradient, image }
|
||||||
|
|
||||||
|
enum AppBarBackgroundType { none, gradient, image }
|
||||||
|
|
||||||
enum TransitionOption { systemDefault, slide }
|
enum TransitionOption { systemDefault, slide }
|
||||||
|
|
||||||
enum UIMode { both, burgerOnly, panelOnly }
|
enum UIMode { both, burgerOnly, panelOnly }
|
||||||
@@ -47,6 +55,58 @@ extension ChatWallpaperTypeExtension on ChatWallpaperType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension FolderTabsBackgroundTypeExtension on FolderTabsBackgroundType {
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case FolderTabsBackgroundType.none:
|
||||||
|
return 'Нет';
|
||||||
|
case FolderTabsBackgroundType.gradient:
|
||||||
|
return 'Градиент';
|
||||||
|
case FolderTabsBackgroundType.image:
|
||||||
|
return 'Фото';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension DrawerBackgroundTypeExtension on DrawerBackgroundType {
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case DrawerBackgroundType.none:
|
||||||
|
return 'Нет';
|
||||||
|
case DrawerBackgroundType.gradient:
|
||||||
|
return 'Градиент';
|
||||||
|
case DrawerBackgroundType.image:
|
||||||
|
return 'Фото';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ChatsListBackgroundTypeExtension on ChatsListBackgroundType {
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case ChatsListBackgroundType.none:
|
||||||
|
return 'Нет';
|
||||||
|
case ChatsListBackgroundType.gradient:
|
||||||
|
return 'Градиент';
|
||||||
|
case ChatsListBackgroundType.image:
|
||||||
|
return 'Фото';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AppBarBackgroundTypeExtension on AppBarBackgroundType {
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case AppBarBackgroundType.none:
|
||||||
|
return 'Нет';
|
||||||
|
case AppBarBackgroundType.gradient:
|
||||||
|
return 'Градиент';
|
||||||
|
case AppBarBackgroundType.image:
|
||||||
|
return 'Фото';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class CustomThemePreset {
|
class CustomThemePreset {
|
||||||
String id;
|
String id;
|
||||||
String name;
|
String name;
|
||||||
@@ -105,6 +165,30 @@ class CustomThemePreset {
|
|||||||
bool useAutoReplyColor;
|
bool useAutoReplyColor;
|
||||||
Color? customReplyColor;
|
Color? customReplyColor;
|
||||||
|
|
||||||
|
bool useGradientForChatsList;
|
||||||
|
ChatsListBackgroundType chatsListBackgroundType;
|
||||||
|
String? chatsListImagePath;
|
||||||
|
bool useGradientForDrawer;
|
||||||
|
DrawerBackgroundType drawerBackgroundType;
|
||||||
|
String? drawerImagePath;
|
||||||
|
bool useGradientForAddAccountButton;
|
||||||
|
bool useGradientForAppBar;
|
||||||
|
AppBarBackgroundType appBarBackgroundType;
|
||||||
|
String? appBarImagePath;
|
||||||
|
bool useGradientForFolderTabs;
|
||||||
|
FolderTabsBackgroundType folderTabsBackgroundType;
|
||||||
|
String? folderTabsImagePath;
|
||||||
|
Color chatsListGradientColor1;
|
||||||
|
Color chatsListGradientColor2;
|
||||||
|
Color drawerGradientColor1;
|
||||||
|
Color drawerGradientColor2;
|
||||||
|
Color addAccountButtonGradientColor1;
|
||||||
|
Color addAccountButtonGradientColor2;
|
||||||
|
Color appBarGradientColor1;
|
||||||
|
Color appBarGradientColor2;
|
||||||
|
Color folderTabsGradientColor1;
|
||||||
|
Color folderTabsGradientColor2;
|
||||||
|
|
||||||
CustomThemePreset({
|
CustomThemePreset({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
@@ -155,6 +239,29 @@ class CustomThemePreset {
|
|||||||
this.useDesktopLayout = true,
|
this.useDesktopLayout = true,
|
||||||
this.useAutoReplyColor = true,
|
this.useAutoReplyColor = true,
|
||||||
this.customReplyColor,
|
this.customReplyColor,
|
||||||
|
this.useGradientForChatsList = false,
|
||||||
|
this.chatsListBackgroundType = ChatsListBackgroundType.none,
|
||||||
|
this.chatsListImagePath,
|
||||||
|
this.useGradientForDrawer = false,
|
||||||
|
this.drawerBackgroundType = DrawerBackgroundType.none,
|
||||||
|
this.drawerImagePath,
|
||||||
|
this.useGradientForAddAccountButton = false,
|
||||||
|
this.useGradientForAppBar = false,
|
||||||
|
this.appBarBackgroundType = AppBarBackgroundType.none,
|
||||||
|
this.appBarImagePath,
|
||||||
|
this.useGradientForFolderTabs = false,
|
||||||
|
this.folderTabsBackgroundType = FolderTabsBackgroundType.none,
|
||||||
|
this.folderTabsImagePath,
|
||||||
|
this.chatsListGradientColor1 = const Color(0xFF1E1E1E),
|
||||||
|
this.chatsListGradientColor2 = const Color(0xFF2D2D2D),
|
||||||
|
this.drawerGradientColor1 = const Color(0xFF1E1E1E),
|
||||||
|
this.drawerGradientColor2 = const Color(0xFF2D2D2D),
|
||||||
|
this.addAccountButtonGradientColor1 = const Color(0xFF1E1E1E),
|
||||||
|
this.addAccountButtonGradientColor2 = const Color(0xFF2D2D2D),
|
||||||
|
this.appBarGradientColor1 = const Color(0xFF1E1E1E),
|
||||||
|
this.appBarGradientColor2 = const Color(0xFF2D2D2D),
|
||||||
|
this.folderTabsGradientColor1 = const Color(0xFF1E1E1E),
|
||||||
|
this.folderTabsGradientColor2 = const Color(0xFF2D2D2D),
|
||||||
});
|
});
|
||||||
|
|
||||||
factory CustomThemePreset.createDefault() {
|
factory CustomThemePreset.createDefault() {
|
||||||
@@ -211,6 +318,29 @@ class CustomThemePreset {
|
|||||||
bool? useDesktopLayout,
|
bool? useDesktopLayout,
|
||||||
bool? useAutoReplyColor,
|
bool? useAutoReplyColor,
|
||||||
Color? customReplyColor,
|
Color? customReplyColor,
|
||||||
|
bool? useGradientForChatsList,
|
||||||
|
ChatsListBackgroundType? chatsListBackgroundType,
|
||||||
|
String? chatsListImagePath,
|
||||||
|
bool? useGradientForDrawer,
|
||||||
|
DrawerBackgroundType? drawerBackgroundType,
|
||||||
|
String? drawerImagePath,
|
||||||
|
bool? useGradientForAddAccountButton,
|
||||||
|
bool? useGradientForAppBar,
|
||||||
|
AppBarBackgroundType? appBarBackgroundType,
|
||||||
|
String? appBarImagePath,
|
||||||
|
bool? useGradientForFolderTabs,
|
||||||
|
FolderTabsBackgroundType? folderTabsBackgroundType,
|
||||||
|
String? folderTabsImagePath,
|
||||||
|
Color? chatsListGradientColor1,
|
||||||
|
Color? chatsListGradientColor2,
|
||||||
|
Color? drawerGradientColor1,
|
||||||
|
Color? drawerGradientColor2,
|
||||||
|
Color? addAccountButtonGradientColor1,
|
||||||
|
Color? addAccountButtonGradientColor2,
|
||||||
|
Color? appBarGradientColor1,
|
||||||
|
Color? appBarGradientColor2,
|
||||||
|
Color? folderTabsGradientColor1,
|
||||||
|
Color? folderTabsGradientColor2,
|
||||||
}) {
|
}) {
|
||||||
return CustomThemePreset(
|
return CustomThemePreset(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -271,6 +401,29 @@ class CustomThemePreset {
|
|||||||
useDesktopLayout: useDesktopLayout ?? this.useDesktopLayout,
|
useDesktopLayout: useDesktopLayout ?? this.useDesktopLayout,
|
||||||
useAutoReplyColor: useAutoReplyColor ?? this.useAutoReplyColor,
|
useAutoReplyColor: useAutoReplyColor ?? this.useAutoReplyColor,
|
||||||
customReplyColor: customReplyColor ?? this.customReplyColor,
|
customReplyColor: customReplyColor ?? this.customReplyColor,
|
||||||
|
useGradientForChatsList: useGradientForChatsList ?? this.useGradientForChatsList,
|
||||||
|
chatsListBackgroundType: chatsListBackgroundType ?? this.chatsListBackgroundType,
|
||||||
|
chatsListImagePath: chatsListImagePath ?? this.chatsListImagePath,
|
||||||
|
useGradientForDrawer: useGradientForDrawer ?? this.useGradientForDrawer,
|
||||||
|
drawerBackgroundType: drawerBackgroundType ?? this.drawerBackgroundType,
|
||||||
|
drawerImagePath: drawerImagePath ?? this.drawerImagePath,
|
||||||
|
useGradientForAddAccountButton: useGradientForAddAccountButton ?? this.useGradientForAddAccountButton,
|
||||||
|
useGradientForAppBar: useGradientForAppBar ?? this.useGradientForAppBar,
|
||||||
|
appBarBackgroundType: appBarBackgroundType ?? this.appBarBackgroundType,
|
||||||
|
appBarImagePath: appBarImagePath ?? this.appBarImagePath,
|
||||||
|
useGradientForFolderTabs: useGradientForFolderTabs ?? this.useGradientForFolderTabs,
|
||||||
|
folderTabsBackgroundType: folderTabsBackgroundType ?? this.folderTabsBackgroundType,
|
||||||
|
folderTabsImagePath: folderTabsImagePath ?? this.folderTabsImagePath,
|
||||||
|
chatsListGradientColor1: chatsListGradientColor1 ?? this.chatsListGradientColor1,
|
||||||
|
chatsListGradientColor2: chatsListGradientColor2 ?? this.chatsListGradientColor2,
|
||||||
|
drawerGradientColor1: drawerGradientColor1 ?? this.drawerGradientColor1,
|
||||||
|
drawerGradientColor2: drawerGradientColor2 ?? this.drawerGradientColor2,
|
||||||
|
addAccountButtonGradientColor1: addAccountButtonGradientColor1 ?? this.addAccountButtonGradientColor1,
|
||||||
|
addAccountButtonGradientColor2: addAccountButtonGradientColor2 ?? this.addAccountButtonGradientColor2,
|
||||||
|
appBarGradientColor1: appBarGradientColor1 ?? this.appBarGradientColor1,
|
||||||
|
appBarGradientColor2: appBarGradientColor2 ?? this.appBarGradientColor2,
|
||||||
|
folderTabsGradientColor1: folderTabsGradientColor1 ?? this.folderTabsGradientColor1,
|
||||||
|
folderTabsGradientColor2: folderTabsGradientColor2 ?? this.folderTabsGradientColor2,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +478,29 @@ class CustomThemePreset {
|
|||||||
'useDesktopLayout': useDesktopLayout,
|
'useDesktopLayout': useDesktopLayout,
|
||||||
'useAutoReplyColor': useAutoReplyColor,
|
'useAutoReplyColor': useAutoReplyColor,
|
||||||
'customReplyColor': customReplyColor?.value,
|
'customReplyColor': customReplyColor?.value,
|
||||||
|
'useGradientForChatsList': useGradientForChatsList,
|
||||||
|
'chatsListBackgroundType': chatsListBackgroundType.index,
|
||||||
|
'chatsListImagePath': chatsListImagePath,
|
||||||
|
'useGradientForDrawer': useGradientForDrawer,
|
||||||
|
'drawerBackgroundType': drawerBackgroundType.index,
|
||||||
|
'drawerImagePath': drawerImagePath,
|
||||||
|
'useGradientForAddAccountButton': useGradientForAddAccountButton,
|
||||||
|
'useGradientForAppBar': useGradientForAppBar,
|
||||||
|
'appBarBackgroundType': appBarBackgroundType.index,
|
||||||
|
'appBarImagePath': appBarImagePath,
|
||||||
|
'useGradientForFolderTabs': useGradientForFolderTabs,
|
||||||
|
'folderTabsBackgroundType': folderTabsBackgroundType.index,
|
||||||
|
'folderTabsImagePath': folderTabsImagePath,
|
||||||
|
'chatsListGradientColor1': chatsListGradientColor1.value,
|
||||||
|
'chatsListGradientColor2': chatsListGradientColor2.value,
|
||||||
|
'drawerGradientColor1': drawerGradientColor1.value,
|
||||||
|
'drawerGradientColor2': drawerGradientColor2.value,
|
||||||
|
'addAccountButtonGradientColor1': addAccountButtonGradientColor1.value,
|
||||||
|
'addAccountButtonGradientColor2': addAccountButtonGradientColor2.value,
|
||||||
|
'appBarGradientColor1': appBarGradientColor1.value,
|
||||||
|
'appBarGradientColor2': appBarGradientColor2.value,
|
||||||
|
'folderTabsGradientColor1': folderTabsGradientColor1.value,
|
||||||
|
'folderTabsGradientColor2': folderTabsGradientColor2.value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,6 +598,57 @@ class CustomThemePreset {
|
|||||||
customReplyColor: json['customReplyColor'] != null
|
customReplyColor: json['customReplyColor'] != null
|
||||||
? Color(json['customReplyColor'] as int)
|
? Color(json['customReplyColor'] as int)
|
||||||
: null,
|
: null,
|
||||||
|
useGradientForChatsList: json['useGradientForChatsList'] as bool? ?? false,
|
||||||
|
chatsListBackgroundType: ChatsListBackgroundType.values[
|
||||||
|
json['chatsListBackgroundType'] as int? ?? 0
|
||||||
|
],
|
||||||
|
chatsListImagePath: json['chatsListImagePath'] as String?,
|
||||||
|
useGradientForDrawer: json['useGradientForDrawer'] as bool? ?? false,
|
||||||
|
drawerBackgroundType: DrawerBackgroundType.values[
|
||||||
|
json['drawerBackgroundType'] as int? ?? 0
|
||||||
|
],
|
||||||
|
drawerImagePath: json['drawerImagePath'] as String?,
|
||||||
|
useGradientForAddAccountButton: json['useGradientForAddAccountButton'] as bool? ?? false,
|
||||||
|
useGradientForAppBar: json['useGradientForAppBar'] as bool? ?? false,
|
||||||
|
appBarBackgroundType: AppBarBackgroundType.values[
|
||||||
|
json['appBarBackgroundType'] as int? ?? 0
|
||||||
|
],
|
||||||
|
appBarImagePath: json['appBarImagePath'] as String?,
|
||||||
|
useGradientForFolderTabs: json['useGradientForFolderTabs'] as bool? ?? false,
|
||||||
|
folderTabsBackgroundType: FolderTabsBackgroundType.values[
|
||||||
|
json['folderTabsBackgroundType'] as int? ?? 0
|
||||||
|
],
|
||||||
|
folderTabsImagePath: json['folderTabsImagePath'] as String?,
|
||||||
|
chatsListGradientColor1: Color(
|
||||||
|
json['chatsListGradientColor1'] as int? ?? const Color(0xFF1E1E1E).value,
|
||||||
|
),
|
||||||
|
chatsListGradientColor2: Color(
|
||||||
|
json['chatsListGradientColor2'] as int? ?? const Color(0xFF2D2D2D).value,
|
||||||
|
),
|
||||||
|
drawerGradientColor1: Color(
|
||||||
|
json['drawerGradientColor1'] as int? ?? const Color(0xFF1E1E1E).value,
|
||||||
|
),
|
||||||
|
drawerGradientColor2: Color(
|
||||||
|
json['drawerGradientColor2'] as int? ?? const Color(0xFF2D2D2D).value,
|
||||||
|
),
|
||||||
|
addAccountButtonGradientColor1: Color(
|
||||||
|
json['addAccountButtonGradientColor1'] as int? ?? const Color(0xFF1E1E1E).value,
|
||||||
|
),
|
||||||
|
addAccountButtonGradientColor2: Color(
|
||||||
|
json['addAccountButtonGradientColor2'] as int? ?? const Color(0xFF2D2D2D).value,
|
||||||
|
),
|
||||||
|
appBarGradientColor1: Color(
|
||||||
|
json['appBarGradientColor1'] as int? ?? const Color(0xFF1E1E1E).value,
|
||||||
|
),
|
||||||
|
appBarGradientColor2: Color(
|
||||||
|
json['appBarGradientColor2'] as int? ?? const Color(0xFF2D2D2D).value,
|
||||||
|
),
|
||||||
|
folderTabsGradientColor1: Color(
|
||||||
|
json['folderTabsGradientColor1'] as int? ?? const Color(0xFF1E1E1E).value,
|
||||||
|
),
|
||||||
|
folderTabsGradientColor2: Color(
|
||||||
|
json['folderTabsGradientColor2'] as int? ?? const Color(0xFF2D2D2D).value,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,6 +779,29 @@ class ThemeProvider with ChangeNotifier {
|
|||||||
bool get useDesktopLayout => _activeTheme.useDesktopLayout;
|
bool get useDesktopLayout => _activeTheme.useDesktopLayout;
|
||||||
bool get useAutoReplyColor => _activeTheme.useAutoReplyColor;
|
bool get useAutoReplyColor => _activeTheme.useAutoReplyColor;
|
||||||
Color? get customReplyColor => _activeTheme.customReplyColor;
|
Color? get customReplyColor => _activeTheme.customReplyColor;
|
||||||
|
bool get useGradientForChatsList => _activeTheme.useGradientForChatsList;
|
||||||
|
ChatsListBackgroundType get chatsListBackgroundType => _activeTheme.chatsListBackgroundType;
|
||||||
|
String? get chatsListImagePath => _activeTheme.chatsListImagePath;
|
||||||
|
bool get useGradientForDrawer => _activeTheme.useGradientForDrawer;
|
||||||
|
DrawerBackgroundType get drawerBackgroundType => _activeTheme.drawerBackgroundType;
|
||||||
|
String? get drawerImagePath => _activeTheme.drawerImagePath;
|
||||||
|
bool get useGradientForAddAccountButton => _activeTheme.useGradientForAddAccountButton;
|
||||||
|
bool get useGradientForAppBar => _activeTheme.useGradientForAppBar;
|
||||||
|
AppBarBackgroundType get appBarBackgroundType => _activeTheme.appBarBackgroundType;
|
||||||
|
String? get appBarImagePath => _activeTheme.appBarImagePath;
|
||||||
|
bool get useGradientForFolderTabs => _activeTheme.useGradientForFolderTabs;
|
||||||
|
FolderTabsBackgroundType get folderTabsBackgroundType => _activeTheme.folderTabsBackgroundType;
|
||||||
|
String? get folderTabsImagePath => _activeTheme.folderTabsImagePath;
|
||||||
|
Color get chatsListGradientColor1 => _activeTheme.chatsListGradientColor1;
|
||||||
|
Color get chatsListGradientColor2 => _activeTheme.chatsListGradientColor2;
|
||||||
|
Color get drawerGradientColor1 => _activeTheme.drawerGradientColor1;
|
||||||
|
Color get drawerGradientColor2 => _activeTheme.drawerGradientColor2;
|
||||||
|
Color get addAccountButtonGradientColor1 => _activeTheme.addAccountButtonGradientColor1;
|
||||||
|
Color get addAccountButtonGradientColor2 => _activeTheme.addAccountButtonGradientColor2;
|
||||||
|
Color get appBarGradientColor1 => _activeTheme.appBarGradientColor1;
|
||||||
|
Color get appBarGradientColor2 => _activeTheme.appBarGradientColor2;
|
||||||
|
Color get folderTabsGradientColor1 => _activeTheme.folderTabsGradientColor1;
|
||||||
|
Color get folderTabsGradientColor2 => _activeTheme.folderTabsGradientColor2;
|
||||||
bool get highQualityPhotos => _highQualityPhotos;
|
bool get highQualityPhotos => _highQualityPhotos;
|
||||||
bool get blockBypass => _blockBypass;
|
bool get blockBypass => _blockBypass;
|
||||||
|
|
||||||
@@ -1218,6 +1468,144 @@ class ThemeProvider with ChangeNotifier {
|
|||||||
await _saveActiveTheme();
|
await _saveActiveTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setUseGradientForChatsList(bool value) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(useGradientForChatsList: value);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setChatsListBackgroundType(ChatsListBackgroundType type) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(chatsListBackgroundType: type);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setChatsListImagePath(String? path) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(chatsListImagePath: path);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setUseGradientForDrawer(bool value) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(useGradientForDrawer: value);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setDrawerBackgroundType(DrawerBackgroundType type) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(drawerBackgroundType: type);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setDrawerImagePath(String? path) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(drawerImagePath: path);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setChatsListGradientColor1(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(chatsListGradientColor1: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setChatsListGradientColor2(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(chatsListGradientColor2: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setDrawerGradientColor1(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(drawerGradientColor1: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setDrawerGradientColor2(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(drawerGradientColor2: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setUseGradientForAddAccountButton(bool value) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(useGradientForAddAccountButton: value);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAddAccountButtonGradientColor1(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(addAccountButtonGradientColor1: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAddAccountButtonGradientColor2(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(addAccountButtonGradientColor2: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setUseGradientForAppBar(bool value) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(useGradientForAppBar: value);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAppBarGradientColor1(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(appBarGradientColor1: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAppBarGradientColor2(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(appBarGradientColor2: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAppBarBackgroundType(AppBarBackgroundType type) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(appBarBackgroundType: type);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setAppBarImagePath(String? path) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(appBarImagePath: path);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setUseGradientForFolderTabs(bool value) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(useGradientForFolderTabs: value);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setFolderTabsGradientColor1(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(folderTabsGradientColor1: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setFolderTabsGradientColor2(Color color) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(folderTabsGradientColor2: color);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setFolderTabsBackgroundType(FolderTabsBackgroundType type) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(folderTabsBackgroundType: type);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setFolderTabsImagePath(String? path) async {
|
||||||
|
_activeTheme = _activeTheme.copyWith(folderTabsImagePath: path);
|
||||||
|
notifyListeners();
|
||||||
|
await _saveActiveTheme();
|
||||||
|
}
|
||||||
|
|
||||||
void toggleTheme() {
|
void toggleTheme() {
|
||||||
if (appTheme == AppTheme.light) {
|
if (appTheme == AppTheme.light) {
|
||||||
setTheme(AppTheme.dark);
|
setTheme(AppTheme.dark);
|
||||||
|
|||||||
@@ -657,9 +657,7 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
Uint8List? lowQualityBytes,
|
Uint8List? lowQualityBytes,
|
||||||
int? videoType,
|
int? videoType,
|
||||||
}) {
|
}) {
|
||||||
// Логика открытия плеера
|
|
||||||
void openFullScreenVideo() async {
|
void openFullScreenVideo() async {
|
||||||
// Показываем индикатор загрузки, пока получаем URL
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -669,12 +667,12 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
try {
|
try {
|
||||||
final videoUrl = await ApiService.instance.getVideoUrl(
|
final videoUrl = await ApiService.instance.getVideoUrl(
|
||||||
videoId,
|
videoId,
|
||||||
chatId!, // chatId из `build`
|
chatId!,
|
||||||
messageId,
|
messageId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!context.mounted) return; // [!code ++] Проверка правильным способом
|
if (!context.mounted) return;
|
||||||
Navigator.pop(context); // Убираем индикатор
|
Navigator.pop(context);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@@ -682,8 +680,8 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!context.mounted) return; // [!code ++] Проверка правильным способом
|
if (!context.mounted) return;
|
||||||
Navigator.pop(context); // Убираем индикатор
|
Navigator.pop(context);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('Не удалось загрузить видео: $e'),
|
content: Text('Не удалось загрузить видео: $e'),
|
||||||
@@ -705,7 +703,9 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return RepaintBoundary(
|
||||||
|
key: ValueKey('video_preview_boundary_${messageId}_$videoId'),
|
||||||
|
child: GestureDetector(
|
||||||
onTap: openFullScreenVideo,
|
onTap: openFullScreenVideo,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 16 / 9,
|
aspectRatio: 16 / 9,
|
||||||
@@ -715,16 +715,16 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
// Если у нас есть ХОТЬ ЧТО-ТО (блюр или URL), показываем ProgressiveImage
|
|
||||||
(highQualityUrl != null && highQualityUrl.isNotEmpty) ||
|
(highQualityUrl != null && highQualityUrl.isNotEmpty) ||
|
||||||
(lowQualityBytes != null)
|
(lowQualityBytes != null)
|
||||||
? _ProgressiveNetworkImage(
|
? _ProgressiveNetworkImage(
|
||||||
|
key: ValueKey('video_preview_image_${messageId}_$videoId'),
|
||||||
url: highQualityUrl ?? '',
|
url: highQualityUrl ?? '',
|
||||||
previewBytes: lowQualityBytes,
|
previewBytes: lowQualityBytes,
|
||||||
width: 220,
|
width: 220,
|
||||||
height: 160,
|
height: 160,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
keepAlive: false,
|
keepAlive: true,
|
||||||
)
|
)
|
||||||
: Container(
|
: Container(
|
||||||
color: Colors.black26,
|
color: Colors.black26,
|
||||||
@@ -757,6 +757,7 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2004,6 +2005,8 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(bottom: 4.0),
|
padding: const EdgeInsets.only(bottom: 4.0),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 300),
|
constraints: const BoxConstraints(maxWidth: 300),
|
||||||
|
child: RepaintBoundary(
|
||||||
|
key: ValueKey('video_preview_${message.id}_$videoId'),
|
||||||
child: _buildVideoPreview(
|
child: _buildVideoPreview(
|
||||||
context: context,
|
context: context,
|
||||||
videoId: videoId,
|
videoId: videoId,
|
||||||
@@ -2014,6 +2017,7 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (index == videos.length - 1)
|
if (index == videos.length - 1)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 4, right: 6),
|
padding: const EdgeInsets.only(top: 4, right: 6),
|
||||||
@@ -2179,6 +2183,8 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
widgets.add(
|
widgets.add(
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4.0),
|
padding: const EdgeInsets.only(bottom: 4.0),
|
||||||
|
child: RepaintBoundary(
|
||||||
|
key: ValueKey('video_preview_${message.id}_$videoId'),
|
||||||
child: _buildVideoPreview(
|
child: _buildVideoPreview(
|
||||||
context: context,
|
context: context,
|
||||||
videoId: videoId,
|
videoId: videoId,
|
||||||
@@ -2188,6 +2194,7 @@ class ChatMessageBubble extends StatelessWidget {
|
|||||||
videoType: videoType,
|
videoType: videoType,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Заглушка, если вложение есть, а ID не найдены
|
// Заглушка, если вложение есть, а ID не найдены
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:math';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gwid/models/chat.dart';
|
import 'package:gwid/models/chat.dart';
|
||||||
import 'package:gwid/models/contact.dart';
|
import 'package:gwid/models/contact.dart';
|
||||||
|
import 'package:gwid/services/avatar_cache_service.dart';
|
||||||
|
|
||||||
class GroupAvatars extends StatelessWidget {
|
class GroupAvatars extends StatelessWidget {
|
||||||
final Chat chat;
|
final Chat chat;
|
||||||
@@ -39,13 +40,13 @@ class GroupAvatars extends StatelessWidget {
|
|||||||
double adaptiveAvatarSize;
|
double adaptiveAvatarSize;
|
||||||
if (totalParticipants <= 2) {
|
if (totalParticipants <= 2) {
|
||||||
adaptiveAvatarSize =
|
adaptiveAvatarSize =
|
||||||
avatarSize * 1.5; // Большие аватары для 1-2 участников
|
avatarSize * 1.5;
|
||||||
} else if (totalParticipants <= 4) {
|
} else if (totalParticipants <= 4) {
|
||||||
adaptiveAvatarSize =
|
adaptiveAvatarSize =
|
||||||
avatarSize * 1.2; // Средние аватары для 3-4 участников
|
avatarSize * 1.2;
|
||||||
} else {
|
} else {
|
||||||
adaptiveAvatarSize =
|
adaptiveAvatarSize =
|
||||||
avatarSize * 0.8; // Маленькие аватары для 5+ участников
|
avatarSize * 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
@@ -114,6 +115,7 @@ class GroupAvatars extends StatelessWidget {
|
|||||||
) {
|
) {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
if (contact == null || contact.photoBaseUrl == null || contact.photoBaseUrl!.isEmpty) {
|
||||||
return Container(
|
return Container(
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
@@ -133,16 +135,12 @@ class GroupAvatars extends StatelessWidget {
|
|||||||
backgroundColor: contact != null
|
backgroundColor: contact != null
|
||||||
? colors.primaryContainer
|
? colors.primaryContainer
|
||||||
: colors.secondaryContainer,
|
: colors.secondaryContainer,
|
||||||
backgroundImage: contact?.photoBaseUrl != null
|
child: Text(
|
||||||
? NetworkImage(contact!.photoBaseUrl!)
|
|
||||||
: null,
|
|
||||||
child: contact?.photoBaseUrl == null
|
|
||||||
? Text(
|
|
||||||
contact?.name.isNotEmpty == true
|
contact?.name.isNotEmpty == true
|
||||||
? contact!.name[0].toUpperCase()
|
? contact!.name[0].toUpperCase()
|
||||||
: participantId.toString().substring(
|
: participantId.toString().substring(
|
||||||
participantId.toString().length - 1,
|
participantId.toString().length - 1,
|
||||||
), // Последняя цифра ID
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: contact != null
|
color: contact != null
|
||||||
? colors.onPrimaryContainer
|
? colors.onPrimaryContainer
|
||||||
@@ -150,10 +148,59 @@ class GroupAvatars extends StatelessWidget {
|
|||||||
fontSize: size * 0.5,
|
fontSize: size * 0.5,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FutureBuilder<ImageProvider?>(
|
||||||
|
future: AvatarCacheService().getAvatar(contact.photoBaseUrl, userId: participantId),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
ImageProvider? imageProvider;
|
||||||
|
if (snapshot.hasData && snapshot.data != null) {
|
||||||
|
imageProvider = snapshot.data;
|
||||||
|
} else {
|
||||||
|
imageProvider = NetworkImage(contact.photoBaseUrl!);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: colors.surface, width: 2),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: colors.shadow.withOpacity(0.3),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: size / 2,
|
||||||
|
backgroundColor: colors.primaryContainer,
|
||||||
|
backgroundImage: imageProvider,
|
||||||
|
onBackgroundImageError: (exception, stackTrace) {
|
||||||
|
},
|
||||||
|
child: imageProvider == null
|
||||||
|
? Text(
|
||||||
|
contact.name.isNotEmpty
|
||||||
|
? contact.name[0].toUpperCase()
|
||||||
|
: participantId.toString().substring(
|
||||||
|
participantId.toString().length - 1,
|
||||||
|
),
|
||||||
|
style: TextStyle(
|
||||||
|
color: colors.onPrimaryContainer,
|
||||||
|
fontSize: size * 0.5,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMoreIndicator(BuildContext context, int count, double size) {
|
Widget _buildMoreIndicator(BuildContext context, int count, double size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user