Skip to content

Commit 3073061

Browse files
committed
base app
1 parent b17238d commit 3073061

File tree

463 files changed

+14995
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

463 files changed

+14995
-9
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[project]
2+
name = "poc"
3+
version = "0.1.0"
4+
description = ""
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
authors = [
8+
{ name = "Flet developer", email = "[email protected]" }
9+
]
10+
dependencies = [
11+
"flet==0.70.0.dev6833",
12+
]
13+
14+
[tool.uv]
15+
prerelease = "allow"
16+
17+
[tool.flet]
18+
# Docs: https://flet.dev/docs/publish
19+
org = "com.mycompany"
20+
product = "poc"
21+
company = "Flet"
22+
copyright = "Copyright (C) 2025 by Flet"
23+
24+
[tool.flet.app]
25+
path = "src"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flet==0.70.0.dev6833

sdk/python/packages/flet/docs/apps/examples-gallery/src/controls/__init__.py

Whitespace-only changes.

sdk/python/packages/flet/docs/apps/examples-gallery/src/controls/ads/__init__.py

Whitespace-only changes.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import flet as ft
2+
import flet_ads as fta
3+
4+
5+
def main(page: ft.Page):
6+
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
7+
page.appbar = ft.AppBar(
8+
adaptive=True,
9+
title="Mobile Ads Playground",
10+
bgcolor=ft.Colors.LIGHT_BLUE_300,
11+
)
12+
13+
# Test ad unit IDs
14+
ids = {
15+
ft.PagePlatform.ANDROID: {
16+
"banner": "ca-app-pub-3940256099942544/6300978111",
17+
"interstitial": "ca-app-pub-3940256099942544/1033173712",
18+
},
19+
ft.PagePlatform.IOS: {
20+
"banner": "ca-app-pub-3940256099942544/2934735716",
21+
"interstitial": "ca-app-pub-3940256099942544/4411468910",
22+
},
23+
}
24+
25+
def handle_interstitial_ad_close(e: ft.Event[fta.InterstitialAd]):
26+
nonlocal iad
27+
print("Closing InterstitialAd")
28+
page.overlay.remove(e.control)
29+
page.overlay.append(iad := get_new_interstitial_ad())
30+
page.update()
31+
32+
async def handle_interstitial_ad_display(e: ft.Event[ft.OutlinedButton]):
33+
nonlocal iad
34+
print("Showing InterstitialAd")
35+
await iad.show()
36+
37+
def get_new_interstitial_ad():
38+
return fta.InterstitialAd(
39+
unit_id=ids.get(page.platform, {}).get("interstitial"),
40+
on_load=lambda e: print("InterstitialAd loaded"),
41+
on_error=lambda e: print("InterstitialAd error", e.data),
42+
on_open=lambda e: print("InterstitialAd opened"),
43+
on_close=handle_interstitial_ad_close,
44+
on_impression=lambda e: print("InterstitialAd impression"),
45+
on_click=lambda e: print("InterstitialAd clicked"),
46+
)
47+
48+
def get_new_banner_ad() -> ft.Container:
49+
return ft.Container(
50+
width=320,
51+
height=50,
52+
bgcolor=ft.Colors.TRANSPARENT,
53+
content=fta.BannerAd(
54+
unit_id=ids.get(page.platform, {}).get("banner"),
55+
on_click=lambda e: print("BannerAd clicked"),
56+
on_load=lambda e: print("BannerAd loaded"),
57+
on_error=lambda e: print("BannerAd error", e.data),
58+
on_open=lambda e: print("BannerAd opened"),
59+
on_close=lambda e: print("BannerAd closed"),
60+
on_impression=lambda e: print("BannerAd impression"),
61+
on_will_dismiss=lambda e: print("BannerAd will dismiss"),
62+
),
63+
)
64+
65+
page.overlay.append(iad := get_new_interstitial_ad())
66+
67+
page.add(
68+
ft.OutlinedButton(
69+
content="Show InterstitialAd",
70+
on_click=handle_interstitial_ad_display,
71+
),
72+
ft.OutlinedButton(
73+
content="Show BannerAd",
74+
on_click=lambda e: page.add(get_new_banner_ad()),
75+
),
76+
)
77+
78+
79+
if __name__ == "__main__":
80+
ft.run(main)

