Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 109 additions & 92 deletions lib/components/drawer/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:rtchat/models/audio.dart';
import 'package:rtchat/models/channels.dart';
import 'package:rtchat/models/layout.dart';
import 'package:rtchat/models/qr_code.dart';
import 'package:rtchat/models/quick_links.dart';
import 'package:rtchat/models/user.dart';
import 'package:rtchat/screens/settings/qr.dart';
import 'package:rtchat/urls.dart';
Expand Down Expand Up @@ -225,110 +226,126 @@ class Sidebar extends StatefulWidget {
}

class _SidebarState extends State<Sidebar> {
@override
Widget build(BuildContext context) {
final tiles = <Widget>[
ListTile(
leading: const Icon(Icons.add_link_sharp),
title: Text(AppLocalizations.of(context)!.configureQuickLinks),
onTap: () =>
Navigator.of(context).pushNamed("/settings/quick-links")),

const Divider(),

// setting
Consumer<LayoutModel>(builder: (context, layoutModel, child) {
if (!layoutModel.locked) {
Widget _buildActionTile(BuildContext context, String actionId) {
switch (actionId) {
case 'rainMode':
return Consumer<LayoutModel>(builder: (context, layoutModel, _) {
return ListTile(
leading: const Icon(Icons.thunderstorm),
title: Text(AppLocalizations.of(context)!.enableRainMode),
subtitle: Text(AppLocalizations.of(context)!.enableRainModeSubtitle,
title: Text(layoutModel.locked
? AppLocalizations.of(context)!.disableRainMode
: AppLocalizations.of(context)!.enableRainMode),
subtitle: Text(
layoutModel.locked
? AppLocalizations.of(context)!.disableRainModeSubtitle
: AppLocalizations.of(context)!.enableRainModeSubtitle,
overflow: TextOverflow.ellipsis),
onTap: () async {
onTap: () {
layoutModel.locked = !layoutModel.locked;
Navigator.pop(context);
},
);
}

return ListTile(
leading: const Icon(Icons.thunderstorm),
title: Text(AppLocalizations.of(context)!.disableRainMode),
subtitle: Text(AppLocalizations.of(context)!.disableRainModeSubtitle,
overflow: TextOverflow.ellipsis),
onTap: () async {
layoutModel.locked = !layoutModel.locked;
Navigator.pop(context);
},
);
}),

Consumer<AudioModel>(builder: (context, audioModel, child) {
if (audioModel.sources.isEmpty) {
return Container();
}
return ListTile(
leading: const Icon(Icons.cached_outlined),
title: Text(AppLocalizations.of(context)!.refreshAudioSources),
onTap: () async {
final scaffoldMessenger = ScaffoldMessenger.of(context);
final count = await audioModel.refreshAllSources();
if (!context.mounted) return;
scaffoldMessenger.showSnackBar(SnackBar(
content: Text(AppLocalizations.of(context)!
.refreshAudioSourcesCount(count))));
},
);
}),
});
case 'refreshAudio':
return Consumer<AudioModel>(builder: (context, audioModel, _) {
if (audioModel.sources.isEmpty) return Container();
return ListTile(
leading: const Icon(Icons.cached_outlined),
title: Text(AppLocalizations.of(context)!.refreshAudioSources),
onTap: () async {
final scaffoldMessenger = ScaffoldMessenger.of(context);
final count = await audioModel.refreshAllSources();
if (!context.mounted) return;
scaffoldMessenger.showSnackBar(SnackBar(
content: Text(AppLocalizations.of(context)!
.refreshAudioSourcesCount(count))));
},
);
});
case 'raid':
return Consumer<UserModel>(builder: (context, model, _) {
return ListTile(
leading: const Icon(Icons.connect_without_contact),
title: Text(AppLocalizations.of(context)!.raidAChannel),
onTap: () {
Navigator.of(context).pop();
showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
builder: (context) => _buildRaidBottomSheet(context),
);
},
);
});
default:
return const SizedBox.shrink();
}
}

//raid
Consumer<UserModel>(builder: (context, model, child) {
return ListTile(
leading: const Icon(Icons.connect_without_contact),
title: Text(AppLocalizations.of(context)!.raidAChannel),
onTap: () {
Navigator.of(context).pop();
showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (context) {
return DraggableScrollableSheet(
initialChildSize: 0.8,
maxChildSize: 0.9,
expand: false,
builder: (context, controller) {
final model =
Provider.of<UserModel>(context, listen: false);
final userChannel = model.userChannel;
return ChannelSearchBottomSheetWidget(
isRaid: true,
onChannelSelect: (channel) {
model.activeChannel = channel;
},
onRaid: userChannel == model.activeChannel &&
userChannel != null
? (channel) {
final activeChannel = model.activeChannel;
if (activeChannel == null) {
return;
}
ActionsAdapter.instance
.raid(activeChannel, channel);
}
: null,
controller: controller,
);
},
Widget _buildRaidBottomSheet(BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.8,
maxChildSize: 0.9,
expand: false,
builder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
left: 16,
right: 16,
),
child: Consumer<UserModel>(
builder: (context, model, _) {
final userChannel = model.userChannel;
return ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height * 0.8,
maxHeight: MediaQuery.of(context).size.height * 0.9,
),
child: ChannelSearchBottomSheetWidget(
isRaid: true,
onChannelSelect: (channel) {
model.activeChannel = channel;
},
onRaid: userChannel == model.activeChannel &&
userChannel != null
? (channel) {
final activeChannel = model.activeChannel;
if (activeChannel == null) return;
ActionsAdapter.instance
.raid(activeChannel, channel);
}
: null,
controller: scrollController,
),
);
},
);
},
),
),
);
}),
},
);
}

