using Gtk 4.0;
using Adw 1;

Adw.Window _root {
  width-request: 360;
  default-width: 440;
  modal: true;
  resizable: true;
  
  content: Adw.ToastOverlay _toastOverlay {
    Adw.ToolbarView {
      [top]
      Adw.HeaderBar _header {
        title-widget: Gtk.Label {};
      }
      
      Gtk.WindowHandle {
        Gtk.Box {
          orientation: vertical;
          spacing: 24;
          margin-start: 24;
          margin-end: 24;
          margin-bottom: 24;
          
          Gtk.Label _titleLabel {
            label: _("Converter");
  
            styles ["title-2"]
          }
          
          Adw.PreferencesGroup {
            title: _("Currency");
          
            header-suffix: Gtk.Box {
              orientation: horizontal;
              spacing: 6;
              
              Gtk.Button _switchButton {
                valign: center;
                tooltip-text: _("Switch currencies");
                
                Adw.ButtonContent {
                  label: _("Switch");
                  icon-name: "update-symbolic";
                }
                
                styles ["flat"]
              }
              
              Gtk.Box _loadingBox {
                orientation: horizontal;
                spacing: 6;
                visible: false;
                
                Gtk.Separator {
                  orientation: vertical;
                }
                
                Gtk.Label {
                  label: _("Loading...");
                }
                
                Gtk.Spinner {
                  spinning: true;
                }
              }
            };
            
            Adw.ComboRow _sourceCurrencyRow {
              title: _("Source");
            }
            
            Adw.ComboRow _resultCurrencyRow {
              title: _("Result");
            }
          }

          Adw.PreferencesGroup {
            Adw.EntryRow _sourceAmountRow { }

            Adw.EntryRow _resultAmountRow {
              editable: false;

              [suffix]
              Gtk.Button _copyResultButton {
                valign: center;
                tooltip-text: _("Copy Result Amount");
                icon-name: "edit-copy-symbolic";

                styles ["flat"]
              }
            }
          }
        }
      }
    }
  };
  
  Gtk.ShortcutController {
    Gtk.Shortcut {
      trigger: "Escape";
      action: "action(window.close)";
    }
  }
}