Removed back to exit

Need feature in theory, but the implementation is lacking and will block the android app. I may revisit this in the future
This commit is contained in:
JHubi1 2024-08-20 18:27:46 +02:00
parent 732ad10b14
commit 68d2bc343f
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
4 changed files with 878 additions and 923 deletions

View File

@ -5,11 +5,6 @@
"description": "Title of the application",
"context": "Visible in the side bar"
},
"backToExit": "Press back again to exit",
"@backToExit": {
"description": "Text displayed when the back button is pressed to exit the app",
"context": "Visible in the chat view"
},
"optionNewChat": "New Chat",
"@optionNewChat": {
"description": "Text displayed for new chat option",

View File

@ -4,7 +4,6 @@ import 'dart:math';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -70,7 +69,6 @@ String hoveredChat = "";
final user = types.User(id: const Uuid().v4());
final assistant = types.User(id: const Uuid().v4());
int backPullTimestamp = 0;
bool settingsOpen = false;
bool desktopTitleVisible = true;
bool logoVisible = true;
@ -114,16 +112,6 @@ class _AppState extends State<App> {
void initState() {
super.initState();
SystemChannels.lifecycle.setMessageHandler((msg) async {
if (msg == AppLifecycleState.resumed.toString()) {
// reset back pull timestamp
setState(() {
backPullTimestamp = 0;
});
}
return null;
});
void load() async {
try {
await FlutterDisplayMode.setHighRefreshRate();
@ -983,21 +971,6 @@ class _MainAppState extends State<MainApp> {
return WindowBorder(
color: Theme.of(context).colorScheme.surface,
child: PopScope(
// disabled for now, shows buggy behavior if enabled
canPop: true,
// DateTime.now().millisecondsSinceEpoch < (backPullTimestamp + 2000),
onPopInvoked: (didPop) {
if (!didPop) {
setState(() {
backPullTimestamp = DateTime.now().microsecondsSinceEpoch;
});
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(AppLocalizations.of(context)!.backToExit),
duration: const Duration(seconds: 2),
showCloseIcon: true));
}
},
child: Scaffold(
appBar: AppBar(
titleSpacing: 0,
@ -1006,9 +979,7 @@ class _MainAppState extends State<MainApp> {
? desktopLayoutRequired(context)
? [
SizedBox(
width: 304,
height: 200,
child: MoveWindow()),
width: 304, height: 200, child: MoveWindow()),
SizedBox(
height: 200,
child: AnimatedOpacity(
@ -1037,9 +1008,7 @@ class _MainAppState extends State<MainApp> {
]
: [
SizedBox(
width: 90,
height: 200,
child: MoveWindow()),
width: 90, height: 200, child: MoveWindow()),
Expanded(
child: SizedBox(
height: 200, child: MoveWindow())),
@ -1100,8 +1069,7 @@ class _MainAppState extends State<MainApp> {
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(AppLocalizations.of(
context)!
Text(AppLocalizations.of(context)!
.deleteDialogDescription),
]),
actions: [
@ -1110,8 +1078,8 @@ class _MainAppState extends State<MainApp> {
selectionHaptic();
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(
context)!
child: Text(
AppLocalizations.of(context)!
.deleteDialogCancel)),
TextButton(
onPressed: () {
@ -1143,8 +1111,8 @@ class _MainAppState extends State<MainApp> {
chatUuid = null;
setState(() {});
},
child: Text(AppLocalizations.of(
context)!
child: Text(
AppLocalizations.of(context)!
.deleteDialogDelete))
]);
});
@ -1233,8 +1201,7 @@ class _MainAppState extends State<MainApp> {
child: Chat(
messages: messages,
textMessageBuilder: (p0,
{required messageWidth,
required showName}) {
{required messageWidth, required showName}) {
var white =
const TextStyle(color: Colors.white);
bool greyed = false;
@ -1289,54 +1256,16 @@ class _MainAppState extends State<MainApp> {
.blockSyntaxes,
<md.InlineSyntax>[
md.EmojiSyntax(),
...md
.ExtensionSet
.gitHubFlavored
...md.ExtensionSet.gitHubFlavored
.inlineSyntaxes
],
),
imageBuilder: (uri, title, alt) {
if (uri.isAbsolute) {
return Image.network(
uri.toString(),
errorBuilder: (context,
error, stackTrace) {
return InkWell(
onTap: () {
selectionHaptic();
ScaffoldMessenger.of(
context)
.showSnackBar(SnackBar(
content: Text(
AppLocalizations.of(
context)!
.notAValidImage),
showCloseIcon:
true));
},
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(
8),
color: Theme.of(context)
.brightness ==
Brightness
.light
? Colors.white
: Colors
.black),
padding:
const EdgeInsets.only(
left: 100,
right: 100,
top: 32),
child: const Image(
image: AssetImage(
"assets/logo512error.png"))));
});
} else {
uri.toString(), errorBuilder:
(context, error,
stackTrace) {
return InkWell(
onTap: () {
selectionHaptic();
@ -1371,6 +1300,40 @@ class _MainAppState extends State<MainApp> {
child: const Image(
image: AssetImage(
"assets/logo512error.png"))));
});
} else {
return InkWell(
onTap: () {
selectionHaptic();
ScaffoldMessenger.of(
context)
.showSnackBar(SnackBar(
content: Text(
AppLocalizations.of(
context)!
.notAValidImage),
showCloseIcon:
true));
},
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(8),
color: Theme.of(context)
.brightness ==
Brightness
.light
? Colors.white
: Colors.black),
padding:
const EdgeInsets.only(
left: 100,
right: 100,
top: 32),
child: const Image(
image: AssetImage(
"assets/logo512error.png"))));
}
},
styleSheet: (p0.author == user)
@ -1391,11 +1354,9 @@ class _MainAppState extends State<MainApp> {
color: Colors.black,
backgroundColor:
Colors.white),
codeblockDecoration:
BoxDecoration(
codeblockDecoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.circular(
borderRadius: BorderRadius.circular(
8)),
h1: white,
h2: white,
@ -1417,17 +1378,22 @@ class _MainAppState extends State<MainApp> {
Brightness.light)
? MarkdownStyleSheet(
p: TextStyle(
color: greyed ? Colors.grey : Colors.black,
color: greyed
? Colors.grey
: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w500),
blockquoteDecoration: BoxDecoration(
color:
Colors.grey[200],
fontWeight:
FontWeight.w500),
blockquoteDecoration:
BoxDecoration(
color: Colors.grey[200],
borderRadius:
BorderRadius
.circular(8),
),
code: const TextStyle(color: Colors.white, backgroundColor: Colors.black),
code: const TextStyle(
color: Colors.white,
backgroundColor: Colors.black),
codeblockDecoration: BoxDecoration(color: Colors.black, borderRadius: BorderRadius.circular(8)),
horizontalRuleDecoration: BoxDecoration(border: Border(top: BorderSide(color: Colors.grey[200]!, width: 1))))
: MarkdownStyleSheet(
@ -1447,9 +1413,8 @@ class _MainAppState extends State<MainApp> {
imageMessageBuilder: (p0,
{required messageWidth}) {
return SizedBox(
width: desktopLayout(context)
? 360.0
: 160.0,
width:
desktopLayout(context) ? 360.0 : 160.0,
child: MarkdownBody(
data: "![${p0.name}](${p0.uri})"));
},
@ -1460,17 +1425,17 @@ class _MainAppState extends State<MainApp> {
onVisibilityChanged:
(VisibilityInfo info) {
if (settingsOpen) return;
logoVisible =
info.visibleFraction > 0;
logoVisible = info.visibleFraction > 0;
try {
setState(() {});
} catch (_) {}
},
child: AnimatedOpacity(
opacity: logoVisible ? 1.0 : 0.0,
duration: const Duration(
milliseconds: 500),
child: const ImageIcon(AssetImage("assets/logo512.png"),
duration:
const Duration(milliseconds: 500),
child: const ImageIcon(
AssetImage("assets/logo512.png"),
size: 44)))),
onSendPressed: (p0) {
send(p0.text, context, setState);
@ -1531,8 +1496,7 @@ class _MainAppState extends State<MainApp> {
}
var text =
(messages[index] as types.TextMessage)
.text;
(messages[index] as types.TextMessage).text;
var input = await prompt(
context,
title: AppLocalizations.of(context)!
@ -1590,10 +1554,8 @@ class _MainAppState extends State<MainApp> {
types.ImageMessage(
author: user,
id: const Uuid().v4(),
name:
value.files.first.name,
size:
value.files.first.size,
name: value.files.first.name,
size: value.files.first.size,
uri:
"data:image/png;base64,$encoded"));
@ -1607,8 +1569,7 @@ class _MainAppState extends State<MainApp> {
builder: (context) {
return Container(
width: double.infinity,
padding:
const EdgeInsets.only(
padding: const EdgeInsets.only(
left: 16,
right: 16,
top: 16),
@ -1635,12 +1596,15 @@ class _MainAppState extends State<MainApp> {
true;
logoVisible =
false;
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const ScreenVoice()));
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
const ScreenVoice()));
},
icon: const Icon(Icons
icon: const Icon(
Icons
.headphones_rounded),
label: Text(AppLocalizations.of(context)!
label: Text(
AppLocalizations.of(context)!
.settingsTitleVoice)))
: const SizedBox
.shrink(),
@ -1666,8 +1630,8 @@ class _MainAppState extends State<MainApp> {
final result =
await ImagePicker()
.pickImage(
source:
ImageSource.camera,
source: ImageSource
.camera,
);
if (result ==
null) {
@ -1687,7 +1651,8 @@ class _MainAppState extends State<MainApp> {
author:
user,
createdAt:
DateTime.now().millisecondsSinceEpoch,
DateTime.now()
.millisecondsSinceEpoch,
height: image
.height
.toDouble(),
@ -1714,11 +1679,10 @@ class _MainAppState extends State<MainApp> {
icon: const Icon(
Icons
.photo_camera_rounded),
label: Text(
AppLocalizations.of(context)!
label: Text(AppLocalizations.of(
context)!
.takeImage))),
const SizedBox(
height: 8),
const SizedBox(height: 8),
SizedBox(
width:
double.infinity,
@ -1734,8 +1698,8 @@ class _MainAppState extends State<MainApp> {
final result =
await ImagePicker()
.pickImage(
source:
ImageSource.gallery,
source: ImageSource
.gallery,
);
if (result ==
null) {
@ -1755,7 +1719,8 @@ class _MainAppState extends State<MainApp> {
author:
user,
createdAt:
DateTime.now().millisecondsSinceEpoch,
DateTime.now()
.millisecondsSinceEpoch,
height: image
.height
.toDouble(),
@ -1782,8 +1747,8 @@ class _MainAppState extends State<MainApp> {
icon: const Icon(
Icons
.image_rounded),
label: Text(
AppLocalizations.of(context)!
label: Text(AppLocalizations.of(
context)!
.uploadImage)))
]));
});
@ -1923,7 +1888,6 @@ class _MainAppState extends State<MainApp> {
selectedIndex: 1,
children: sidebar(context, setState));
})),
),
);
}
}

View File

@ -32,18 +32,18 @@ void main() async {
// ----------
await execute('Windows x64', flutterExecutable, [
'build',
'windows',
'--obfuscate',
'--split-debug-info=build\\debugWindows'
]);
// await execute('Windows x64', flutterExecutable, [
// 'build',
// 'windows',
// '--obfuscate',
// '--split-debug-info=build\\debugWindows'
// ]);
await execute(
'Windows x64 installer',
'iscc.exe',
['windows_installer/x64.iss', '/qp', '/dAppVersion=$version'],
" > Inno Setup is not installed. Please install it from https://www.jrsoftware.org/isdl.php#stable\n Then add the Inno Setup directory to your PATH environment variable.");
// await execute(
// 'Windows x64 installer',
// 'iscc.exe',
// ['windows_installer/x64.iss', '/qp', '/dAppVersion=$version'],
// " > Inno Setup is not installed. Please install it from https://www.jrsoftware.org/isdl.php#stable\n Then add the Inno Setup directory to your PATH environment variable.");
// ----------

View File

@ -1,6 +1,5 @@
{
"de": [
"backToExit",
"deleteChat",
"renameChat",
"settingsDescriptionBehavior",
@ -22,7 +21,6 @@
],
"it": [
"backToExit",
"deleteChat",
"renameChat",
"settingsDescriptionBehavior",
@ -44,7 +42,6 @@
],
"tr": [
"backToExit",
"deleteChat",
"renameChat",
"settingsDescriptionBehavior",
@ -66,7 +63,6 @@
],
"zh": [
"backToExit",
"deleteChat",
"renameChat",
"settingsDescriptionBehavior",