Added beta badge

This commit is contained in:
JHubi1 2024-08-22 00:18:23 +02:00
parent efcca113c8
commit e10062206d
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
3 changed files with 53 additions and 22 deletions

View File

@ -483,8 +483,9 @@ class _MainAppState extends State<MainApp> {
onPressed: () { onPressed: () {
if (!chatAllowed && if (!chatAllowed &&
chatUuid == chatUuid ==
jsonDecode(item)["uuid"]) jsonDecode(item)["uuid"]) {
return; return;
}
if (!allowMultipleChats) { if (!allowMultipleChats) {
for (var i = 0; for (var i = 0;
i < i <
@ -646,8 +647,9 @@ class _MainAppState extends State<MainApp> {
? DismissDirection.startToEnd ? DismissDirection.startToEnd
: DismissDirection.none, : DismissDirection.none,
confirmDismiss: (direction) async { confirmDismiss: (direction) async {
if (!chatAllowed && chatUuid == jsonDecode(item)["uuid"]) if (!chatAllowed && chatUuid == jsonDecode(item)["uuid"]) {
return false; return false;
}
return await deleteChatDialog(context, setState, return await deleteChatDialog(context, setState,
takeAction: false); takeAction: false);
}, },

View File

@ -158,6 +158,7 @@ Widget button(String text, IconData? icon, void Function()? onPressed,
bool disabled = false, bool disabled = false,
bool replaceIconIfNull = false, bool replaceIconIfNull = false,
String? description, String? description,
String? badge,
void Function()? onDisabledTap, void Function()? onDisabledTap,
void Function()? onLongTap, void Function()? onLongTap,
void Function()? onDoubleTap}) { void Function()? onDoubleTap}) {
@ -206,24 +207,43 @@ Widget button(String text, IconData? icon, void Function()? onPressed,
(icon != null || replaceIconIfNull) (icon != null || replaceIconIfNull)
? const SizedBox(width: 16, height: 42) ? const SizedBox(width: 16, height: 42)
: const SizedBox.shrink(), : const SizedBox.shrink(),
Expanded( Expanded(child: Builder(builder: (context) {
child: (context != null) Widget textWidget = Text(text,
? RichText( style: TextStyle(color: disabled ? Colors.grey : color));
text: TextSpan( if (badge != null) {
text: text, textWidget = Badge(
style: DefaultTextStyle.of(context).style.copyWith( label: Text(badge),
color: disabled ? Colors.grey : color), offset: const Offset(20, -4),
children: [ backgroundColor: Theme.of(context).colorScheme.primary,
(description != null && textColor: Theme.of(context).colorScheme.onPrimary,
desktopLayoutNotRequired(context)) child: textWidget);
? TextSpan( }
text: description, if (description == null || description!.startsWith("\n")) {
style: const TextStyle(color: Colors.grey)) description = description?.removePrefix("\n");
: const TextSpan() return Column(
])) crossAxisAlignment: CrossAxisAlignment.start,
: Text(text, mainAxisSize: MainAxisSize.min,
style: mainAxisAlignment: MainAxisAlignment.center,
TextStyle(color: disabled ? Colors.grey : color))) 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()
]);
}
}))
]), ]),
)), )),
); );
@ -544,7 +564,9 @@ class _ScreenSettingsState extends State<ScreenSettings> {
}, },
context: context, context: context,
description: description:
"\n${AppLocalizations.of(context)!.settingsDescriptionVoice}") "\n${AppLocalizations.of(context)!.settingsDescriptionVoice}",
badge: AppLocalizations.of(context)!
.settingsExperimentalBeta)
: const SizedBox.shrink(), : const SizedBox.shrink(),
button( button(
AppLocalizations.of(context)!.settingsTitleExport, AppLocalizations.of(context)!.settingsTitleExport,

View File

@ -66,7 +66,14 @@ class _ScreenSettingsVoiceState extends State<ScreenSettingsVoice> {
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
child: Scaffold( child: Scaffold(
appBar: AppBar( 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( body: Padding(
padding: const EdgeInsets.only(left: 16, right: 16), padding: const EdgeInsets.only(left: 16, right: 16),
child: Column(children: [ child: Column(children: [