🏡 index : quine-global-labs/bazaar.git

using Gtk 4.0;
using Adw 1;

template $BzSafetyDialog: Adw.Bin {
  child: Adw.ToolbarView {
    [top]
    Adw.HeaderBar {
      show-title: false;
    }

    content: Adw.Carousel carousel {
      interactive: false;
      allow-scroll-wheel: false;
      allow-mouse-drag: false;
      allow-long-swipes: false;
      hexpand: true;

      ScrolledWindow {
        hscrollbar-policy: never;
        hexpand: true;
        sensitive: bind $is_page(carousel.position, 0) as <bool>;

        Box global_box {
          orientation: vertical;
          spacing: 12;
          margin-start: 18;
          margin-end: 18;
          margin-top: 18;
          margin-bottom: 18;

          $BzLozenge {
            title: _("Arbitrary Permissions");

            icon-names: [
              "earth-symbolic",
            ];

            importance: important;
            margin-bottom: 8;
          }

          Label arbitrary_description {
            wrap: true;
            xalign: 0;
            use-markup: true;
            margin-bottom: 18;
            margin-start: 18;
            margin-end: 18;
            label: _("This app has a permission that indirectly allows it to grant itself <b>any other permission it wants</b>, bypassing the Flatpak sandbox.\n\nIt can therefore do anything a privileged, non-sandboxed application can do, such as accessing all your files and connecting to the internet.\n\nViewing the other permissions may still give a better idea of what the app is likely to do.");
          }

          Button other_permissions_button {
            label: _("View Other Permissions");
            clicked => $next_page(template);
            margin-bottom: 12;
            halign: center;
            hexpand: true;
            styles ["pill"]
          }
        }
      }

      ScrolledWindow {
        hscrollbar-policy: never;
        hexpand: true;
        sensitive: bind $is_page(carousel.position, 1) as <bool>;

        Adw.Clamp {
          maximum-size: 640;
          tightening-threshold: 400;

          Box {
            orientation: vertical;
            spacing: 24;
            margin-start: 24;
            margin-end: 24;
            margin-top: 24;
            margin-bottom: 24;

            $BzLozenge lozenge {
              title: _("Safe");

              icon-names: [
                "app-safety-ok-symbolic",
              ];

              importance: unimportant;
            }

            ListBox permissions_list {
              selection-mode: none;

              styles [
                "boxed-list",
              ]
            }

            Adw.PreferencesGroup {
              margin-top: 10;
              title: _("Details");

              Adw.ActionRow license_row {
                title: _("License");
                subtitle: bind template.entry as <$BzEntry>.project-license;
                subtitle-selectable: true;
                visible: bind $not($is_empty_string(license_row.subtitle) as <bool>) as <bool>;

                styles [
                  "property",
                ]
              }

              Adw.ActionRow {
                title: _("App ID");
                subtitle: bind template.entry as <$BzEntry>.id;
                subtitle-selectable: true;

                styles [
                  "property",
                ]
              }

              Adw.ActionRow {
                title: _("SDK");
                subtitle: bind template.entry as <$BzFlatpakEntry>.runtime as <$BzResult>.object as <$BzEntry>.title;
                subtitle-selectable: true;
                tooltip-text: bind template.entry as <$BzFlatpakEntry>.application-runtime;
                visible: bind $invert_boolean(
                  $is_null(template.entry as <$BzFlatpakEntry>.runtime as <$BzResult>.object) as <bool>
                ) as <bool>;

                styles [
                  "property",
                ]

                [suffix]
                MenuButton {
                  visible: bind $invert_boolean($is_null(template.entry as <$BzEntry>.eol) as <bool>) as <bool>;

                  styles [
                    "error",
                    "flat",
                  ]

                  valign: center;
                  icon-name: "dialog-warning-symbolic";

                  popover: Popover {
                    child: Label {
                      margin-top: 8;
                      margin-bottom: 8;
                      margin-start: 8;
                      margin-end: 8;
                      max-width-chars: 35;
                      wrap: true;
                      label: _(
                        "This app uses an outdated version of the software platform (SDK) and might contain bugs or security vulnerabilities which will not be fixed."
                      );
                    };
                  };
                }
              }
            }
          }
        }
      }
    };
  };
}