mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-21 05:38:42 -04:00
updates and cleanup
This commit is contained in:
parent
6bd60207d8
commit
ef1ded4494
11 changed files with 142 additions and 108 deletions
|
@ -100,7 +100,8 @@
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"waiting_for_network": "Waiting For Network"
|
"waiting_for_network": "Waiting For Network",
|
||||||
|
"chat": "Chat"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
|
@ -127,7 +128,7 @@
|
||||||
"contacts": "Contacts",
|
"contacts": "Contacts",
|
||||||
"edit_contact": "Edit Contact",
|
"edit_contact": "Edit Contact",
|
||||||
"invitations": "Invitations",
|
"invitations": "Invitations",
|
||||||
"no_contact_selected": "Double-click a contact to edit it",
|
"no_contact_selected": "Select a contact to view or edit",
|
||||||
"new_chat": "Open Chat",
|
"new_chat": "Open Chat",
|
||||||
"close_contact": "Close Contact"
|
"close_contact": "Close Contact"
|
||||||
},
|
},
|
||||||
|
|
|
@ -50,8 +50,11 @@ class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||||
messageWindow: const AsyncLoading(),
|
messageWindow: const AsyncLoading(),
|
||||||
title: '',
|
title: '',
|
||||||
)) {
|
)) {
|
||||||
|
// Immediate Init
|
||||||
|
_init();
|
||||||
|
|
||||||
// Async Init
|
// Async Init
|
||||||
_initWait.add(_init);
|
_initWait.add(_initAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory ChatComponentCubit.singleContact(
|
factory ChatComponentCubit.singleContact(
|
||||||
|
@ -68,7 +71,7 @@ class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||||
messagesCubit: messagesCubit,
|
messagesCubit: messagesCubit,
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<void> _init(Completer<void> _cancel) async {
|
void _init() {
|
||||||
// Get local user info and account record cubit
|
// Get local user info and account record cubit
|
||||||
_localUserIdentityKey = _accountInfo.identityTypedPublicKey;
|
_localUserIdentityKey = _accountInfo.identityTypedPublicKey;
|
||||||
|
|
||||||
|
@ -77,9 +80,6 @@ class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||||
_accountRecordCubit.stream.listen(_onChangedAccountRecord);
|
_accountRecordCubit.stream.listen(_onChangedAccountRecord);
|
||||||
_onChangedAccountRecord(_accountRecordCubit.state);
|
_onChangedAccountRecord(_accountRecordCubit.state);
|
||||||
|
|
||||||
// Subscribe to remote user info
|
|
||||||
await _updateConversationSubscriptions();
|
|
||||||
|
|
||||||
// Subscribe to messages
|
// Subscribe to messages
|
||||||
_messagesSubscription = _messagesCubit.stream.listen(_onChangedMessages);
|
_messagesSubscription = _messagesCubit.stream.listen(_onChangedMessages);
|
||||||
_onChangedMessages(_messagesCubit.state);
|
_onChangedMessages(_messagesCubit.state);
|
||||||
|
@ -90,6 +90,11 @@ class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||||
_onChangedContacts(_contactListCubit.state);
|
_onChangedContacts(_contactListCubit.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _initAsync(Completer<void> _cancel) async {
|
||||||
|
// Subscribe to remote user info
|
||||||
|
await _updateConversationSubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await _initWait();
|
await _initWait();
|
||||||
|
|
|
@ -68,15 +68,27 @@ class ContactItemWidget extends StatelessWidget {
|
||||||
: () => singleFuture<void>((this, _kOnTap), () async {
|
: () => singleFuture<void>((this, _kOnTap), () async {
|
||||||
await _onTap(_contact);
|
await _onTap(_contact);
|
||||||
}),
|
}),
|
||||||
endActions: [
|
startActions: [
|
||||||
if (_onDoubleTap != null)
|
if (_onDoubleTap != null)
|
||||||
|
SliderTileAction(
|
||||||
|
//icon: Icons.edit,
|
||||||
|
label: translate('button.chat'),
|
||||||
|
actionScale: ScaleKind.secondary,
|
||||||
|
onPressed: (_context) =>
|
||||||
|
singleFuture<void>((this, _kOnTap), () async {
|
||||||
|
await _onDoubleTap(_contact);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
endActions: [
|
||||||
|
if (_onTap != null)
|
||||||
SliderTileAction(
|
SliderTileAction(
|
||||||
//icon: Icons.edit,
|
//icon: Icons.edit,
|
||||||
label: translate('button.edit'),
|
label: translate('button.edit'),
|
||||||
actionScale: ScaleKind.secondary,
|
actionScale: ScaleKind.secondary,
|
||||||
onPressed: (_context) =>
|
onPressed: (_context) =>
|
||||||
singleFuture<void>((this, _kOnTap), () async {
|
singleFuture<void>((this, _kOnTap), () async {
|
||||||
await _onDoubleTap(_contact);
|
await _onTap(_contact);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
if (_onDelete != null)
|
if (_onDelete != null)
|
||||||
|
|
|
@ -39,14 +39,14 @@ class ContactsBrowserElement {
|
||||||
class ContactsBrowser extends StatefulWidget {
|
class ContactsBrowser extends StatefulWidget {
|
||||||
const ContactsBrowser(
|
const ContactsBrowser(
|
||||||
{required this.onContactSelected,
|
{required this.onContactSelected,
|
||||||
required this.onChatStarted,
|
required this.onStartChat,
|
||||||
this.selectedContactRecordKey,
|
this.selectedContactRecordKey,
|
||||||
super.key});
|
super.key});
|
||||||
@override
|
@override
|
||||||
State<ContactsBrowser> createState() => _ContactsBrowserState();
|
State<ContactsBrowser> createState() => _ContactsBrowserState();
|
||||||
|
|
||||||
final Future<void> Function(proto.Contact? contact) onContactSelected;
|
final Future<void> Function(proto.Contact? contact) onContactSelected;
|
||||||
final Future<void> Function(proto.Contact contact) onChatStarted;
|
final Future<void> Function(proto.Contact contact) onStartChat;
|
||||||
final TypedKey? selectedContactRecordKey;
|
final TypedKey? selectedContactRecordKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -60,7 +60,7 @@ class ContactsBrowser extends StatefulWidget {
|
||||||
'onContactSelected', onContactSelected))
|
'onContactSelected', onContactSelected))
|
||||||
..add(
|
..add(
|
||||||
ObjectFlagProperty<Future<void> Function(proto.Contact contact)>.has(
|
ObjectFlagProperty<Future<void> Function(proto.Contact contact)>.has(
|
||||||
'onChatStarted', onChatStarted));
|
'onStartChat', onStartChat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,8 +238,8 @@ class _ContactsBrowserState extends State<ContactsBrowser>
|
||||||
selected: widget.selectedContactRecordKey ==
|
selected: widget.selectedContactRecordKey ==
|
||||||
contact.localConversationRecordKey.toVeilid(),
|
contact.localConversationRecordKey.toVeilid(),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
onDoubleTap: _onTapContact,
|
onDoubleTap: _onStartChat,
|
||||||
onTap: _onStartChat,
|
onTap: _onSelectContact,
|
||||||
onDelete: _onDeleteContact)
|
onDelete: _onDeleteContact)
|
||||||
.paddingLTRB(0, 4, 0, 0);
|
.paddingLTRB(0, 4, 0, 0);
|
||||||
case ContactsBrowserElementKind.invitation:
|
case ContactsBrowserElementKind.invitation:
|
||||||
|
@ -293,12 +293,12 @@ class _ContactsBrowserState extends State<ContactsBrowser>
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onTapContact(proto.Contact contact) async {
|
Future<void> _onSelectContact(proto.Contact contact) async {
|
||||||
await widget.onContactSelected(contact);
|
await widget.onContactSelected(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onStartChat(proto.Contact contact) async {
|
Future<void> _onStartChat(proto.Contact contact) async {
|
||||||
await widget.onChatStarted(contact);
|
await widget.onStartChat(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onDeleteContact(proto.Contact contact) async {
|
Future<void> _onDeleteContact(proto.Contact contact) async {
|
||||||
|
|
|
@ -135,7 +135,7 @@ class _ContactsDialogState extends State<ContactsDialog> {
|
||||||
?.localConversationRecordKey
|
?.localConversationRecordKey
|
||||||
.toVeilid(),
|
.toVeilid(),
|
||||||
onContactSelected: _onContactSelected,
|
onContactSelected: _onContactSelected,
|
||||||
onChatStarted: _onChatStarted,
|
onStartChat: _onChatStarted,
|
||||||
).paddingLTRB(8, 0, 8, 8)))),
|
).paddingLTRB(8, 0, 8, 8)))),
|
||||||
if (enableRight && enableLeft)
|
if (enableRight && enableLeft)
|
||||||
Container(
|
Container(
|
||||||
|
|
|
@ -31,7 +31,8 @@ class SettingsPageState extends State<SettingsPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) =>
|
Widget build(BuildContext context) =>
|
||||||
AsyncBlocBuilder<PreferencesCubit, Preferences>(
|
AsyncBlocBuilder<PreferencesCubit, Preferences>(
|
||||||
builder: (context, state) => StyledScaffold(
|
builder: (context, state) => ThemeSwitcher.withTheme(
|
||||||
|
builder: (_, switcher, theme) => StyledScaffold(
|
||||||
appBar: DefaultAppBar(
|
appBar: DefaultAppBar(
|
||||||
title: Text(translate('settings_page.titlebar')),
|
title: Text(translate('settings_page.titlebar')),
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
|
@ -39,7 +40,8 @@ class SettingsPageState extends State<SettingsPage> {
|
||||||
onPressed: () => GoRouterHelper(context).pop(),
|
onPressed: () => GoRouterHelper(context).pop(),
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
const SignalStrengthMeterWidget().paddingLTRB(16, 0, 16, 0),
|
const SignalStrengthMeterWidget()
|
||||||
|
.paddingLTRB(16, 0, 16, 0),
|
||||||
]),
|
]),
|
||||||
body: ThemeSwitchingArea(
|
body: ThemeSwitchingArea(
|
||||||
child: FormBuilder(
|
child: FormBuilder(
|
||||||
|
@ -49,16 +51,22 @@ class SettingsPageState extends State<SettingsPage> {
|
||||||
children: [
|
children: [
|
||||||
buildSettingsPageColorPreferences(
|
buildSettingsPageColorPreferences(
|
||||||
context: context,
|
context: context,
|
||||||
|
switcher: switcher,
|
||||||
onChanged: () => setState(() {}))
|
onChanged: () => setState(() {}))
|
||||||
.paddingLTRB(0, 8, 0, 0),
|
.paddingLTRB(0, 8, 0, 0),
|
||||||
buildSettingsPageBrightnessPreferences(
|
buildSettingsPageBrightnessPreferences(
|
||||||
context: context, onChanged: () => setState(() {})),
|
context: context,
|
||||||
|
switcher: switcher,
|
||||||
|
onChanged: () => setState(() {})),
|
||||||
buildSettingsPageWallpaperPreferences(
|
buildSettingsPageWallpaperPreferences(
|
||||||
context: context, onChanged: () => setState(() {})),
|
context: context,
|
||||||
|
switcher: switcher,
|
||||||
|
onChanged: () => setState(() {})),
|
||||||
buildSettingsPageNotificationPreferences(
|
buildSettingsPageNotificationPreferences(
|
||||||
context: context, onChanged: () => setState(() {})),
|
context: context,
|
||||||
|
onChanged: () => setState(() {})),
|
||||||
].map((x) => x.paddingLTRB(0, 0, 0, 8)).toList(),
|
].map((x) => x.paddingLTRB(0, 0, 0, 8)).toList(),
|
||||||
),
|
),
|
||||||
).paddingSymmetric(horizontal: 8, vertical: 8),
|
).paddingSymmetric(horizontal: 8, vertical: 8),
|
||||||
)));
|
))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,12 @@ List<DropdownMenuItem<dynamic>> _getBrightnessDropdownItems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSettingsPageBrightnessPreferences(
|
Widget buildSettingsPageBrightnessPreferences(
|
||||||
{required BuildContext context, required void Function() onChanged}) {
|
{required BuildContext context,
|
||||||
|
required void Function() onChanged,
|
||||||
|
required ThemeSwitcherState switcher}) {
|
||||||
final preferencesRepository = PreferencesRepository.instance;
|
final preferencesRepository = PreferencesRepository.instance;
|
||||||
final themePreferences = preferencesRepository.value.themePreference;
|
final themePreferences = preferencesRepository.value.themePreference;
|
||||||
return ThemeSwitcher.withTheme(
|
return FormBuilderDropdown(
|
||||||
builder: (_, switcher, theme) => FormBuilderDropdown(
|
|
||||||
name: formFieldBrightness,
|
name: formFieldBrightness,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: Text(translate('settings_page.brightness_mode'))),
|
label: Text(translate('settings_page.brightness_mode'))),
|
||||||
|
@ -41,5 +42,5 @@ Widget buildSettingsPageBrightnessPreferences(
|
||||||
await preferencesRepository.set(newPrefs);
|
await preferencesRepository.set(newPrefs);
|
||||||
switcher.changeTheme(theme: newThemePrefs.themeData());
|
switcher.changeTheme(theme: newThemePrefs.themeData());
|
||||||
onChanged();
|
onChanged();
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
|
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
|
||||||
|
import 'package:async_tools/async_tools.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
|
@ -7,6 +8,7 @@ import '../../settings/settings.dart';
|
||||||
import '../models/models.dart';
|
import '../models/models.dart';
|
||||||
|
|
||||||
const String formFieldTheme = 'theme';
|
const String formFieldTheme = 'theme';
|
||||||
|
const String _kSwitchTheme = 'switchTheme';
|
||||||
|
|
||||||
List<DropdownMenuItem<dynamic>> _getThemeDropdownItems() {
|
List<DropdownMenuItem<dynamic>> _getThemeDropdownItems() {
|
||||||
const colorPrefs = ColorPreference.values;
|
const colorPrefs = ColorPreference.values;
|
||||||
|
@ -32,17 +34,19 @@ List<DropdownMenuItem<dynamic>> _getThemeDropdownItems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSettingsPageColorPreferences(
|
Widget buildSettingsPageColorPreferences(
|
||||||
{required BuildContext context, required void Function() onChanged}) {
|
{required BuildContext context,
|
||||||
|
required void Function() onChanged,
|
||||||
|
required ThemeSwitcherState switcher}) {
|
||||||
final preferencesRepository = PreferencesRepository.instance;
|
final preferencesRepository = PreferencesRepository.instance;
|
||||||
final themePreferences = preferencesRepository.value.themePreference;
|
final themePreferences = preferencesRepository.value.themePreference;
|
||||||
return ThemeSwitcher.withTheme(
|
return FormBuilderDropdown(
|
||||||
builder: (_, switcher, theme) => FormBuilderDropdown(
|
|
||||||
name: formFieldTheme,
|
name: formFieldTheme,
|
||||||
decoration: InputDecoration(
|
decoration:
|
||||||
label: Text(translate('settings_page.color_theme'))),
|
InputDecoration(label: Text(translate('settings_page.color_theme'))),
|
||||||
items: _getThemeDropdownItems(),
|
items: _getThemeDropdownItems(),
|
||||||
initialValue: themePreferences.colorPreference,
|
initialValue: themePreferences.colorPreference,
|
||||||
onChanged: (value) async {
|
onChanged: (value) {
|
||||||
|
singleFuture(_kSwitchTheme, () async {
|
||||||
final newThemePrefs = themePreferences.copyWith(
|
final newThemePrefs = themePreferences.copyWith(
|
||||||
colorPreference: value as ColorPreference);
|
colorPreference: value as ColorPreference);
|
||||||
final newPrefs = preferencesRepository.value
|
final newPrefs = preferencesRepository.value
|
||||||
|
@ -51,5 +55,6 @@ Widget buildSettingsPageColorPreferences(
|
||||||
await preferencesRepository.set(newPrefs);
|
await preferencesRepository.set(newPrefs);
|
||||||
switcher.changeTheme(theme: newThemePrefs.themeData());
|
switcher.changeTheme(theme: newThemePrefs.themeData());
|
||||||
onChanged();
|
onChanged();
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@ import '../models/models.dart';
|
||||||
const String formFieldEnableWallpaper = 'enable_wallpaper';
|
const String formFieldEnableWallpaper = 'enable_wallpaper';
|
||||||
|
|
||||||
Widget buildSettingsPageWallpaperPreferences(
|
Widget buildSettingsPageWallpaperPreferences(
|
||||||
{required BuildContext context, required void Function() onChanged}) {
|
{required BuildContext context,
|
||||||
|
required void Function() onChanged,
|
||||||
|
required ThemeSwitcherState switcher}) {
|
||||||
final preferencesRepository = PreferencesRepository.instance;
|
final preferencesRepository = PreferencesRepository.instance;
|
||||||
final themePreferences = preferencesRepository.value.themePreference;
|
final themePreferences = preferencesRepository.value.themePreference;
|
||||||
return ThemeSwitcher.withTheme(
|
return FormBuilderCheckbox(
|
||||||
builder: (_, switcher, theme) => FormBuilderCheckbox(
|
|
||||||
name: formFieldEnableWallpaper,
|
name: formFieldEnableWallpaper,
|
||||||
title: Text(translate('settings_page.enable_wallpaper')),
|
title: Text(translate('settings_page.enable_wallpaper')),
|
||||||
initialValue: themePreferences.enableWallpaper,
|
initialValue: themePreferences.enableWallpaper,
|
||||||
|
@ -28,5 +29,5 @@ Widget buildSettingsPageWallpaperPreferences(
|
||||||
switcher.changeTheme(theme: newThemePrefs.themeData());
|
switcher.changeTheme(theme: newThemePrefs.themeData());
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
13
pubspec.lock
13
pubspec.lock
|
@ -92,10 +92,11 @@ packages:
|
||||||
async_tools:
|
async_tools:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "../dart_async_tools"
|
name: async_tools
|
||||||
relative: true
|
sha256: a258558160d6adc18612d0c635ce0d18ceabc022f7933ce78ca4806075d79578
|
||||||
source: path
|
url: "https://pub.dev"
|
||||||
version: "0.1.7"
|
source: hosted
|
||||||
|
version: "0.1.8"
|
||||||
auto_size_text:
|
auto_size_text:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -156,10 +157,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: bloc_advanced_tools
|
name: bloc_advanced_tools
|
||||||
sha256: d8a680d8a0469456399fb26bae9f7a1d2a1420b5bdf75e204e0fadab9edb0811
|
sha256: "977f3c7e3f9a19aec2f2c734ae99c8f0799c1b78f9fd7e4dce91a2dbf773e11b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.8"
|
version: "0.1.9"
|
||||||
blurry_modal_progress_hud:
|
blurry_modal_progress_hud:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
10
pubspec.yaml
10
pubspec.yaml
|
@ -15,13 +15,13 @@ dependencies:
|
||||||
animated_theme_switcher: ^2.0.10
|
animated_theme_switcher: ^2.0.10
|
||||||
ansicolor: ^2.0.3
|
ansicolor: ^2.0.3
|
||||||
archive: ^4.0.4
|
archive: ^4.0.4
|
||||||
async_tools: ^0.1.7
|
async_tools: ^0.1.8
|
||||||
auto_size_text: ^3.0.0
|
auto_size_text: ^3.0.0
|
||||||
awesome_extensions: ^2.0.21
|
awesome_extensions: ^2.0.21
|
||||||
badges: ^3.1.2
|
badges: ^3.1.2
|
||||||
basic_utils: ^5.8.2
|
basic_utils: ^5.8.2
|
||||||
bloc: ^8.1.4
|
bloc: ^8.1.4
|
||||||
bloc_advanced_tools: ^0.1.8
|
bloc_advanced_tools: ^0.1.9
|
||||||
blurry_modal_progress_hud: ^1.1.1
|
blurry_modal_progress_hud: ^1.1.1
|
||||||
change_case: ^2.2.0
|
change_case: ^2.2.0
|
||||||
charcode: ^1.4.0
|
charcode: ^1.4.0
|
||||||
|
@ -112,9 +112,9 @@ dependencies:
|
||||||
xterm: ^4.0.0
|
xterm: ^4.0.0
|
||||||
zxing2: ^0.2.3
|
zxing2: ^0.2.3
|
||||||
|
|
||||||
dependency_overrides:
|
#dependency_overrides:
|
||||||
async_tools:
|
# async_tools:
|
||||||
path: ../dart_async_tools
|
# path: ../dart_async_tools
|
||||||
# bloc_advanced_tools:
|
# bloc_advanced_tools:
|
||||||
# path: ../bloc_advanced_tools
|
# path: ../bloc_advanced_tools
|
||||||
# searchable_listview:
|
# searchable_listview:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue