<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2026, Jiri Eischmann <jiri@eischmann.cz> and the meshy contributors -->
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
<interface>
  <requires lib="gtk" version="4.0"/>
  <requires lib="libadwaita" version="1.0"/>

  <menu id="app_menu">
    <section>
      <item>
        <attribute name="label" translatable="yes">Disconnect</attribute>
        <attribute name="action">win.disconnect</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Settings</attribute>
        <attribute name="action">win.navigate-settings</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
        <attribute name="action">win.show-help-overlay</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Help</attribute>
        <attribute name="action">win.help</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">About Meshy</attribute>
        <attribute name="action">win.about</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Quit</attribute>
        <attribute name="action">win.quit</attribute>
      </item>
    </section>
  </menu>

  <menu id="connection_menu">
    <section>
      <item>
        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
        <attribute name="action">win.show-help-overlay</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Help</attribute>
        <attribute name="action">win.help</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">About Meshy</attribute>
        <attribute name="action">win.about</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">Quit</attribute>
        <attribute name="action">win.quit</attribute>
      </item>
    </section>
  </menu>

  <template class="MeshyWindow" parent="AdwApplicationWindow">
    <property name="default-width">800</property>
    <property name="default-height">600</property>
    <property name="title" translatable="no">Meshy</property>
    <property name="content">
      <object class="AdwToastOverlay" id="toast_overlay">
        <property name="child">
          <object class="GtkStack" id="main_stack">
            <property name="transition-type">crossfade</property>

            <!-- Connection screen (full window, no panels) -->
            <child>
              <object class="GtkStackPage">
                <property name="name">connection</property>
                <property name="child">
                  <object class="AdwToolbarView">
                    <child type="top">
                      <object class="AdwHeaderBar" id="connection_header">
                        <property name="title-widget">
                          <object class="AdwWindowTitle">
                            <property name="title" translatable="yes">Connect</property>
                          </object>
                        </property>
                        <child type="end">
                          <object class="GtkMenuButton">
                            <property name="icon-name">open-menu-symbolic</property>
                            <property name="menu-model">connection_menu</property>
                            <property name="tooltip-text" translatable="yes">Menu</property>
                            <style>
                              <class name="flat"/>
                            </style>
                          </object>
                        </child>
                      </object>
                    </child>
                    <child type="top">
                      <object class="AdwBanner" id="connection_screen_banner">
                        <property name="revealed">false</property>
                      </object>
                    </child>
                    <property name="content">
                      <object class="AdwClamp">
                        <property name="maximum-size">600</property>
                        <property name="child">
                          <object class="GtkBox" id="connection_box">
                            <property name="orientation">vertical</property>
                          </object>
                        </property>
                      </object>
                    </property>
                  </object>
                </property>
              </object>
            </child>

            <!-- Auto-connecting screen -->
            <child>
              <object class="GtkStackPage">
                <property name="name">connecting</property>
                <property name="child">
                  <object class="AdwToolbarView">
                    <child type="top">
                      <object class="AdwHeaderBar">
                        <property name="title-widget">
                          <object class="AdwWindowTitle">
                            <property name="title" translatable="yes">Meshy</property>
                          </object>
                        </property>
                        <child type="end">
                          <object class="GtkMenuButton">
                            <property name="icon-name">open-menu-symbolic</property>
                            <property name="menu-model">connection_menu</property>
                            <property name="tooltip-text" translatable="yes">Menu</property>
                            <style>
                              <class name="flat"/>
                            </style>
                          </object>
                        </child>
                      </object>
                    </child>
                    <property name="content">
                      <object class="AdwStatusPage" id="connecting_status">
                        <property name="icon-name">radiowaves-dots-symbolic</property>
                        <property name="title" translatable="yes">Connecting…</property>
                        <child>
                          <object class="GtkSpinner" id="connecting_spinner">
                            <property name="spinning">false</property>
                            <property name="halign">center</property>
                            <property name="width-request">32</property>
                            <property name="height-request">32</property>
                          </object>
                        </child>
                      </object>
                    </property>
                  </object>
                </property>
              </object>
            </child>

            <!-- Main app layout -->
            <child>
              <object class="GtkStackPage">
                <property name="name">main</property>
                <property name="child">
          <object class="AdwOverlaySplitView" id="outer_split">
            <property name="min-sidebar-width">52</property>
            <property name="max-sidebar-width">52</property>
            <property name="collapsed">false</property>
            <property name="pin-sidebar">true</property>

            <!-- Nav rail -->
            <property name="sidebar">
              <object class="GtkBox" id="nav_rail">
                <property name="orientation">vertical</property>
                <property name="spacing">4</property>
                <property name="width-request">52</property>
                <style>
                  <class name="nav-rail"/>
                </style>

                <child>
                  <object class="GtkToggleButton" id="nav_device">
                    <property name="icon-name">phone-old-symbolic</property>
                    <property name="tooltip-text" translatable="yes">Device</property>
                    <property name="width-request">44</property>
                    <property name="height-request">44</property>
                    <property name="halign">center</property>
                    <style>
                      <class name="flat"/>
                      <class name="circular"/>
                    </style>
                  </object>
                </child>
                <child>
                  <object class="GtkOverlay">
                    <property name="halign">center</property>
                    <child>
                      <object class="GtkToggleButton" id="nav_contacts">
                        <property name="icon-name">avatar-default-symbolic</property>
                        <property name="tooltip-text" translatable="yes">Contacts</property>
                        <property name="width-request">44</property>
                        <property name="height-request">44</property>
                        <property name="halign">center</property>
                        <style>
                          <class name="flat"/>
                          <class name="circular"/>
                        </style>
                      </object>
                    </child>
                    <child type="overlay">
                      <object class="GtkLabel" id="nav_contacts_dot">
                        <property name="visible">false</property>
                        <property name="halign">start</property>
                        <property name="valign">center</property>
                        <property name="margin-start">3</property>
                        <property name="can-target">false</property>
                        <style>
                          <class name="nav-unread-dot"/>
                        </style>
                      </object>
                    </child>
                  </object>
                </child>
                <child>
                  <object class="GtkOverlay">
                    <property name="halign">center</property>
                    <child>
                      <object class="GtkToggleButton" id="nav_channels">
                        <property name="icon-name">system-users-symbolic</property>
                        <property name="tooltip-text" translatable="yes">Channels</property>
                        <property name="width-request">44</property>
                        <property name="height-request">44</property>
                        <property name="halign">center</property>
                        <style>
                          <class name="flat"/>
                          <class name="circular"/>
                        </style>
                      </object>
                    </child>
                    <child type="overlay">
                      <object class="GtkLabel" id="nav_channels_dot">
                        <property name="visible">false</property>
                        <property name="halign">start</property>
                        <property name="valign">center</property>
                        <property name="margin-start">3</property>
                        <property name="can-target">false</property>
                        <style>
                          <class name="nav-unread-dot"/>
                        </style>
                      </object>
                    </child>
                  </object>
                </child>
                <child>
                  <object class="GtkToggleButton" id="nav_map">
                    <property name="icon-name">map-symbolic</property>
                    <property name="tooltip-text" translatable="yes">Map</property>
                    <property name="width-request">44</property>
                    <property name="height-request">44</property>
                    <property name="halign">center</property>
                    <style>
                      <class name="flat"/>
                      <class name="circular"/>
                    </style>
                  </object>
                </child>
                <!-- Spacer pushes settings to bottom -->
                <child>
                  <object class="GtkBox">
                    <property name="vexpand">true</property>
                  </object>
                </child>

                <child>
                  <object class="GtkToggleButton" id="nav_settings">
                    <property name="icon-name">emblem-system-symbolic</property>
                    <property name="tooltip-text" translatable="yes">Settings</property>
                    <property name="width-request">44</property>
                    <property name="height-request">44</property>
                    <property name="halign">center</property>
                    <property name="margin-bottom">4</property>
                    <style>
                      <class name="flat"/>
                      <class name="circular"/>
                    </style>
                  </object>
                </child>

              </object>
            </property>

            <!-- Inner split view -->
            <property name="content">
              <object class="AdwNavigationSplitView" id="split_view">
                <property name="min-sidebar-width">250</property>
                <property name="max-sidebar-width">360</property>

                <!-- Sidebar -->
                <property name="sidebar">
                  <object class="AdwNavigationPage" id="sidebar_page">
                    <property name="title" translatable="no">Meshy</property>
                    <property name="child">
                      <object class="AdwToolbarView">
                        <child type="top">
                          <object class="AdwHeaderBar" id="sidebar_header">
                            <property name="show-title">true</property>
                            <child type="start">
                              <object class="GtkButton" id="nav_rail_toggle">
                                <property name="icon-name">sidebar-show-symbolic</property>
                                <property name="tooltip-text" translatable="yes">Show navigation</property>
                                <property name="visible">false</property>
                                <style>
                                  <class name="flat"/>
                                </style>
                              </object>
                            </child>
                            <child type="end">
                              <object class="GtkMenuButton">
                                <property name="icon-name">open-menu-symbolic</property>
                                <property name="menu-model">app_menu</property>
                                <property name="tooltip-text" translatable="yes">Menu</property>
                                <style>
                                  <class name="flat"/>
                                </style>
                              </object>
                            </child>
                          </object>
                        </child>
                        <child type="top">
                          <object class="AdwBanner" id="sidebar_banner">
                            <property name="title" translatable="yes">Not connected</property>
                            <property name="revealed">true</property>
                            <property name="button-label" translatable="yes">Connect</property>
                          </object>
                        </child>
                        <property name="content">
                          <object class="GtkBox" id="sidebar_box">
                            <property name="orientation">vertical</property>
                          </object>
                        </property>
                      </object>
                    </property>
                  </object>
                </property>

                <!-- Content -->
                <property name="content">
                  <object class="AdwNavigationPage" id="content_page">
                    <property name="title" translatable="no">Meshy</property>
                    <property name="child">
                      <object class="AdwToolbarView">
                        <child type="top">
                          <object class="AdwHeaderBar" id="content_header">
                            <child type="start">
                              <object class="GtkBox" id="companion_box">
                                <property name="spacing">6</property>
                                <property name="visible">false</property>
                                <child>
                                  <object class="GtkLabel" id="companion_name_label">
                                    <property name="label"></property>
                                    <property name="ellipsize">end</property>
                                    <style>
                                      <class name="dim-label"/>
                                      <class name="caption"/>
                                    </style>
                                  </object>
                                </child>
                                <child>
                                  <object class="GtkLabel" id="companion_separator">
                                    <property name="label" translatable="no">·</property>
                                    <property name="visible">false</property>
                                    <style>
                                      <class name="dim-label"/>
                                      <class name="caption"/>
                                    </style>
                                  </object>
                                </child>
                                <child>
                                  <object class="GtkImage" id="companion_battery_icon">
                                    <property name="visible">false</property>
                                    <property name="pixel-size">16</property>
                                    <style>
                                      <class name="dim-label"/>
                                    </style>
                                  </object>
                                </child>
                                <child>
                                  <object class="GtkImage" id="companion_signal_icon">
                                    <property name="visible">false</property>
                                    <property name="pixel-size">16</property>
                                    <style>
                                      <class name="dim-label"/>
                                    </style>
                                  </object>
                                </child>
                              </object>
                            </child>
                          </object>
                        </child>
                        <property name="content">
                          <object class="GtkBox" id="content_box">
                            <property name="orientation">vertical</property>
                          </object>
                        </property>
                      </object>
                    </property>
                  </object>
                </property>

              </object>
            </property>

          </object>
                </property>
              </object>
            </child>

          </object>
        </property>
      </object>
    </property>
  </template>
</interface>