@override
Widget build(BuildContext context) {
final tiles = <Widget>[
ListTile(
leading: const Icon(Icons.add_link_sharp),
title: Text(AppLocalizations.of(context)!.configureQuickLinks),
onTap: () =>
Navigator.of(context).pushNamed("/settings/quick-links")),
const Divider(),
Consumer<QuickLinksModel>(
builder: (context, model, _) => Column(
children: QuickLinksModel.availableActions
.where((action) => model.isActionEnabled(action['id']))
.map((action) => _buildActionTile(context, action['id']))
.toList(),
),
),
ListTile(
leading: const Icon(Icons.build_outlined),
title: Text(AppLocalizations.of(context)!.settings),
Expand Down
5 changes: 5 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"sendAMessage": "Send a message...",
"@sendAMessage": {
Expand Down Expand Up @@ -992,5 +993,9 @@
"alertsEnabled" : "Alerts only",
"@alertsEnabled" : {
"description": "Message indicating that alerts have been enabled"
},
"sidebarActions": "Sidebar Actions",
"@sidebarActions": {
"description": "Header for the toggleable sidebar actions section"
}
}
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,12 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Alerts only'**
String get alertsEnabled;

/// Header for the toggleable sidebar actions section
///
/// In en, this message translates to:
/// **'Sidebar Actions'**
String get sidebarActions;
}

class _AppLocalizationsDelegate
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -697,4 +697,7 @@ class AppLocalizationsAr extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_bn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,7 @@ class AppLocalizationsBn extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,7 @@ class AppLocalizationsDe extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -699,4 +699,7 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,7 @@ class AppLocalizationsEs extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -711,4 +711,7 @@ class AppLocalizationsFr extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -708,4 +708,7 @@ class AppLocalizationsIt extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,7 @@ class AppLocalizationsJa extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ko.dart
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,7 @@ class AppLocalizationsKo extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,7 @@ class AppLocalizationsNl extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,7 @@ class AppLocalizationsPl extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,7 @@ class AppLocalizationsPt extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -708,4 +708,7 @@ class AppLocalizationsRu extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_sv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,7 @@ class AppLocalizationsSv extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,7 @@ class AppLocalizationsUk extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ class AppLocalizationsZh extends AppLocalizations {

@override
String get alertsEnabled => 'Alerts only';

@override
String get sidebarActions => 'Sidebar Actions';
}

/// The translations for Chinese, using the Han script (`zh_Hant`).
Expand Down
Loading