From cafc161aac482b2473123a547f5b549d186b0797 Mon Sep 17 00:00:00 2001 From: JHubi1 Date: Mon, 3 Jun 2024 16:46:58 +0200 Subject: [PATCH] Fixed send button, now throw exception is message empty --- lib/l10n/app_en.arb | 2 +- lib/main.dart | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3e5c259..e6b8863 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -170,7 +170,7 @@ "description": "Text displayed when the host is being checked", "context": "Visible in the settings view" }, - "settingsHostInvalid": "Issue: {type, select, url{Invalid URL} host{Invalid Host} other{Request Failed}}", + "settingsHostInvalid": "Issue: {type, select, url{Invalid URL} host{Invalid Host} timeout{Request Failed. Server issues} other{Request Failed}}", "@settingsHostInvalid": { "description": "Text displayed when the host is invalid", "context": "Visible in the settings view", diff --git a/lib/main.dart b/lib/main.dart index e01dcc2..040f7db 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -171,6 +171,7 @@ class _MainAppState extends State { bool menuVisible = false; int tipId = Random().nextInt(5); + bool sendable = false; List sidebar(BuildContext context, Function setState) { return List.from([ @@ -1147,6 +1148,9 @@ class _MainAppState extends State { } } if (chatAllowed) return; + if (text.trim() == "") { + throw Exception(); + } messages.insert( 0, types.TextMessage( @@ -1168,6 +1172,9 @@ class _MainAppState extends State { ) .timeout(const Duration(seconds: 15)); if (chatAllowed) return; + if (request.message!.content.trim() == "") { + throw Exception(); + } messages.insert( 0, types.TextMessage( @@ -1496,10 +1503,16 @@ class _MainAppState extends State { l10n: ChatL10nEn( inputPlaceholder: AppLocalizations.of(context)! .messageInputPlaceholder), - inputOptions: const InputOptions( + inputOptions: InputOptions( keyboardType: TextInputType.multiline, - sendButtonVisibilityMode: - SendButtonVisibilityMode.always), + onTextChanged: (p0) { + setState(() { + sendable = p0.trim().isNotEmpty; + }); + }, + sendButtonVisibilityMode: (sendable) + ? SendButtonVisibilityMode.always + : SendButtonVisibilityMode.hidden), user: user, hideBackgroundOnEmojiMessages: false, theme: (Theme.of(context).brightness == Brightness.light)