Skip to content

Commit

Permalink
Added beta badge
Browse files Browse the repository at this point in the history
  • Loading branch information
JHubi1 committed Aug 21, 2024
1 parent efcca11 commit e100622
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
6 changes: 4 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,9 @@ class _MainAppState extends State<MainApp> {
onPressed: () {
if (!chatAllowed &&
chatUuid ==
jsonDecode(item)["uuid"])
jsonDecode(item)["uuid"]) {
return;
}
if (!allowMultipleChats) {
for (var i = 0;
i <
Expand Down Expand Up @@ -646,8 +647,9 @@ class _MainAppState extends State<MainApp> {
? DismissDirection.startToEnd
: DismissDirection.none,
confirmDismiss: (direction) async {
if (!chatAllowed && chatUuid == jsonDecode(item)["uuid"])
if (!chatAllowed && chatUuid == jsonDecode(item)["uuid"]) {
return false;
}
return await deleteChatDialog(context, setState,
takeAction: false);
},
Expand Down
60 changes: 41 additions & 19 deletions lib/screen_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Widget button(String text, IconData? icon, void Function()? onPressed,
bool disabled = false,
bool replaceIconIfNull = false,
String? description,
String? badge,
void Function()? onDisabledTap,
void Function()? onLongTap,
void Function()? onDoubleTap}) {
Expand Down Expand Up @@ -206,24 +207,43 @@ Widget button(String text, IconData? icon, void Function()? onPressed,
(icon != null || replaceIconIfNull)
? const SizedBox(width: 16, height: 42)
: const SizedBox.shrink(),
Expanded(
child: (context != null)
? RichText(
text: TextSpan(
text: text,
style: DefaultTextStyle.of(context).style.copyWith(
color: disabled ? Colors.grey : color),
children: [
(description != null &&
desktopLayoutNotRequired(context))
? TextSpan(
text: description,
style: const TextStyle(color: Colors.grey))
: const TextSpan()
]))
: Text(text,
style:
TextStyle(color: disabled ? Colors.grey : color)))
Expanded(child: Builder(builder: (context) {
Widget textWidget = Text(text,
style: TextStyle(color: disabled ? Colors.grey : color));
if (badge != null) {
textWidget = Badge(
label: Text(badge),
offset: const Offset(20, -4),
backgroundColor: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary,
child: textWidget);
}
if (description == null || description!.startsWith("\n")) {
description = description?.removePrefix("\n");
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
textWidget,
(description != null && desktopLayoutNotRequired(context))
? Text(description!,
style: const TextStyle(color: Colors.grey))
: const SizedBox.shrink()
]);
} else {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
textWidget,
(description != null && desktopLayoutNotRequired(context))
? Text(description!,
style: const TextStyle(color: Colors.grey))
: const SizedBox.shrink()
]);
}
}))
]),
)),
);
Expand Down Expand Up @@ -544,7 +564,9 @@ class _ScreenSettingsState extends State<ScreenSettings> {
},
context: context,
description:
"\n${AppLocalizations.of(context)!.settingsDescriptionVoice}")
"\n${AppLocalizations.of(context)!.settingsDescriptionVoice}",
badge: AppLocalizations.of(context)!
.settingsExperimentalBeta)
: const SizedBox.shrink(),
button(
AppLocalizations.of(context)!.settingsTitleExport,
Expand Down
9 changes: 8 additions & 1 deletion lib/settings/voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ class _ScreenSettingsVoiceState extends State<ScreenSettingsVoice> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.settingsTitleVoice)),
title: Badge(
label: Text(
AppLocalizations.of(context)!.settingsExperimentalBeta),
offset: const Offset(20, -4),
backgroundColor: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary,
child:
Text(AppLocalizations.of(context)!.settingsTitleVoice))),
body: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Column(children: [
Expand Down

0 comments on commit e100622

Please sign in to comment.