using Gtk 4.0;
using Adw 1;

menu mainMenu {
  item (_("Currency Converter"), "win.currencyConverter")
  
  section {
    item(_("Preferences"), "win.preferences")
    item(_("Keyboard Shortcuts"), "win.keyboardShortcuts")
    item(_("Help"), "win.help")
    item(_("About Denaro"), "win.about")
  }
}

Adw.ApplicationWindow _root {
  default-width: 900;
  default-height: 720;
  width-request: 360;
  
  Adw.ToolbarView _toolbarView {
    [top]
    Adw.HeaderBar {
      title-widget: Adw.WindowTitle _windowTitle {};
      
      [start]
      Gtk.MenuButton _accountMenuButton {
        icon-name: "bank-symbolic";
        tooltip-text: _("Account Menu");
        visible: false;
        popover: Gtk.Popover _accountPopover {
          Gtk.Box {
            orientation: vertical;
            spacing: 10;
            margin-start: 5;
            margin-end: 5;
            margin-top: 5;
            margin-bottom: 5;
            width-request: 300;

            Gtk.Box {
              orientation: horizontal;
              hexpand: true;

              Gtk.Label {
                halign: start;
                hexpand: true;
                label: _("Recents");

                styles ["title-4"]
              }

              Gtk.Box {
                halign: end;
                margin-start: 6;

                Gtk.Button {
                  tooltip-text: _("New Account (Ctrl+N)");
                  action-name: "win.newAccount";

                  Adw.ButtonContent {
                    label: C_("Account", "New");
                    icon-name: "document-new-symbolic";
                  }

                  styles ["suggested-action"]
                }

                Gtk.Button {
                  icon-name: "document-open-symbolic";
                  tooltip-text: _("Open Account (Ctrl+O)");
                  action-name: "win.openAccount";
                }

                styles ["linked"]
              }
            }

            Gtk.Separator {

            }

            Adw.ViewStack _viewStackAccountPopover {
              Adw.ViewStackPage {
                name: "no-recents";
                child: Adw.StatusPage {
                  title: _("No Recent Accounts");
                  icon-name: "document-open-recent-symbolic";

                  styles ["compact"]
                };
              }

              Adw.ViewStackPage {
                name: "recents";
                child: Adw.PreferencesGroup _recentAccountsGroup {

                };
              }
            }
          }
        };
      }
      
      [start]
      Gtk.ToggleButton _flapToggleButton {
        icon-name: "sidebar-show-symbolic";
        tooltip-text: _("Toggle Sidebar");
        active: true;
        visible: false;
      }
      
      [start]
      Gtk.ToggleButton _graphToggleButton {
        icon-name: "dock-top-symbolic";
        tooltip-text: _("Toggle Graphs");
        active: true;
        visible: false;
      }


      [end]
      Gtk.MenuButton {
        direction: none;
        menu-model: mainMenu;
        tooltip-text: _("Main Menu");
        primary: true;
      }

      [end]
      Gtk.ToggleButton _dashboardButton {
        icon-name: "resources-symbolic";
        tooltip-text: _("Dashboard");
        visible: false;
      }

      styles ["flat"]
    }
    
    content: Adw.ToastOverlay _toastOverlay {
      hexpand: true;
      vexpand: true;
      
      Adw.ViewStack _viewStack {
        Adw.ViewStackPage {
          name:"pageNoAccounts";
          child: Gtk.ScrolledWindow {
            Adw.Clamp {
              maximum-size: 420;
              valign: center;
              margin-start: 12;
              margin-end: 12;
              margin-top: 12;
              margin-bottom: 12;
              
              Gtk.Box {
                orientation: vertical;
                spacing: 12;
                hexpand: true;
                halign: fill;
                
                Gtk.Box {
                  halign: center;
                  margin-top: 24;
                  margin-bottom: 14;
                
                  Gtk.Image _greetingIcon {
                    pixel-size: 48;
                    margin-end: 12;
                  }  
                  
                  Gtk.Label _greetingLabel {                  
                    styles ["greeting-title"]
                  }
                }
                
                Gtk.Label _dragLabel {
                  label: _("Create or open an account to get started. You may also drag a file into the app from your file browser.");
                  wrap: true;
                  justify: center;
                  visible: bind _startPageRecentAccountsGroup.visible inverted;
                  
                  styles ["dim-label"]
                }
                
                Adw.PreferencesGroup _startPageRecentAccountsGroup {
                  title: _("Recent Accounts");
                  width-request: 200;
                  height-request: 55;
                  margin-top: 24;
                  margin-bottom: 24;
                  visible: false;
                }
                
                Gtk.FlowBox {
                  margin-bottom: 12;
                  column-spacing: 4;
                  row-spacing: 4;
                  max-children-per-line: 2;
                  homogeneous: true;
                  hexpand: true;
                  halign: fill;
                  selection-mode: none;
                  
                  Gtk.FlowBoxChild {
                    focusable: false;
                    
                    Gtk.Button _newAccountButton {
                      label: _("New Account");
                      action-name: "win.newAccount";
                      halign: center;
                      
                      styles ["pill", "suggested-action"]
                    }
                  }
                  
                  Gtk.FlowBoxChild {
                    focusable: false;
                    
                    Gtk.Button _openAccountButton {
                      label: _("Open Account");
                      action-name: "win.openAccount";
                      halign: center;
                      
                      styles ["pill"]
                    }
                  }
                }
              }  
            }
          };
        }
        
        Adw.ViewStackPage {
          name: "pageTabs";
          child: Gtk.Box {
            orientation: vertical;
            
            Adw.TabBar {
              view: _tabView;
            }
            
            Adw.TabView _tabView {}
          };
        }

        Adw.ViewStackPage {
          name: "dashboard";
          child: Adw.Bin _dashboardBin {
          };
        }
      }
    };
  }
}