@Erel ,
I have been doing something very similar to this, but the shared classes etc are in their own subdirectory.
One thing that I have noticed is that when you create a new class it is created in the subdirectory for the IDE you are using.
I then have to:
- close the IDE
- manually copy the file,
- reopen the IDE (an error message pops up, which is expected)
- Select add existing modules and link the class using the relative option
It would be really useful if the "Add New Module" option allowed you to automatically create the class file in the right directory. Should I add this as a Wish?
I also create a Panel which is passed to the child rather than the Activity/Page.
[CODE lang="b4x" title="Sample Code - B4i"]
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public page As Page
Private xui As XUI 'ignore
Private hp As HomePageClass
Private backpanel As Panel
End Sub
Sub PageLoad
page.Initialize("page")
page.RootPanel.LoadLayout("Backpanel")
page.RootPanel.Color = Globals.gcol_primaryback
End Sub
Private Sub Page_Resize(Width As Int, Height As Int)
'Display within Iphone X safe areas
Private r As Rect = page.SafeAreaInsets
backpanel.SetLayoutAnimated(0,1,r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
hp.resize(Width - r.Right - r.Left,Height - r.Bottom - r.Top)
End Sub
Sub pagestart
If Not(page.IsInitialized) Then PageLoad
hp.Initialize("homepage")
hp.ShowPage(Me,backpanel)
End Sub
Sub page_Appear
hp.Resuming
End Sub
Sub page_Disappear
hp.Pausing
End Sub
[/CODE]
[CODE lang="b4x" title="Sample Code - B4a"]Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private first_time As Boolean
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private hpClass As HomePageClass
Private backpanel As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("backpanel")
hpClass.Initialize("hpclass")
first_time = FirstTime
End Sub
Sub Activity_Resume
If first_time Then
hpClass.ShowPage(Me,backpanel)
End If
first_time = False
CallSubDelayed(Me, "ResumeHomePage")
End Sub
Sub ResumeHomePage
hpClass.Resuming
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If hpClass.IsInitialized Then
hpClass.Pausing
End If
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
' May result in a callback to hpClass_closeapp
Return hpclass.keypress(KeyCode)
End Sub
Sub hpClass_closeapp
ExitApplication
End Sub
[/CODE]