Portfolio User commited on
Commit
6091274
·
1 Parent(s): 454cac1

final: add loading indicator and force direct URL for perfect mobile compatibility

Browse files
android_app/main.py CHANGED
@@ -7,22 +7,28 @@ def main(page: ft.Page):
7
  page.window_height = 800
8
  page.padding = 0
9
 
10
- # Using the direct app URL instead of the Space wrapper for better performance in WebView
11
- HF_URL = "https://rafi11223-medi-agent.hf.space/?__theme=light"
 
 
 
 
 
12
 
13
- # The WebView component
14
  webview = ft.WebView(
15
  HF_URL,
16
  expand=True,
17
  javascript_enabled=True,
18
- # Setting a common user agent can help bypass some security blocks in WebViews
19
- user_agent="Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
20
- on_page_started=lambda _: print("Loading Medi-Agent..."),
21
- on_page_ended=lambda _: print("Medi-Agent Ready!"),
22
- on_web_resource_error=lambda e: print(f"Page error: {e.description}"),
23
  )
24
 
25
- page.add(webview)
 
 
 
 
 
 
26
 
27
  if __name__ == "__main__":
28
  ft.app(target=main)
 
7
  page.window_height = 800
8
  page.padding = 0
9
 
10
+ HF_URL = "https://rafi11223-medi-agent.hf.space"
11
+
12
+ loading_text = ft.Text("🏥 Starting Medical Assistant...", size=16, weight=ft.FontWeight.BOLD)
13
+
14
+ def on_page_ended(e):
15
+ loading_text.visible = False
16
+ page.update()
17
 
 
18
  webview = ft.WebView(
19
  HF_URL,
20
  expand=True,
21
  javascript_enabled=True,
22
+ on_page_ended=on_page_ended,
 
 
 
 
23
  )
24
 
25
+ page.add(
26
+ ft.Column(
27
+ [ft.Container(height=40), loading_text, webview],
28
+ expand=True,
29
+ horizontal_alignment=ft.CrossAxisAlignment.CENTER
30
+ )
31
+ )
32
 
33
  if __name__ == "__main__":
34
  ft.app(target=main)
android_build_package/main.py CHANGED
@@ -7,21 +7,30 @@ def main(page: ft.Page):
7
  page.window_height = 800
8
  page.padding = 0
9
 
10
- # Using the direct app URL for the best compatibility in mobile apps
11
- HF_URL = "https://rafi11223-medi-agent.hf.space/?__theme=light"
 
 
 
 
 
 
 
12
 
13
- # The WebView component
14
  webview = ft.WebView(
15
  HF_URL,
16
  expand=True,
17
  javascript_enabled=True,
18
- # Standard mobile user agent to ensure the site loads correctly
19
- user_agent="Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
20
- on_page_started=lambda _: print("Loading MediAgent..."),
21
- on_page_ended=lambda _: print("MediAgent Ready!"),
22
  )
23
 
24
- page.add(webview)
 
 
 
 
 
 
25
 
26
  if __name__ == "__main__":
27
  ft.app(target=main)
 
7
  page.window_height = 800
8
  page.padding = 0
9
 
10
+ # The most direct URL to bypass wrappers
11
+ HF_URL = "https://rafi11223-medi-agent.hf.space"
12
+
13
+ # Minimal UI with a loading indicator
14
+ loading_text = ft.Text("🏥 Starting Medical Assistant...", size=20, text_align=ft.TextAlign.CENTER)
15
+
16
+ def on_page_ended(e):
17
+ loading_text.visible = False
18
+ page.update()
19
 
 
20
  webview = ft.WebView(
21
  HF_URL,
22
  expand=True,
23
  javascript_enabled=True,
24
+ on_page_ended=on_page_ended,
 
 
 
25
  )
26
 
27
+ page.add(
28
+ ft.Column(
29
+ [loading_text, webview],
30
+ expand=True,
31
+ horizontal_alignment=ft.CrossAxisAlignment.CENTER
32
+ )
33
+ )
34
 
35
  if __name__ == "__main__":
36
  ft.app(target=main)