sdk/python/packages/flet/docs/apps/examples-gallery/src/controls/alert_dialog/__init__.py

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import flet as ft
2+
3+
4+
def main(page: ft.Page):
5+
page.title = "AlertDialog examples"
6+
7+
dialog = ft.AlertDialog(
8+
title=ft.Text("Hello"),
9+
content=ft.Text("You are notified!"),
10+
alignment=ft.Alignment.CENTER,
11+
on_dismiss=lambda e: print("Dialog dismissed!"),
12+
title_padding=ft.Padding.all(25),
13+
)
14+
15+
modal_dialog = ft.AlertDialog(
16+
modal=True,
17+
title=ft.Text("Please confirm"),
18+
content=ft.Text("Do you really want to delete all those files?"),
19+
actions=[
20+
ft.TextButton("Yes", on_click=lambda e: page.pop_dialog()),
21+
ft.TextButton("No", on_click=lambda e: page.pop_dialog()),
22+
],
23+
actions_alignment=ft.MainAxisAlignment.END,
24+
on_dismiss=lambda e: print("Modal dialog dismissed!"),
25+
)
26+
27+
page.add(
28+
ft.Button(
29+
content="Open dialog",
30+
on_click=lambda e: page.show_dialog(dialog),
31+
),
32+
ft.Button(
33+
content="Open modal dialog",
34+
on_click=lambda e: page.show_dialog(modal_dialog),
35+
),
36+
)
37+
38+
39+
if __name__ == "__main__":
40+
ft.run(main)

sdk/python/packages/flet/docs/apps/examples-gallery/src/controls/animated_switcher/__init__.py

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
3+
import flet as ft
4+
5+
6+
def main(page: ft.Page):
7+
def animate(e: ft.Event[ft.Button]):
8+
switcher.content = ft.Image(
9+
src=f"https://picsum.photos/200/300?{time.time()}",
10+
width=200,
11+
height=300,
12+
)
13+
page.update()
14+
15+
page.add(
16+
switcher := ft.AnimatedSwitcher(
17+
content=ft.Image(
18+
src="https://picsum.photos/200/300",
19+
width=200,
20+
height=300,
21+
),
22+
transition=ft.AnimatedSwitcherTransition.SCALE,
23+
duration=500,
24+
reverse_duration=100,
25+
switch_in_curve=ft.AnimationCurve.BOUNCE_OUT,
26+
switch_out_curve=ft.AnimationCurve.BOUNCE_IN,
27+
),
28+
ft.Button("Animate!", on_click=animate),
29+
)
30+
31+
32+
if __name__ == "__main__":
33+
ft.run(main)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import base64
2+
import time
3+
4+
import httpx
5+
6+
import flet as ft
7+
8+
9+
class BufferingSwitcher(ft.AnimatedSwitcher):
10+
image_queue = []
11+
12+
def __init__(self, image: ft.Image):
13+
super().__init__(image)
14+
self.transition = ft.AnimatedSwitcherTransition.SCALE
15+
self.duration = 500
16+
self.reverse_duration = 100
17+
self.switch_in_curve = ft.AnimationCurve.EASE_IN
18+
self.switch_out_curve = ft.AnimationCurve.EASE_OUT
19+
self.image_queue.append(image)
20+
21+
def animate(self, e):
22+
self.content = ft.Image(
23+
src=self.image_queue.pop(),
24+
width=200,
25+
height=300,
26+
gapless_playback=True,
27+
)
28+
self.update()
29+
30+
async def fill_queue(self):
31+
while len(self.image_queue) < 10:
32+
self.image_queue.append(
33+
await self.image_to_base64(
34+
f"https://picsum.photos/200/300?{time.time()}"
35+
)
36+
)
37+
38+
async def image_to_base64(self, url):
39+
response = await httpx.AsyncClient(follow_redirects=True).get(url)
40+
if response.status_code == 200:
41+
base64_str = (
42+
base64.standard_b64encode(response.content).decode("utf-8").strip()
43+
)
44+
return base64_str
45+
else:
46+
print(f"Image request failed with {response.status_code}")
47+
return None
48+
49+
def before_update(self):
50+
self.page.run_task(self.fill_queue)
51+
52+
53+
def main(page: ft.Page):
54+
switcher = BufferingSwitcher(
55+
ft.Image(
56+
src=f"https://picsum.photos/200/300?{time.time()}", width=200, height=300
57+
)
58+
)
59+
60+
page.add(
61+
switcher,
62+
ft.Button("Animate!", on_click=switcher.animate),
63+
)
64+
65+
66+
if __name__ == "__main__":
67+
ft.run(main)

0 commit comments

Comments
 (0)