@@ -14,7 +14,7 @@ Version=9.85
14
14
Sub Class_Globals
15
15
Private Root As B4XView
16
16
Private xui As XUI
17
- Private URL As String = "http://172.20.10.6 :19800/v1/" ' "https://api.puterise.com:19900 /v1/"
17
+ Private URL As String = "http://172.20.10.3 :19800/v1/"
18
18
Private lblTitle As B4XView
19
19
Private lblBack As B4XView
20
20
Private clvRecord As CustomListView
@@ -50,6 +50,27 @@ Private Sub B4XPage_Created (Root1 As B4XView)
50
50
#End If
51
51
End Sub
52
52
53
+ Private Sub B4XPage_CloseRequest As ResumableSub
54
+ If xui.IsB4A Then
55
+ 'back key in Android
56
+ If PrefDialog1.BackKeyPressed Then Return False
57
+ If PrefDialog2.BackKeyPressed Then Return False
58
+ If PrefDialog3.BackKeyPressed Then Return False
59
+ End If
60
+ If Viewing = "Product" Then
61
+ GetCategories
62
+ Return False
63
+ End If
64
+ Return True
65
+ End Sub
66
+
67
+ 'Don't miss the code in the Main module + manifest editor.
68
+ Private Sub IME_HeightChanged (NewHeight As Int , OldHeight As Int )
69
+ PrefDialog1.KeyboardHeightChanged(NewHeight)
70
+ PrefDialog2.KeyboardHeightChanged(NewHeight)
71
+ PrefDialog3.KeyboardHeightChanged(NewHeight)
72
+ End Sub
73
+
53
74
#If B4j
54
75
Private Sub SetScrollPaneBackgroundColor (View As CustomListView , Color As Int )
55
76
Dim SP As JavaObject = View.GetBase.GetView(0 )
@@ -64,12 +85,10 @@ Private Sub B4XPage_Appear
64
85
GetCategories
65
86
End Sub
66
87
67
- Private Sub B4XPage_CloseRequest As ResumableSub
68
- If Viewing = "Product" Then
69
- GetCategories
70
- Return False
71
- End If
72
- Return True
88
+ Private Sub B4XPage_Resize (Width As Int , Height As Int )
89
+ If PrefDialog1.IsInitialized And PrefDialog1.Dialog.Visible Then PrefDialog1.Dialog.Resize(Width, Height)
90
+ If PrefDialog2.IsInitialized And PrefDialog2.Dialog.Visible Then PrefDialog2.Dialog.Resize(Width, Height)
91
+ If PrefDialog3.IsInitialized And PrefDialog3.Dialog.Visible Then PrefDialog3.Dialog.Resize(Width, Height)
73
92
End Sub
74
93
75
94
#If B4J
@@ -200,16 +219,17 @@ Private Sub CreateDialog1
200
219
End Sub
201
220
202
221
Private Sub CreateDialog2
203
- Dim options As List
204
- options .Initialize
222
+ Dim categories As List
223
+ categories .Initialize
205
224
For i = 0 To Category.Length - 1
206
- options .Add(Category(i).Name)
225
+ categories .Add(Category(i).Name)
207
226
Next
208
227
PrefDialog2.Initialize(Root, "Product" , 300 dip, 250 dip)
209
228
PrefDialog2.Dialog.OverlayColor = xui.Color_ARGB(128 , 0 , 10 , 40 )
210
229
PrefDialog2.Dialog.TitleBarHeight = 50 dip
211
230
PrefDialog2.LoadFromJson(File.ReadString(File.DirAssets, "template_product.json" ))
212
- PrefDialog2.SetOptions("Category" , options)
231
+ PrefDialog2.SetOptions("Category" , categories)
232
+ PrefDialog2.SetEventsListener(Me, "PrefDialog2" ) '<-- must add to handle events.
213
233
End Sub
214
234
215
235
Private Sub CreateDialog3
@@ -219,7 +239,7 @@ Private Sub CreateDialog3
219
239
PrefDialog3.Dialog.TitleBarHeight = 50 dip
220
240
PrefDialog3.Dialog.TitleBarColor = xui.Color_RGB(220 , 20 , 60 )
221
241
PrefDialog3.AddSeparator("default" )
222
- End Sub
242
+ End Sub
223
243
224
244
Private Sub ShowDialog1 (Action As String , Item As Map )
225
245
If Action = "Add" Then
@@ -229,14 +249,29 @@ Private Sub ShowDialog1 (Action As String, Item As Map)
229
249
End If
230
250
PrefDialog1.Title = Action & " Category"
231
251
Dim sf As Object = PrefDialog1.ShowDialog(Item, "OK" , "CANCEL" )
252
+ #if B4A or B4i
253
+ PrefDialog1.Dialog.Base.Top = 100 dip ' Make it lower
254
+ #Else
255
+ 'Dim sp As ScrollPane = PrefDialog1.CustomListView1.sv
256
+ 'sp.SetVScrollVisibility("NEVER")
257
+ Sleep(0 )
258
+ PrefDialog1.CustomListView1.sv.Height = PrefDialog1.CustomListView1.sv.ScrollViewInnerPanel.Height + 10 dip
259
+ #End If
260
+ ' Fix Linux UI (Long Text Button)
261
+ Dim btnCancel As B4XView = PrefDialog1.Dialog.GetButton(xui.DialogResponse_Cancel)
262
+ btnCancel.Width = btnCancel.Width + 20 dip
263
+ btnCancel.Left = btnCancel.Left - 20 dip
264
+ btnCancel.TextColor = xui.Color_Red
265
+ Dim btnOk As B4XView = PrefDialog1.Dialog.GetButton(xui.DialogResponse_Positive)
266
+ btnOk.Left = btnOk.Left - 20 dip
232
267
Wait For (sf) Complete (Result As Int )
233
268
If Result = xui.DialogResponse_Positive Then
234
269
If 0 = Item.Get ("id" ) Then ' New row
235
270
Dim CategoryMap As Map = CreateMap("name" : Item.Get ("Category Name" ))
236
271
Dim sd As Object = SendData("POST" , "category" , CategoryMap)
237
272
Wait For (sd) Complete (Data As Map )
238
273
If Data.Get ("s" ) = "ok" Then
239
- ' Log(Data.Get("a")) ' 201 Created
274
+ Log(Data.Get ("a" )) ' 201 Created
240
275
Dim l As List = Data.Get ("r" )
241
276
Dim m As Map = l.Get (0 )
242
277
xui.MsgboxAsync("New category created!" , $"ID: ${m.Get(" id")}" $)
@@ -268,6 +303,8 @@ Private Sub ShowDialog2 (Action As String, Item As Map)
268
303
End If
269
304
PrefDialog2.Title = Action & " Product"
270
305
Dim sf As Object = PrefDialog2.ShowDialog(Item, "OK" , "CANCEL" )
306
+ Sleep(0 )
307
+ PrefDialog2.CustomListView1.sv.Height = PrefDialog2.CustomListView1.sv.ScrollViewInnerPanel.Height + 10 dip
271
308
Wait For (sf) Complete (Result As Int )
272
309
If Result = xui.DialogResponse_Positive Then
273
310
If 0 = Item.Get ("id" ) Then ' New row
@@ -301,19 +338,42 @@ Private Sub ShowDialog2 (Action As String, Item As Map)
301
338
End If
302
339
End Sub
303
340
341
+ Private Sub PrefDialog2_BeforeDialogDisplayed (Template As Object )
342
+ Try
343
+ ' Fix Linux UI (Long Text Button)
344
+ Dim btnCancel As B4XView = PrefDialog2.Dialog.GetButton(xui.DialogResponse_Cancel)
345
+ btnCancel.Width = btnCancel.Width + 20 dip
346
+ btnCancel.Left = btnCancel.Left - 20 dip
347
+ btnCancel.TextColor = xui.Color_Red
348
+ Dim btnOk As B4XView = PrefDialog2.Dialog.GetButton(xui.DialogResponse_Positive)
349
+ If btnOk.IsInitialized Then
350
+ btnOk.Width = btnOk.Width + 20 dip
351
+ btnOk.Left = btnCancel.Left - btnOk.Width
352
+ End If
353
+ Catch
354
+ Log(LastException)
355
+ End Try
356
+ End Sub
357
+
304
358
Private Sub ShowDialog3 (Item As Map , Id As Long )
305
359
PrefDialog3.Title = "Delete " & Viewing
306
360
Dim sf As Object = PrefDialog3.ShowDialog(Item, "OK" , "CANCEL" )
307
361
#if B4A or B4i
308
- PrefDialog3.Dialog.Base.Top = 200 dip ' Make it lower
362
+ PrefDialog3.Dialog.Base.Top = 100 dip ' Make it lower
309
363
#Else
310
- Dim sp As ScrollPane = PrefDialog3.CustomListView1.sv
311
- sp.SetVScrollVisibility("NEVER" )
312
- 'sp.Pannable = False ' <-- still can scroll :)
364
+ ' Fix Linux UI (Long Text Button)
365
+ 'Dim sp As ScrollPane = PrefDialog3.CustomListView1.sv
366
+ 'sp.SetVScrollVisibility("NEVER")
367
+ Sleep(0 )
368
+ PrefDialog3.CustomListView1.sv.Height = PrefDialog3.CustomListView1.sv.ScrollViewInnerPanel.Height + 10 dip
313
369
#End If
370
+ Dim btnCancel As B4XView = PrefDialog3.Dialog.GetButton(xui.DialogResponse_Cancel)
371
+ btnCancel.Width = btnCancel.Width + 20 dip
372
+ btnCancel.Left = btnCancel.Left - 20 dip
373
+ btnCancel.TextColor = xui.Color_Red
374
+ Dim btnOk As B4XView = PrefDialog3.Dialog.GetButton(xui.DialogResponse_Positive)
375
+ btnOk.Left = btnOk.Left - 20 dip
314
376
PrefDialog3.CustomListView1.GetPanel(0 ).GetView(0 ).Text = Item.Get ("Item" )
315
- 'PrefDialog3.CustomListView1.GetPanel(0).GetView(0).Text = " " & Item.Get("Item")
316
- 'PrefDialog3.CustomListView1.GetPanel(0).GetView(0).SetTextAlignment("CENTER", "LEFT")
317
377
#if b4i
318
378
PrefDialog3.CustomListView1.GetPanel(0 ).GetView(0 ).TextSize = 16 ' Text too small in ios
319
379
#else
0 commit comments