[gnome-calendar/wip/cdavis/adaptive-state-porting] gcal-window: Use AdwAdaptiveState for adaptivity




commit 64ccf6591c9fc1abd295bd5ee0f6fcbbaa3bd140
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Oct 7 16:02:57 2022 -0400

    gcal-window: Use AdwAdaptiveState for adaptivity
    
    AdwLeaflet is a widget meant to be used for applications that
    need a sidebar and different set of main content with transitions
    between them at narrow sizes. We only need the sidebar at mobile
    sizes. AdwAdaptiveState is a new utility that can be used for proper
    adaptive widgetry. It uses conditions to show and hide
    widgets appropriately at breakpoints. This gives us more control
    over how we handle our widgets. For Calendar, we are no longer
    constrained by the main content's minimum size, meaning that the
    main window can finally reach 360px.

 build-aux/flatpak/org.gnome.Calendar.json | 33 ++++++++++++++++++++++++++++++
 src/gui/gcal-window.ui                    | 34 +++++++++++++++++++------------
 2 files changed, 54 insertions(+), 13 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Calendar.json b/build-aux/flatpak/org.gnome.Calendar.json
index 07f5510b..657628ac 100644
--- a/build-aux/flatpak/org.gnome.Calendar.json
+++ b/build-aux/flatpak/org.gnome.Calendar.json
@@ -162,6 +162,39 @@
                 }
             ]
         },
+        {
+            "name" : "libsass",
+            "buildsystem" : "meson",
+            "sources" : [
+                {
+                  "type" : "git",
+                  "url" : "https://github.com/lazka/libsass.git";,
+                  "branch" : "meson"
+                }
+            ]
+        },
+        {
+            "name" : "sassc",
+            "buildsystem" : "meson",
+            "sources" : [
+                {
+                  "type" : "git",
+                  "url" : "https://github.com/lazka/sassc.git";,
+                  "branch" : "meson"
+                }
+            ]
+        },
+        {
+            "name" : "libadwaita",
+            "buildsystem" : "meson",
+            "sources" : [
+                {
+                    "type" : "git",
+                    "url" : "https://gitlab.gnome.org/GNOME/libadwaita.git";,
+                    "branch" : "wip/exalm/adaptive-states"
+                }
+            ]
+        },
         {
             "name" : "gnome-calendar",
             "buildsystem" : "meson",
diff --git a/src/gui/gcal-window.ui b/src/gui/gcal-window.ui
index 0ef04001..9ff535fd 100644
--- a/src/gui/gcal-window.ui
+++ b/src/gui/gcal-window.ui
@@ -4,6 +4,7 @@
     <property name="title" translatable="yes">Calendar</property>
     <property name="default_width">800</property>
     <property name="default_height">600</property>
+    <property name="width_request">360</property>
     <property name="height_request">600</property>
 
     <!-- Shortcuts -->
@@ -98,15 +99,15 @@
     <child>
       <object class="AdwToastOverlay" id="overlay">
         <child>
-          <object class="AdwLeaflet" id="leaflet">
-            <property name="homogeneous">False</property>
+          <object class="GtkBox">
+            <property name="orientation">horizontal</property>
             <child>
-              <object class="GtkBox">
+              <object class="GtkBox" id="sidebar">
                 <property name="hexpand">False</property>
                 <property name="orientation">vertical</property>
                 <child>
-                  <object class="AdwHeaderBar">
-                    <property name="show-end-title-buttons" bind-source="leaflet" bind-property="folded" 
bind-flags="sync-create"/>
+                  <object class="AdwHeaderBar" id="sidebar_header">
+                    <property name="show-end-title-buttons">False</property>
                     <property name="title-widget">
                       <object class="GcalCalendarButton" id="calendars_button" />
                     </property>
@@ -145,7 +146,7 @@
                 </child>
                 <child>
                   <object class="GtkActionBar" id="action_bar">
-                    <property name="revealed" bind-source="leaflet" bind-property="folded" 
bind-flags="sync-create"/>
+                    <property name="revealed">False</property>
                     <child type="start">
                       <object class="GtkButton">
                         <property name="action-name">win.today</property>
@@ -165,15 +166,10 @@
               </object>
             </child>
             <child>
-              <object class="AdwLeafletPage">
-                <property name="navigatable">True</property>
-                <property name="child">
-                  <object class="GtkSeparator"/>
-                </property>
-              </object>
+              <object class="GtkSeparator" id="separator"/>
             </child>
             <child>
-              <object class="GtkBox">
+              <object class="GtkBox" id="content">
                 <property name="orientation">vertical</property>
                 <child>
                   <object class="GtkHeaderBar" id="header_bar">
@@ -252,6 +248,18 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="AdwAdaptiveState" id="narrow_state">
+        <conditions>
+          <condition type="max-width">770</condition>
+        </conditions>
+        <setter object="action_bar" property="revealed">True</setter>
+        <setter object="sidebar_header" property="show-end-title-buttons">True</setter>
+        <setter object="sidebar" property="hexpand">True</setter>
+        <setter object="content" property="visible">False</setter>
+        <setter object="separator" property="visible">False</setter>
+      </object>
+    </child>
   </template>
   <object class="GcalQuickAddPopover" id="quick_add_popover">
     <signal name="edit-event" handler="edit_event" object="GcalWindow" swapped="no"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]