Tried fixes for #26
This commit is contained in:
parent
0086ec63bc
commit
fcb20e7931
304
lib/main.dart
304
lib/main.dart
|
@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import 'screen_settings.dart';
|
import 'screen_settings.dart';
|
||||||
import 'screen_voice.dart';
|
import 'screen_voice.dart';
|
||||||
|
@ -34,6 +33,7 @@ import 'package:speech_to_text/speech_to_text.dart';
|
||||||
import 'package:flutter_tts/flutter_tts.dart';
|
import 'package:flutter_tts/flutter_tts.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
// client configuration
|
// client configuration
|
||||||
|
|
||||||
|
@ -881,47 +881,91 @@ class _MainAppState extends State<MainApp> {
|
||||||
right: 23,
|
right: 23,
|
||||||
top: 17,
|
top: 17,
|
||||||
bottom: 17),
|
bottom: 17),
|
||||||
child: MarkdownBody(
|
child: Theme(
|
||||||
data: p0.text,
|
data: Theme.of(context).copyWith(
|
||||||
onTapLink: (text, href, title) async {
|
scrollbarTheme:
|
||||||
selectionHaptic();
|
const ScrollbarThemeData(
|
||||||
try {
|
thumbColor:
|
||||||
var url = Uri.parse(href!);
|
WidgetStatePropertyAll(
|
||||||
if (await canLaunchUrl(url)) {
|
Colors.grey))),
|
||||||
launchUrl(
|
child: MarkdownBody(
|
||||||
mode: LaunchMode
|
data: p0.text,
|
||||||
.inAppBrowserView,
|
onTapLink: (text, href, title) async {
|
||||||
url);
|
selectionHaptic();
|
||||||
} else {
|
try {
|
||||||
throw Exception();
|
var url = Uri.parse(href!);
|
||||||
|
if (await canLaunchUrl(url)) {
|
||||||
|
launchUrl(
|
||||||
|
mode: LaunchMode
|
||||||
|
.inAppBrowserView,
|
||||||
|
url);
|
||||||
|
} else {
|
||||||
|
throw Exception();
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
context)!
|
||||||
|
.settingsHostInvalid(
|
||||||
|
"url")),
|
||||||
|
showCloseIcon: true));
|
||||||
}
|
}
|
||||||
} catch (_) {
|
},
|
||||||
// ignore: use_build_context_synchronously
|
extensionSet: md.ExtensionSet(
|
||||||
ScaffoldMessenger.of(context)
|
md.ExtensionSet.gitHubFlavored
|
||||||
.showSnackBar(SnackBar(
|
.blockSyntaxes,
|
||||||
content: Text(
|
<md.InlineSyntax>[
|
||||||
AppLocalizations.of(
|
md.EmojiSyntax(),
|
||||||
// ignore: use_build_context_synchronously
|
...md.ExtensionSet.gitHubFlavored
|
||||||
context)!
|
.inlineSyntaxes
|
||||||
.settingsHostInvalid(
|
],
|
||||||
"url")),
|
),
|
||||||
showCloseIcon: true));
|
imageBuilder: (uri, title, alt) {
|
||||||
}
|
if (uri.isAbsolute) {
|
||||||
},
|
return Image.network(
|
||||||
extensionSet: md.ExtensionSet(
|
uri.toString(), errorBuilder:
|
||||||
md.ExtensionSet.gitHubFlavored
|
(context, error,
|
||||||
.blockSyntaxes,
|
stackTrace) {
|
||||||
<md.InlineSyntax>[
|
return InkWell(
|
||||||
md.EmojiSyntax(),
|
onTap: () {
|
||||||
...md.ExtensionSet.gitHubFlavored
|
selectionHaptic();
|
||||||
.inlineSyntaxes
|
ScaffoldMessenger.of(
|
||||||
],
|
context)
|
||||||
),
|
.showSnackBar(SnackBar(
|
||||||
imageBuilder: (uri, title, alt) {
|
content: Text(
|
||||||
if (uri.isAbsolute) {
|
AppLocalizations.of(
|
||||||
return Image.network(uri.toString(),
|
context)!
|
||||||
errorBuilder: (context, error,
|
.notAValidImage),
|
||||||
stackTrace) {
|
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 {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
selectionHaptic();
|
selectionHaptic();
|
||||||
|
@ -954,108 +998,81 @@ class _MainAppState extends State<MainApp> {
|
||||||
child: const Image(
|
child: const Image(
|
||||||
image: AssetImage(
|
image: AssetImage(
|
||||||
"assets/logo512error.png"))));
|
"assets/logo512error.png"))));
|
||||||
});
|
}
|
||||||
} else {
|
},
|
||||||
return InkWell(
|
styleSheet: (p0.author == user)
|
||||||
onTap: () {
|
? MarkdownStyleSheet(
|
||||||
selectionHaptic();
|
p: const TextStyle(
|
||||||
ScaffoldMessenger.of(context)
|
color: Colors.white,
|
||||||
.showSnackBar(SnackBar(
|
fontSize: 16,
|
||||||
content: Text(
|
fontWeight:
|
||||||
AppLocalizations.of(
|
FontWeight.w500),
|
||||||
context)!
|
blockquoteDecoration:
|
||||||
.notAValidImage),
|
BoxDecoration(
|
||||||
showCloseIcon: true));
|
color: Colors.grey[800],
|
||||||
},
|
borderRadius:
|
||||||
child: Container(
|
BorderRadius.circular(
|
||||||
decoration: BoxDecoration(
|
8),
|
||||||
|
),
|
||||||
|
code: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
backgroundColor:
|
||||||
|
Colors.white),
|
||||||
|
codeblockDecoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
8)),
|
||||||
|
h1: white,
|
||||||
|
h2: white,
|
||||||
|
h3: white,
|
||||||
|
h4: white,
|
||||||
|
h5: white,
|
||||||
|
h6: white,
|
||||||
|
listBullet: white,
|
||||||
|
horizontalRuleDecoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color: Colors
|
||||||
|
.grey[800]!,
|
||||||
|
width: 1))),
|
||||||
|
tableBorder: TableBorder.all(
|
||||||
|
color: Colors.white),
|
||||||
|
tableBody: white)
|
||||||
|
: (Theme.of(context).brightness ==
|
||||||
|
Brightness.light)
|
||||||
|
? MarkdownStyleSheet(
|
||||||
|
p: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w500),
|
||||||
|
blockquoteDecoration:
|
||||||
|
BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius
|
BorderRadius
|
||||||
.circular(8),
|
.circular(8),
|
||||||
color: Theme.of(context)
|
),
|
||||||
.brightness ==
|
code: const TextStyle(
|
||||||
Brightness.light
|
color: Colors.white,
|
||||||
? Colors.white
|
backgroundColor:
|
||||||
: Colors.black),
|
Colors.black),
|
||||||
padding:
|
codeblockDecoration: BoxDecoration(color: Colors.black, borderRadius: BorderRadius.circular(8)),
|
||||||
const EdgeInsets.only(
|
horizontalRuleDecoration: BoxDecoration(border: Border(top: BorderSide(color: Colors.grey[200]!, width: 1))))
|
||||||
left: 100,
|
: MarkdownStyleSheet(
|
||||||
right: 100,
|
p: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
|
||||||
top: 32),
|
blockquoteDecoration: BoxDecoration(
|
||||||
child: const Image(
|
color:
|
||||||
image: AssetImage(
|
Colors.grey[800]!,
|
||||||
"assets/logo512error.png"))));
|
borderRadius:
|
||||||
}
|
BorderRadius
|
||||||
},
|
.circular(8),
|
||||||
styleSheet: (p0.author == user)
|
),
|
||||||
? MarkdownStyleSheet(
|
code: const TextStyle(color: Colors.black, backgroundColor: Colors.white),
|
||||||
p: const TextStyle(
|
codeblockDecoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||||
color: Colors.white,
|
horizontalRuleDecoration: BoxDecoration(border: Border(top: BorderSide(color: Colors.grey[200]!, width: 1))))),
|
||||||
fontSize: 16,
|
));
|
||||||
fontWeight:
|
|
||||||
FontWeight.w500),
|
|
||||||
blockquoteDecoration:
|
|
||||||
BoxDecoration(
|
|
||||||
color: Colors.grey[800],
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
code: const TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
backgroundColor:
|
|
||||||
Colors.white),
|
|
||||||
codeblockDecoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
8)),
|
|
||||||
h1: white,
|
|
||||||
h2: white,
|
|
||||||
h3: white,
|
|
||||||
h4: white,
|
|
||||||
h5: white,
|
|
||||||
h6: white,
|
|
||||||
listBullet: white,
|
|
||||||
horizontalRuleDecoration:
|
|
||||||
BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: Colors
|
|
||||||
.grey[800]!,
|
|
||||||
width: 1))),
|
|
||||||
tableBorder: TableBorder.all(
|
|
||||||
color: Colors.white),
|
|
||||||
tableBody: white)
|
|
||||||
: (Theme.of(context).brightness ==
|
|
||||||
Brightness.light)
|
|
||||||
? MarkdownStyleSheet(
|
|
||||||
p: const TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w500),
|
|
||||||
blockquoteDecoration:
|
|
||||||
BoxDecoration(
|
|
||||||
color: Colors.grey[200],
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(
|
|
||||||
8),
|
|
||||||
),
|
|
||||||
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(
|
|
||||||
p: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
|
|
||||||
blockquoteDecoration: BoxDecoration(
|
|
||||||
color: Colors.grey[800]!,
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(
|
|
||||||
8),
|
|
||||||
),
|
|
||||||
code: const TextStyle(color: Colors.black, backgroundColor: Colors.white),
|
|
||||||
codeblockDecoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
|
||||||
horizontalRuleDecoration: BoxDecoration(border: Border(top: BorderSide(color: Colors.grey[200]!, width: 1))))));
|
|
||||||
},
|
},
|
||||||
imageMessageBuilder: (p0,
|
imageMessageBuilder: (p0,
|
||||||
{required messageWidth}) {
|
{required messageWidth}) {
|
||||||
|
@ -1515,8 +1532,11 @@ class _MainAppState extends State<MainApp> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawerEdgeDragWidth:
|
drawerEdgeDragWidth: (prefs!.getBool("fixCodeblockScroll") ?? false)
|
||||||
desktopLayout(context) ? null : MediaQuery.of(context).size.width,
|
? null
|
||||||
|
: (desktopLayout(context)
|
||||||
|
? null
|
||||||
|
: MediaQuery.of(context).size.width),
|
||||||
drawer: Builder(builder: (context) {
|
drawer: Builder(builder: (context) {
|
||||||
if (desktopLayoutRequired(context) && !settingsOpen) {
|
if (desktopLayoutRequired(context) && !settingsOpen) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||||
import 'package:restart_app/restart_app.dart';
|
import 'package:restart_app/restart_app.dart';
|
||||||
import 'package:duration_picker/duration_picker.dart';
|
import 'package:duration_picker/duration_picker.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ScreenSettingsInterface extends StatefulWidget {
|
class ScreenSettingsInterface extends StatefulWidget {
|
||||||
const ScreenSettingsInterface({super.key});
|
const ScreenSettingsInterface({super.key});
|
||||||
|
@ -404,6 +405,21 @@ class _ScreenSettingsInterfaceState extends State<ScreenSettingsInterface> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
titleDivider(),
|
||||||
|
toggle(context, "Fix to code block not scrollable",
|
||||||
|
(prefs!.getBool("fixCodeblockScroll") ?? false),
|
||||||
|
(value) {
|
||||||
|
prefs!.setBool("fixCodeblockScroll", value);
|
||||||
|
if ((prefs!.getBool("fixCodeblockScroll") ?? false) ==
|
||||||
|
false) {
|
||||||
|
prefs!.remove("fixCodeblockScroll");
|
||||||
|
}
|
||||||
|
selectionHaptic();
|
||||||
|
setState(() {});
|
||||||
|
}, onLongTap: () {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
"https://github.com/JHubi1/ollama-app/issues/26"));
|
||||||
|
}),
|
||||||
const SizedBox(height: 16)
|
const SizedBox(height: 16)
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue