File: Frigcal/code/Frigcal--source/main.kv

#==============================================================================
# The app's main kivy-lang file, used to build the app's GUI on startup.
#
# Defines the main menu and imports other subfiles for screens and popups.
# Screens are activated by the main menu defined here, events open popups. 
#
# Originally a string in the .py: .kv easy to mod but requires packaging.
# There are both explicit and implicit linkages between .kv and .py code.
# Kivy-lang background and editorial deleted here: see PPUS's .kv file.
# See _dev-misc/kivy-dev-notes.txt for notes and temp code trimmed here.
#==============================================================================



#------------------------------------------------------------------------------
# Requirements 
#------------------------------------------------------------------------------

#:kivy 2.3.1             

# full requirements: see _HOW-4.0.0.txt in _dev-misc/...



#------------------------------------------------------------------------------
# Subfiles 
#------------------------------------------------------------------------------

# get common.kv once here, not in all*.kv, else startup dup warning
# cross-file names cummulative: visible as long as already run somewhere

#:include common.kv
#:include allscreens.kv
#:include allpopups.kv



#------------------------------------------------------------------------------
# Local classes: common appearance, avoid redundant code
#------------------------------------------------------------------------------

<NavigationDrawerItem@MDNavigationDrawerItem>:

    # Manual text/icon/bg colors, shaded grey post select in callback.
    # These are now manually shaded in .py code after each menu click,
    # so the values here are used only for initial colors at app start.
    # App references here work even though the GUI may be incomplete.

    text_color:     app.manual_theme_color_fg()   
    selected_color: app.manual_theme_color_fg()   
    icon_color:     app.manual_theme_color_fg()   
    bg_color:       app.manual_theme_color_bg()



#------------------------------------------------------------------------------
# The main display and nav drawer
#------------------------------------------------------------------------------


# MainWindow is a BoxLayout root in .py for Android 15+ edge-to-edge 
# insets padding and screen-wide touch gestures.  Its #canvas.before
# below changes full-app background color but is not required for 
# e-2-e and unused: bg color already extends into insets padding 
# automatically, and KivyMD already updates it on app theme toggles.
#
# Still, for e-2-e, this app must:
# - Make system bars transparent (Android navbar defaults to translucent)
# - Handle system-bar fg colors (Android default clashes with in-app themes)
# - Suport older Androids (see main.py, .buildozer/.../templates/strings.tmpl.xml)  
# - Tweak drop-down menus so they don't run into the system navbar (see monthgui.py)
#
# PPUS 1.4 simply made system bars non-transparent black everywhere
# because it was only dark themed.  Here, app theme != device theme.

# The coding here is quite subtle.  The seemingly superfluous top
# MDScreen is required, else the hb button is on the left, and 
# bottom insets padding is applied above the screen content.  With 
# the top MDScreen, hb button is on nav bar or offscreen in small
# screen landscape and must be adjusted in main.py.  Adding a top
# boxlayout or topappbar to avoid hb button overlay simlarly causes 
# bottom inset padding to be applied to layout, not entire window.

# CAUTION: 'x' calc here for the icon button is repeated in main.py 
# for repositioning the hb button after edge-to-edge insets padding.
  

MainWindow:

    # Defined as an MDBoxLayout in .py for insets padding and gestures

    # moot: bg extends into e-2-e padding 
    #canvas.before:                                   # global bg color
    #    Color:
    #        rgba: get_color_from_hex("#888888")      # any color here
    #    Rectangle:
    #        size: self.size
    #        pos: self.pos

    MDScreen:                                         # all the screens, with drawer + hb button

        MDIconButton:                                 # appears on all all-MD* screens
            id: hbbutton
            icon: 'menu'
            pos_hint: {'top': 1.0}                    # at display top: 100% up
            x: root.width - (self.width + dp(8))      # 8 pixels from right
            icon_size: '24dp'                         # icon image (not button itself)
            #adaptive_height: True
            on_release: app.toggle_menu()

        MDNavigationLayout:                           # NL accepts only SM and ND; a FloatLayout
            id: navlayout

            MDScreenManager:                          # SM accepts only S
                id: navscreenmgr
   
                MonthScreen:                          # MDScreens, in allscreens.kv
                SearchScreen:                         # allpopups.kv opened in .py
                SettingsScreen:                       # .py code sets current screen
                HelpScreen:
                AboutScreen:

            MDNavigationDrawer:
                id: nav_drawer                        # to toggle entire menu
                radius: 0, dp(16), dp(16), 0
 
                MDNavigationDrawerMenu:
                    id: nav_drawer_menu               # formerly for child walk         


                    # Main
    
                    MDNavigationDrawerLabel:
                        text: 'Main'

                    NavigationDrawerItem:
                        id: month
                        text: 'Month'
                        icon: 'calendar-month'
                        on_release: app.on_menu_month(self)
         
                    NavigationDrawerItem:
                        id: search
                        text: 'Search'
                        icon: 'calendar-search'
                        on_release: app.on_menu_search(self)

                    NavigationDrawerItem:
                        id: goto
                        text: 'Go To'
                        icon: 'calendar-question'
                        on_release: app.on_menu_goto(self)


                    # Tools
    
                    MDNavigationDrawerDivider:
                    MDNavigationDrawerLabel:
                        text: 'Tools'
        
                    NavigationDrawerItem:
                        id: save
                        text: 'Save Calendars'
                        icon: 'content-save'
                        on_release: app.on_menu_save(self)

                    NavigationDrawerItem:
                        id: new
                        text: 'New Calendar'
                        icon: 'calendar-plus'
                        on_release: app.on_menu_new(self)

                    NavigationDrawerItem:
                        id: theme
                        text: 'Theme'
                        icon: 'theme-light-dark'
                        on_release: app.on_theme(self)

                    NavigationDrawerItem:
                        id: settings
                        text: 'Settings'
                        icon: 'cog'
                        on_release: app.on_menu_settings(self)


                    # Info

                    MDNavigationDrawerDivider:
                    MDNavigationDrawerLabel:
                        text: 'Info'
    
                    NavigationDrawerItem:
                        id: help
                        text: 'Help'  
                        icon: 'help-circle'   
                        on_release: app.on_menu_help(self)

                    NavigationDrawerItem:
                        id: about
                        text: 'About'  
                        icon: 'information'
                        on_release: app.on_menu_about(self)


                    # Nav

                    MDNavigationDrawerDivider:
                    MDNavigationDrawerLabel:
                        text: 'Nav'

                    NavigationDrawerItem:
                        text: 'Today'
                        id: today
                        icon: 'calendar-today'
                        on_release: app.on_menu_today(self)

                    NavigationDrawerItem:
                        id: nextmo
                        text: 'Next Month'
                        icon: 'step-forward'
                        on_release: app.on_menu_nextmonth(self)

                    NavigationDrawerItem:
                        id: priormo
                        text: 'Prior Month'
                        icon: 'step-backward'
                        on_release: app.on_menu_priormonth(self)

                    NavigationDrawerItem:
                        id: nextyr
                        text: 'Next Year'
                        icon: 'step-forward-2'
                        on_release: app.on_menu_nextyear(self)

                    NavigationDrawerItem:
                        id: prioryr
                        text: 'Prior Year'
                        icon: 'step-backward-2'
                        on_release: app.on_menu_prioryear(self)