Skip to content

Commit

Permalink
Restrict desktop settings width, centralized delete dialog, allow cha…
Browse files Browse the repository at this point in the history
…nging titles and deleting non current chats
  • Loading branch information
JHubi1 committed Aug 20, 2024
1 parent 8813571 commit efcca11
Show file tree
Hide file tree
Showing 10 changed files with 1,194 additions and 1,286 deletions.
685 changes: 215 additions & 470 deletions lib/main.dart

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions lib/screen_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ Widget title(String text, {double top = 16, double bottom = 16}) {
Padding(
padding: const EdgeInsets.only(left: 24, right: 24),
child: Text(text)),
const Expanded(child: Divider())
const Expanded(child: Divider(height: 1))
]));
}

Widget titleDivider({double? top, double? bottom, BuildContext? context}) {
top ??= (context != null && desktopLayoutNotRequired(context)) ? 32 : 16;
bottom ??= (context != null && desktopLayoutNotRequired(context)) ? 32 : 16;
return Padding(
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: EdgeInsets.only(left: 8, right: 8, top: top, bottom: bottom),
child: const Row(
mainAxisSize: MainAxisSize.max,
Expand All @@ -143,13 +144,12 @@ Widget verticalTitleDivider(
{double? left, double? right, BuildContext? context}) {
left ??= (context != null && desktopLayoutNotRequired(context)) ? 32 : 16;
right ??= (context != null && desktopLayoutNotRequired(context)) ? 32 : 16;
return Padding(
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: EdgeInsets.only(left: left, right: right, top: 8, bottom: 8),
child: const Row(mainAxisSize: MainAxisSize.max, children: [
// Expanded(child:
VerticalDivider()
// ),
]));
child: const Row(
mainAxisSize: MainAxisSize.max,
children: [VerticalDivider(width: 1)]));
}

Widget button(String text, IconData? icon, void Function()? onPressed,
Expand Down Expand Up @@ -359,6 +359,7 @@ class _ScreenSettingsState extends State<ScreenSettings> {
TextField(
controller: hostInputController,
keyboardType: TextInputType.url,
autofillHints: const [AutofillHints.url],
readOnly: useHost,
onSubmitted: (value) {
selectionHaptic();
Expand Down
241 changes: 124 additions & 117 deletions lib/settings/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,123 +42,130 @@ class _ScreenSettingsAboutState extends State<ScreenSettingsAbout> {
Expanded(child: SizedBox(height: 200, child: MoveWindow()))
]),
actions: desktopControlsActions(context)),
body: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Column(children: [
Expanded(
child: ListView(children: [
// const SizedBox(height: 8),
button(
AppLocalizations.of(context)!
.settingsVersion(currentVersion ?? ""),
Icons.verified_rounded,
null),
(updateStatus == "notAvailable")
? const SizedBox.shrink()
: button(
(!updateChecked
? AppLocalizations.of(context)!
.settingsUpdateCheck
: updateLoading
? AppLocalizations.of(context)!
.settingsUpdateChecking
: (updateStatus == "rateLimit")
? AppLocalizations.of(context)!
.settingsUpdateRateLimit
: (updateStatus != "ok")
? AppLocalizations.of(context)!
.settingsUpdateIssue
: (Version.parse(latestVersion ??
"1.0.0") >
Version.parse(
currentVersion ??
"2.0.0"))
? AppLocalizations.of(context)!
.settingsUpdateAvailable(
latestVersion!)
: AppLocalizations.of(context)!
.settingsUpdateLatest),
((updateStatus != "ok")
? Icons.warning_rounded
: (Version.parse(latestVersion ?? "1.0.0") >
Version.parse(
currentVersion ?? "2.0.0"))
? Icons.info_outline_rounded
: Icons.update_rounded), () {
if (updateLoading) return;
selectionHaptic();
if ((Version.parse(latestVersion ?? "1.0.0") >
Version.parse(currentVersion ?? "2.0.0")) &&
(updateStatus == "ok")) {
updateDialog(context, title);
} else {
checkUpdate(setState);
return;
}
}),
(updateStatus == "notAvailable")
? const SizedBox.shrink()
: toggle(
context,
AppLocalizations.of(context)!
.settingsCheckForUpdates,
(prefs!.getBool("checkUpdateOnSettingsOpen") ??
false), (value) {
selectionHaptic();
prefs!.setBool("checkUpdateOnSettingsOpen", value);
setState(() {});
}),
titleDivider(context: context),
button(AppLocalizations.of(context)!.settingsGithub,
SimpleIcons.github, () {
selectionHaptic();
launchUrl(
mode: LaunchMode.inAppBrowserView,
Uri.parse(repoUrl));
}),
button(AppLocalizations.of(context)!.settingsReportIssue,
Icons.report_rounded, () {
selectionHaptic();
launchUrl(
mode: LaunchMode.inAppBrowserView,
Uri.parse("$repoUrl/issues"));
}),
button(AppLocalizations.of(context)!.settingsLicenses,
Icons.gavel_rounded, () {
selectionHaptic();
String legal = "Copyright 2024 JHubi1";
Widget icon = const Padding(
padding: EdgeInsets.all(16),
child: ImageIcon(AssetImage("assets/logo512.png"),
size: 48),
);
if (desktopFeature()) {
showDialog(
context: context,
builder: (context) {
return Dialog(
child: ClipRRect(
borderRadius: BorderRadius.circular(28),
child: LicensePage(
applicationName: "Ollama App",
applicationVersion: currentVersion,
applicationIcon: icon,
applicationLegalese: legal),
));
});
} else {
showLicensePage(
context: context,
applicationName: "Ollama App",
applicationVersion: currentVersion,
applicationIcon: icon,
applicationLegalese: legal);
}
}),
const SizedBox(height: 16)
]),
)
]))),
body: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 1000),
padding: const EdgeInsets.only(left: 16, right: 16),
child: Column(children: [
Expanded(
child: ListView(children: [
// const SizedBox(height: 8),
button(
AppLocalizations.of(context)!
.settingsVersion(currentVersion ?? ""),
Icons.verified_rounded,
null),
(updateStatus == "notAvailable")
? const SizedBox.shrink()
: button(
(!updateChecked
? AppLocalizations.of(context)!
.settingsUpdateCheck
: updateLoading
? AppLocalizations.of(context)!
.settingsUpdateChecking
: (updateStatus == "rateLimit")
? AppLocalizations.of(context)!
.settingsUpdateRateLimit
: (updateStatus != "ok")
? AppLocalizations.of(context)!
.settingsUpdateIssue
: (Version.parse(latestVersion ??
"1.0.0") >
Version.parse(
currentVersion ??
"2.0.0"))
? AppLocalizations.of(
context)!
.settingsUpdateAvailable(
latestVersion!)
: AppLocalizations.of(
context)!
.settingsUpdateLatest),
((updateStatus != "ok")
? Icons.warning_rounded
: (Version.parse(latestVersion ?? "1.0.0") >
Version.parse(
currentVersion ?? "2.0.0"))
? Icons.info_outline_rounded
: Icons.update_rounded), () {
if (updateLoading) return;
selectionHaptic();
if ((Version.parse(latestVersion ?? "1.0.0") >
Version.parse(
currentVersion ?? "2.0.0")) &&
(updateStatus == "ok")) {
updateDialog(context, title);
} else {
checkUpdate(setState);
return;
}
}),
(updateStatus == "notAvailable")
? const SizedBox.shrink()
: toggle(
context,
AppLocalizations.of(context)!
.settingsCheckForUpdates,
(prefs!.getBool("checkUpdateOnSettingsOpen") ??
false), (value) {
selectionHaptic();
prefs!
.setBool("checkUpdateOnSettingsOpen", value);
setState(() {});
}),
titleDivider(context: context),
button(AppLocalizations.of(context)!.settingsGithub,
SimpleIcons.github, () {
selectionHaptic();
launchUrl(
mode: LaunchMode.inAppBrowserView,
Uri.parse(repoUrl));
}),
button(AppLocalizations.of(context)!.settingsReportIssue,
Icons.report_rounded, () {
selectionHaptic();
launchUrl(
mode: LaunchMode.inAppBrowserView,
Uri.parse("$repoUrl/issues"));
}),
button(AppLocalizations.of(context)!.settingsLicenses,
Icons.gavel_rounded, () {
selectionHaptic();
String legal = "Copyright 2024 JHubi1";
Widget icon = const Padding(
padding: EdgeInsets.all(16),
child: ImageIcon(AssetImage("assets/logo512.png"),
size: 48),
);
if (desktopFeature()) {
showDialog(
context: context,
builder: (context) {
return Dialog(
child: ClipRRect(
borderRadius: BorderRadius.circular(28),
child: LicensePage(
applicationName: "Ollama App",
applicationVersion: currentVersion,
applicationIcon: icon,
applicationLegalese: legal),
));
});
} else {
showLicensePage(
context: context,
applicationName: "Ollama App",
applicationVersion: currentVersion,
applicationIcon: icon,
applicationLegalese: legal);
}
}),
const SizedBox(height: 16)
]),
)
])),
)),
);
}
}
Loading

0 comments on commit efcca11

Please sign in to comment.