diff --git a/lib/main.dart b/lib/main.dart index fc7fe7a..36c2929 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -71,6 +71,7 @@ final user = types.User(id: const Uuid().v4()); final assistant = types.User(id: const Uuid().v4()); bool settingsOpen = false; +bool desktopTitleVisible = true; bool logoVisible = true; bool menuVisible = false; bool sendable = false; @@ -504,7 +505,7 @@ class _MainAppState extends State { if (chatUuid == jsonDecode(item)["uuid"]) { messages = []; chatUuid = null; - if (!desktopLayout(context)) { + if (!desktopLayoutRequired(context)) { Navigator.of(context).pop(); } } @@ -517,10 +518,11 @@ class _MainAppState extends State { borderRadius: BorderRadius.all(Radius.circular(50))), onTap: () { selectionHaptic(); - if (!desktopFeature()) { + if (!desktopLayoutRequired(context)) { Navigator.of(context).pop(); } if (!chatAllowed) return; + if (chatUuid == jsonDecode(item)["uuid"]) return; loadChat(jsonDecode(item)["uuid"], setState); chatUuid = jsonDecode(item)["uuid"]; }, @@ -671,18 +673,52 @@ class _MainAppState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( + titleSpacing: 0, title: Row( - children: desktopFeature() - ? [ - SizedBox(width: 85, height: 200, child: MoveWindow()), - Expanded( - child: SizedBox(height: 200, child: MoveWindow())), - selector, - Expanded( - child: SizedBox(height: 200, child: MoveWindow())) - ] - : [Expanded(child: selector)], - ), + children: desktopFeature() + ? desktopLayoutRequired(context) + ? [ + // bottom left tile + SizedBox( + width: 304, height: 200, child: MoveWindow()), + SizedBox( + height: 200, + child: AnimatedOpacity( + opacity: menuVisible ? 1.0 : 0.0, + duration: + const Duration(milliseconds: 300), + child: VerticalDivider( + width: 2, + color: Theme.of(context) + .colorScheme + .onSurface + .withAlpha(20)))), + AnimatedOpacity( + opacity: desktopTitleVisible ? 1.0 : 0.0, + duration: desktopTitleVisible + ? const Duration(milliseconds: 300) + : const Duration(milliseconds: 0), + child: Padding( + padding: const EdgeInsets.all(16), + child: selector, + ), + ), + Expanded( + child: SizedBox( + height: 200, child: MoveWindow())) + ] + : [ + SizedBox( + width: 90, height: 200, child: MoveWindow()), + Expanded( + child: SizedBox( + height: 200, child: MoveWindow())), + selector, + Expanded( + child: SizedBox( + height: 200, child: MoveWindow())) + ] + : [Expanded(child: selector)]), actions: desktopControlsActions(context, [ const SizedBox(width: 4), IconButton( @@ -786,8 +822,7 @@ class _MainAppState extends State { .onSurface .withAlpha(20))) : const SizedBox.shrink()), - leading: - desktopLayoutRequired(context) ? const SizedBox() : null), + automaticallyImplyLeading: !desktopLayoutRequired(context)), body: Row( children: [ desktopLayoutRequired(context) diff --git a/lib/worker/desktop.dart b/lib/worker/desktop.dart index a5a7d69..99a377a 100644 --- a/lib/worker/desktop.dart +++ b/lib/worker/desktop.dart @@ -24,6 +24,12 @@ bool desktopLayoutRequired(BuildContext context, return (desktopFeature(web: web) && value >= valueCap); } +bool desktopLayoutNotRequired(BuildContext context, + {bool web = false, double? value, double valueCap = 1000}) { + value ??= MediaQuery.of(context).size.width; + return (value >= valueCap); +} + Widget desktopControls(BuildContext context) { return SizedBox( height: 200, diff --git a/lib/worker/setter.dart b/lib/worker/setter.dart index 4c34427..6752253 100644 --- a/lib/worker/setter.dart +++ b/lib/worker/setter.dart @@ -21,6 +21,8 @@ void setModel(BuildContext context, Function setState) { int addIndex = -1; bool loaded = false; Function? setModalState; + desktopTitleVisible = false; + setState(() {}); void load() async { try { var list = await llama.OllamaClient( @@ -49,6 +51,9 @@ void setModel(BuildContext context, Function setState) { loaded = true; setModalState!(() {}); } catch (_) { + setState(() { + desktopTitleVisible = true; + }); // ignore: use_build_context_synchronously Navigator.of(context).pop(); // ignore: use_build_context_synchronously @@ -87,7 +92,9 @@ void setModel(BuildContext context, Function setState) { prefs?.remove("model"); } prefs?.setBool("multimodal", multimodal); - setState(() {}); + setState(() { + desktopTitleVisible = true; + }); }, child: Container( width: desktopLayout(context) ? null : double.infinity, @@ -111,7 +118,7 @@ void setModel(BuildContext context, Function setState) { child: Wrap( spacing: desktopLayout(context) ? 10.0 : 5.0, runSpacing: desktopFeature() - ? desktopLayoutRequired(context) + ? desktopFeature() ? 10.0 : 5.0 : 0.0, @@ -217,11 +224,20 @@ void setModel(BuildContext context, Function setState) { ]))); }); - if (desktopLayout(context)) { + if (desktopFeature()) { showDialog( context: context, builder: (context) { - return Dialog(alignment: Alignment.topCenter, child: content); + return Transform.translate( + offset: desktopLayoutRequired(context) + ? const Offset(289, 0) + : const Offset(0, 0), + child: Dialog( + alignment: desktopLayoutRequired(context) + ? Alignment.topLeft + : Alignment.topCenter, + child: content), + ); }); } else { showModalBottomSheet(context: context, builder: (context) => content);