using Gtk 4.0;
using Adw 1;

template $ExmUpgradeAssistant: Adw.Dialog {
  content-width: 400;
  content-height: 600;
  title: _("Upgrade Assistant");
  notify::manager => $on_bind_manager();

  child: Adw.ToolbarView {
    [top]
    Adw.HeaderBar {}

    content: Gtk.Stack stack {
      Gtk.StackPage version_select {
        name: "version-select";

        child: Adw.Clamp {
          Gtk.Box {
            styles [
              "detail"
            ]

            orientation: vertical;
            spacing: 15;
            vexpand: true;

            Gtk.Image {
              icon-name: "software-update-available-symbolic";
              icon-size: large;
              focusable: true;

              accessibility {
                labelled-by: description;
              }
            }

            Gtk.Box {
              vexpand: true;
              orientation: vertical;

              Gtk.Label description {
                wrap: true;
              }

              Gtk.DropDown drop_down {
                halign: center;
                margin-top: 24;
              }
            }

            Gtk.Button run_button {
              styles [
                "pill"
              ]

              label: _("_Check Compatibility");
              halign: center;
              valign: end;
              use-underline: true;
              clicked => $do_compatibility_check() swapped;
            }
          }
        };
      }

      Gtk.StackPage waiting {
        name: "waiting";

        child: Gtk.Box {
          orientation: vertical;
          spacing: 12;
          valign: center;

          Adw.Spinner {
            focusable: true;
            halign: center;
            valign: center;
            height-request: 32;
            width-request: 32;
          }

          Gtk.Label counter {
            styles [
              "title-2"
            ]
          }
        };
      }

      Gtk.StackPage error {
        name: "error";

        child: Adw.StatusPage error_status {
          icon-name: "offline-symbolic";
          title: _("Connection Error");
        };
      }

      Gtk.StackPage results {
        name: "results";

        child: Gtk.ScrolledWindow {
          hscrollbar-policy: never;

          child: Adw.Clamp {
            child: Gtk.Box {
              styles [
                "content"
              ]

              orientation: vertical;
              vexpand: true;
              spacing: 24;

              Gtk.Label summary {
                wrap: true;
              }

              Gtk.ProgressBar progress_bar {
                show-text: true;
                margin-start: 24;
                margin-end: 24;
                focusable: true;

                accessibility {
                  labelled-by: summary;
                  described-by: progress_bar;
                }
              }

              Adw.PreferencesGroup user_list_title {
                title: _("User-Installed Extensions");

                Gtk.ListBox user_list_box {
                  styles [
                    "boxed-list",
                    "boxed-list-placeholder"
                  ]

                  valign: start;
                  selection-mode: none;

                  accessibility {
                    labelled-by: user_list_title;
                  }
                }
              }

              Adw.PreferencesGroup system_list_title {
                title: _("System Extensions");

                Gtk.ListBox system_list_box {
                  styles [
                    "boxed-list",
                    "boxed-list-placeholder"
                  ]

                  valign: start;
                  selection-mode: none;

                  accessibility {
                    labelled-by: system_list_title;
                  }
                }
              }

              Gtk.Button copy_details {
                label: _("_Copy to Clipboard");
                halign: center;
                use-underline: true;
                clicked => $copy_to_clipboard() swapped;
              }
            };
          };
        };
      }
    };
  };
}
