flet-ads 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flet-ads might be problematic. Click here for more details.
- flet_ads/__init__.py +9 -0
- flet_ads/banner.py +110 -0
- flet_ads/base_ad.py +174 -0
- flet_ads/interstitial.py +111 -0
- flet_ads/native.py +171 -0
- flet_ads-0.1.0.dist-info/METADATA +97 -0
- flet_ads-0.1.0.dist-info/RECORD +21 -0
- {flet_ads-0.0.1.dist-info → flet_ads-0.1.0.dist-info}/WHEEL +2 -1
- flet_ads-0.1.0.dist-info/top_level.txt +2 -0
- flutter/flet_ads/CHANGELOG.md +3 -0
- flutter/flet_ads/LICENSE +201 -0
- flutter/flet_ads/README.md +3 -0
- flutter/flet_ads/analysis_options.yaml +4 -0
- flutter/flet_ads/lib/flet_ads.dart +3 -0
- flutter/flet_ads/lib/src/banner.dart +96 -0
- flutter/flet_ads/lib/src/create_control.dart +29 -0
- flutter/flet_ads/lib/src/interstitial.dart +83 -0
- flutter/flet_ads/lib/src/native.dart +153 -0
- flutter/flet_ads/lib/utils/native.dart +69 -0
- flutter/flet_ads/pubspec.lock +759 -0
- flutter/flet_ads/pubspec.yaml +18 -0
- .DS_Store +0 -0
- flet_ads/.DS_Store +0 -0
- flet_ads-0.0.1.dist-info/.DS_Store +0 -0
- flet_ads-0.0.1.dist-info/METADATA +0 -14
- flet_ads-0.0.1.dist-info/RECORD +0 -7
flet_ads/__init__.py
CHANGED
flet_ads/banner.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from typing import Any, Optional, Union
|
|
2
|
+
|
|
3
|
+
from flet.core.animation import AnimationValue
|
|
4
|
+
from flet.core.control import OptionalNumber
|
|
5
|
+
from flet.core.ref import Ref
|
|
6
|
+
from flet.core.types import (
|
|
7
|
+
OffsetValue,
|
|
8
|
+
OptionalControlEventCallable,
|
|
9
|
+
ResponsiveNumber,
|
|
10
|
+
RotateValue,
|
|
11
|
+
ScaleValue,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from flet_ads.base_ad import BaseAd
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BannerAd(BaseAd):
|
|
18
|
+
"""
|
|
19
|
+
Displays a banner ad.
|
|
20
|
+
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
Online docs: https://flet.dev/docs/controls/bannerad
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
unit_id: str,
|
|
29
|
+
on_load: OptionalControlEventCallable = None,
|
|
30
|
+
on_error: OptionalControlEventCallable = None,
|
|
31
|
+
on_open: OptionalControlEventCallable = None,
|
|
32
|
+
on_close: OptionalControlEventCallable = None,
|
|
33
|
+
on_impression: OptionalControlEventCallable = None,
|
|
34
|
+
on_click: OptionalControlEventCallable = None,
|
|
35
|
+
on_will_dismiss: OptionalControlEventCallable = None,
|
|
36
|
+
#
|
|
37
|
+
# ConstrainedControl
|
|
38
|
+
#
|
|
39
|
+
ref: Optional[Ref] = None,
|
|
40
|
+
key: Optional[str] = None,
|
|
41
|
+
width: OptionalNumber = None,
|
|
42
|
+
height: OptionalNumber = None,
|
|
43
|
+
left: OptionalNumber = None,
|
|
44
|
+
top: OptionalNumber = None,
|
|
45
|
+
right: OptionalNumber = None,
|
|
46
|
+
bottom: OptionalNumber = None,
|
|
47
|
+
expand: Union[None, bool, int] = None,
|
|
48
|
+
expand_loose: Optional[bool] = None,
|
|
49
|
+
col: Optional[ResponsiveNumber] = None,
|
|
50
|
+
opacity: OptionalNumber = None,
|
|
51
|
+
rotate: RotateValue = None,
|
|
52
|
+
scale: ScaleValue = None,
|
|
53
|
+
offset: OffsetValue = None,
|
|
54
|
+
aspect_ratio: OptionalNumber = None,
|
|
55
|
+
animate_opacity: AnimationValue = None,
|
|
56
|
+
animate_size: AnimationValue = None,
|
|
57
|
+
animate_position: AnimationValue = None,
|
|
58
|
+
animate_rotation: AnimationValue = None,
|
|
59
|
+
animate_scale: AnimationValue = None,
|
|
60
|
+
animate_offset: AnimationValue = None,
|
|
61
|
+
on_animation_end: OptionalControlEventCallable = None,
|
|
62
|
+
tooltip: Optional[str] = None,
|
|
63
|
+
visible: Optional[bool] = None,
|
|
64
|
+
disabled: Optional[bool] = None,
|
|
65
|
+
data: Any = None,
|
|
66
|
+
):
|
|
67
|
+
BaseAd.__init__(
|
|
68
|
+
self,
|
|
69
|
+
unit_id=unit_id,
|
|
70
|
+
on_load=on_load,
|
|
71
|
+
on_error=on_error,
|
|
72
|
+
on_open=on_open,
|
|
73
|
+
on_close=on_close,
|
|
74
|
+
on_impression=on_impression,
|
|
75
|
+
on_click=on_click,
|
|
76
|
+
on_will_dismiss=on_will_dismiss,
|
|
77
|
+
#
|
|
78
|
+
# ConstrainedControl
|
|
79
|
+
#
|
|
80
|
+
ref=ref,
|
|
81
|
+
key=key,
|
|
82
|
+
width=width,
|
|
83
|
+
height=height,
|
|
84
|
+
left=left,
|
|
85
|
+
top=top,
|
|
86
|
+
right=right,
|
|
87
|
+
bottom=bottom,
|
|
88
|
+
expand=expand,
|
|
89
|
+
expand_loose=expand_loose,
|
|
90
|
+
col=col,
|
|
91
|
+
opacity=opacity,
|
|
92
|
+
rotate=rotate,
|
|
93
|
+
scale=scale,
|
|
94
|
+
offset=offset,
|
|
95
|
+
aspect_ratio=aspect_ratio,
|
|
96
|
+
animate_opacity=animate_opacity,
|
|
97
|
+
animate_size=animate_size,
|
|
98
|
+
animate_position=animate_position,
|
|
99
|
+
animate_rotation=animate_rotation,
|
|
100
|
+
animate_scale=animate_scale,
|
|
101
|
+
animate_offset=animate_offset,
|
|
102
|
+
on_animation_end=on_animation_end,
|
|
103
|
+
tooltip=tooltip,
|
|
104
|
+
visible=visible,
|
|
105
|
+
disabled=disabled,
|
|
106
|
+
data=data,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def _get_control_name(self):
|
|
110
|
+
return "banner_ad"
|
flet_ads/base_ad.py
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
from typing import Any, Optional, Union
|
|
2
|
+
|
|
3
|
+
from flet.core.animation import AnimationValue
|
|
4
|
+
from flet.core.constrained_control import ConstrainedControl
|
|
5
|
+
from flet.core.control import OptionalNumber
|
|
6
|
+
from flet.core.ref import Ref
|
|
7
|
+
from flet.core.types import (
|
|
8
|
+
OffsetValue,
|
|
9
|
+
OptionalControlEventCallable,
|
|
10
|
+
PagePlatform,
|
|
11
|
+
ResponsiveNumber,
|
|
12
|
+
RotateValue,
|
|
13
|
+
ScaleValue,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BaseAd(ConstrainedControl):
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
unit_id: str,
|
|
21
|
+
on_load: OptionalControlEventCallable = None,
|
|
22
|
+
on_error: OptionalControlEventCallable = None,
|
|
23
|
+
on_open: OptionalControlEventCallable = None,
|
|
24
|
+
on_close: OptionalControlEventCallable = None,
|
|
25
|
+
on_impression: OptionalControlEventCallable = None,
|
|
26
|
+
on_click: OptionalControlEventCallable = None,
|
|
27
|
+
on_will_dismiss: OptionalControlEventCallable = None,
|
|
28
|
+
#
|
|
29
|
+
# ConstrainedControl
|
|
30
|
+
#
|
|
31
|
+
ref: Optional[Ref] = None,
|
|
32
|
+
key: Optional[str] = None,
|
|
33
|
+
width: OptionalNumber = None,
|
|
34
|
+
height: OptionalNumber = None,
|
|
35
|
+
left: OptionalNumber = None,
|
|
36
|
+
top: OptionalNumber = None,
|
|
37
|
+
right: OptionalNumber = None,
|
|
38
|
+
bottom: OptionalNumber = None,
|
|
39
|
+
expand: Union[None, bool, int] = None,
|
|
40
|
+
expand_loose: Optional[bool] = None,
|
|
41
|
+
col: Optional[ResponsiveNumber] = None,
|
|
42
|
+
opacity: OptionalNumber = None,
|
|
43
|
+
rotate: RotateValue = None,
|
|
44
|
+
scale: ScaleValue = None,
|
|
45
|
+
offset: OffsetValue = None,
|
|
46
|
+
aspect_ratio: OptionalNumber = None,
|
|
47
|
+
animate_opacity: AnimationValue = None,
|
|
48
|
+
animate_size: AnimationValue = None,
|
|
49
|
+
animate_position: AnimationValue = None,
|
|
50
|
+
animate_rotation: AnimationValue = None,
|
|
51
|
+
animate_scale: AnimationValue = None,
|
|
52
|
+
animate_offset: AnimationValue = None,
|
|
53
|
+
on_animation_end: OptionalControlEventCallable = None,
|
|
54
|
+
tooltip: Optional[str] = None,
|
|
55
|
+
visible: Optional[bool] = None,
|
|
56
|
+
disabled: Optional[bool] = None,
|
|
57
|
+
data: Any = None,
|
|
58
|
+
):
|
|
59
|
+
ConstrainedControl.__init__(
|
|
60
|
+
self,
|
|
61
|
+
ref=ref,
|
|
62
|
+
key=key,
|
|
63
|
+
width=width,
|
|
64
|
+
height=height,
|
|
65
|
+
left=left,
|
|
66
|
+
top=top,
|
|
67
|
+
right=right,
|
|
68
|
+
bottom=bottom,
|
|
69
|
+
expand=expand,
|
|
70
|
+
expand_loose=expand_loose,
|
|
71
|
+
col=col,
|
|
72
|
+
opacity=opacity,
|
|
73
|
+
rotate=rotate,
|
|
74
|
+
scale=scale,
|
|
75
|
+
offset=offset,
|
|
76
|
+
aspect_ratio=aspect_ratio,
|
|
77
|
+
animate_opacity=animate_opacity,
|
|
78
|
+
animate_size=animate_size,
|
|
79
|
+
animate_position=animate_position,
|
|
80
|
+
animate_rotation=animate_rotation,
|
|
81
|
+
animate_scale=animate_scale,
|
|
82
|
+
animate_offset=animate_offset,
|
|
83
|
+
on_animation_end=on_animation_end,
|
|
84
|
+
tooltip=tooltip,
|
|
85
|
+
visible=visible,
|
|
86
|
+
disabled=disabled,
|
|
87
|
+
data=data,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
self.on_load = on_load
|
|
91
|
+
self.on_error = on_error
|
|
92
|
+
self.on_open = on_open
|
|
93
|
+
self.on_close = on_close
|
|
94
|
+
self.on_impression = on_impression
|
|
95
|
+
self.on_click = on_click
|
|
96
|
+
self.on_will_dismiss = on_will_dismiss
|
|
97
|
+
self.unit_id = unit_id
|
|
98
|
+
|
|
99
|
+
def before_update(self):
|
|
100
|
+
assert self.page.platform in [
|
|
101
|
+
PagePlatform.ANDROID,
|
|
102
|
+
PagePlatform.IOS,
|
|
103
|
+
], f"{self.__class__.__name__} is only supported on Mobile (Android and iOS). "
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def unit_id(self) -> str:
|
|
107
|
+
return self._get_attr("unitId")
|
|
108
|
+
|
|
109
|
+
@unit_id.setter
|
|
110
|
+
def unit_id(self, value: str):
|
|
111
|
+
self._set_attr("unitId", value)
|
|
112
|
+
|
|
113
|
+
# on_load
|
|
114
|
+
@property
|
|
115
|
+
def on_load(self):
|
|
116
|
+
return self._get_event_handler("load")
|
|
117
|
+
|
|
118
|
+
@on_load.setter
|
|
119
|
+
def on_load(self, handler):
|
|
120
|
+
self._add_event_handler("load", handler)
|
|
121
|
+
|
|
122
|
+
# on_error
|
|
123
|
+
@property
|
|
124
|
+
def on_error(self):
|
|
125
|
+
return self._get_event_handler("error")
|
|
126
|
+
|
|
127
|
+
@on_error.setter
|
|
128
|
+
def on_error(self, handler):
|
|
129
|
+
self._add_event_handler("error", handler)
|
|
130
|
+
|
|
131
|
+
# on_open
|
|
132
|
+
@property
|
|
133
|
+
def on_open(self):
|
|
134
|
+
return self._get_event_handler("open")
|
|
135
|
+
|
|
136
|
+
@on_open.setter
|
|
137
|
+
def on_open(self, handler):
|
|
138
|
+
self._add_event_handler("open", handler)
|
|
139
|
+
|
|
140
|
+
# on_close
|
|
141
|
+
@property
|
|
142
|
+
def on_close(self):
|
|
143
|
+
return self._get_event_handler("close")
|
|
144
|
+
|
|
145
|
+
@on_close.setter
|
|
146
|
+
def on_close(self, handler):
|
|
147
|
+
self._add_event_handler("close", handler)
|
|
148
|
+
|
|
149
|
+
# on_click
|
|
150
|
+
@property
|
|
151
|
+
def on_click(self):
|
|
152
|
+
return self._get_event_handler("click")
|
|
153
|
+
|
|
154
|
+
@on_click.setter
|
|
155
|
+
def on_click(self, handler):
|
|
156
|
+
self._add_event_handler("click", handler)
|
|
157
|
+
|
|
158
|
+
# on_impression
|
|
159
|
+
@property
|
|
160
|
+
def on_impression(self):
|
|
161
|
+
return self._get_event_handler("impression")
|
|
162
|
+
|
|
163
|
+
@on_impression.setter
|
|
164
|
+
def on_impression(self, handler):
|
|
165
|
+
self._add_event_handler("impression", handler)
|
|
166
|
+
|
|
167
|
+
# on_will_dismiss
|
|
168
|
+
@property
|
|
169
|
+
def on_will_dismiss(self):
|
|
170
|
+
return self._get_event_handler("willDismiss")
|
|
171
|
+
|
|
172
|
+
@on_will_dismiss.setter
|
|
173
|
+
def on_will_dismiss(self, handler):
|
|
174
|
+
self._add_event_handler("willDismiss", handler)
|
flet_ads/interstitial.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from typing import Any, Optional, Union
|
|
2
|
+
|
|
3
|
+
from flet.core.animation import AnimationValue
|
|
4
|
+
from flet.core.control import OptionalNumber
|
|
5
|
+
from flet.core.ref import Ref
|
|
6
|
+
from flet.core.types import (
|
|
7
|
+
OffsetValue,
|
|
8
|
+
OptionalControlEventCallable,
|
|
9
|
+
ResponsiveNumber,
|
|
10
|
+
RotateValue,
|
|
11
|
+
ScaleValue,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from flet_ads.base_ad import BaseAd
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class InterstitialAd(BaseAd):
|
|
18
|
+
"""
|
|
19
|
+
Displays a full screen interstitial ad.
|
|
20
|
+
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
Online docs: https://flet.dev/docs/controls/interstitialad
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
unit_id: str,
|
|
29
|
+
on_load: OptionalControlEventCallable = None,
|
|
30
|
+
on_error: OptionalControlEventCallable = None,
|
|
31
|
+
on_open: OptionalControlEventCallable = None,
|
|
32
|
+
on_close: OptionalControlEventCallable = None,
|
|
33
|
+
on_impression: OptionalControlEventCallable = None,
|
|
34
|
+
on_click: OptionalControlEventCallable = None,
|
|
35
|
+
#
|
|
36
|
+
# ConstrainedControl
|
|
37
|
+
#
|
|
38
|
+
ref: Optional[Ref] = None,
|
|
39
|
+
key: Optional[str] = None,
|
|
40
|
+
width: OptionalNumber = None,
|
|
41
|
+
height: OptionalNumber = None,
|
|
42
|
+
left: OptionalNumber = None,
|
|
43
|
+
top: OptionalNumber = None,
|
|
44
|
+
right: OptionalNumber = None,
|
|
45
|
+
bottom: OptionalNumber = None,
|
|
46
|
+
expand: Union[None, bool, int] = None,
|
|
47
|
+
expand_loose: Optional[bool] = None,
|
|
48
|
+
col: Optional[ResponsiveNumber] = None,
|
|
49
|
+
opacity: OptionalNumber = None,
|
|
50
|
+
rotate: RotateValue = None,
|
|
51
|
+
scale: ScaleValue = None,
|
|
52
|
+
offset: OffsetValue = None,
|
|
53
|
+
aspect_ratio: OptionalNumber = None,
|
|
54
|
+
animate_opacity: AnimationValue = None,
|
|
55
|
+
animate_size: AnimationValue = None,
|
|
56
|
+
animate_position: AnimationValue = None,
|
|
57
|
+
animate_rotation: AnimationValue = None,
|
|
58
|
+
animate_scale: AnimationValue = None,
|
|
59
|
+
animate_offset: AnimationValue = None,
|
|
60
|
+
on_animation_end: OptionalControlEventCallable = None,
|
|
61
|
+
tooltip: Optional[str] = None,
|
|
62
|
+
visible: Optional[bool] = None,
|
|
63
|
+
disabled: Optional[bool] = None,
|
|
64
|
+
data: Any = None,
|
|
65
|
+
):
|
|
66
|
+
BaseAd.__init__(
|
|
67
|
+
self,
|
|
68
|
+
unit_id=unit_id,
|
|
69
|
+
on_load=on_load,
|
|
70
|
+
on_error=on_error,
|
|
71
|
+
on_open=on_open,
|
|
72
|
+
on_close=on_close,
|
|
73
|
+
on_impression=on_impression,
|
|
74
|
+
on_click=on_click,
|
|
75
|
+
#
|
|
76
|
+
# ConstrainedControl
|
|
77
|
+
#
|
|
78
|
+
ref=ref,
|
|
79
|
+
key=key,
|
|
80
|
+
width=width,
|
|
81
|
+
height=height,
|
|
82
|
+
left=left,
|
|
83
|
+
top=top,
|
|
84
|
+
right=right,
|
|
85
|
+
bottom=bottom,
|
|
86
|
+
expand=expand,
|
|
87
|
+
expand_loose=expand_loose,
|
|
88
|
+
col=col,
|
|
89
|
+
opacity=opacity,
|
|
90
|
+
rotate=rotate,
|
|
91
|
+
scale=scale,
|
|
92
|
+
offset=offset,
|
|
93
|
+
aspect_ratio=aspect_ratio,
|
|
94
|
+
animate_opacity=animate_opacity,
|
|
95
|
+
animate_size=animate_size,
|
|
96
|
+
animate_position=animate_position,
|
|
97
|
+
animate_rotation=animate_rotation,
|
|
98
|
+
animate_scale=animate_scale,
|
|
99
|
+
animate_offset=animate_offset,
|
|
100
|
+
on_animation_end=on_animation_end,
|
|
101
|
+
tooltip=tooltip,
|
|
102
|
+
visible=visible,
|
|
103
|
+
disabled=disabled,
|
|
104
|
+
data=data,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
def _get_control_name(self):
|
|
108
|
+
return "interstitial_ad"
|
|
109
|
+
|
|
110
|
+
def show(self):
|
|
111
|
+
self.invoke_method("show")
|
flet_ads/native.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Any, Optional, Union
|
|
4
|
+
|
|
5
|
+
from flet.core.animation import AnimationValue
|
|
6
|
+
from flet.core.control import OptionalNumber
|
|
7
|
+
from flet.core.ref import Ref
|
|
8
|
+
from flet.core.types import OffsetValue, ResponsiveNumber, RotateValue, ScaleValue
|
|
9
|
+
|
|
10
|
+
from flet_ads.base_ad import BaseAd
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NativeAdTemplateType(Enum):
|
|
14
|
+
SMALL = "small"
|
|
15
|
+
MEDIUM = "medium"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class NativeTemplateFontStyle(Enum):
|
|
19
|
+
NORMAL = "normal"
|
|
20
|
+
BOLD = "bold"
|
|
21
|
+
ITALIC = "italic"
|
|
22
|
+
MONOSPACE = "monospace"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclasses.dataclass
|
|
26
|
+
class NativeAdTemplateTextStyle:
|
|
27
|
+
size: OptionalNumber = dataclasses.field(default=None)
|
|
28
|
+
text_color: Optional[str] = dataclasses.field(default=None)
|
|
29
|
+
bgcolor: Optional[str] = dataclasses.field(default=None)
|
|
30
|
+
style: Optional[NativeTemplateFontStyle] = dataclasses.field(default=None)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclasses.dataclass
|
|
34
|
+
class NativeAdTemplateStyle:
|
|
35
|
+
template_type: Optional[NativeAdTemplateType] = dataclasses.field(default=None)
|
|
36
|
+
main_bgcolor: Optional[str] = dataclasses.field(default=None)
|
|
37
|
+
corner_radius: OptionalNumber = dataclasses.field(default=None)
|
|
38
|
+
call_to_action_text_style: Optional[NativeAdTemplateTextStyle] = dataclasses.field(
|
|
39
|
+
default=None
|
|
40
|
+
)
|
|
41
|
+
primary_text_style: Optional[NativeAdTemplateTextStyle] = dataclasses.field(
|
|
42
|
+
default=None
|
|
43
|
+
)
|
|
44
|
+
secondary_text_style: Optional[NativeAdTemplateTextStyle] = dataclasses.field(
|
|
45
|
+
default=None
|
|
46
|
+
)
|
|
47
|
+
tertiary_text_style: Optional[NativeAdTemplateTextStyle] = dataclasses.field(
|
|
48
|
+
default=None
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class NativeAd(BaseAd):
|
|
53
|
+
"""
|
|
54
|
+
TBA
|
|
55
|
+
|
|
56
|
+
-----
|
|
57
|
+
|
|
58
|
+
Online docs: https://flet.dev/docs/controls/nativead
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
unit_id: str = None,
|
|
64
|
+
factory_id: str = None,
|
|
65
|
+
template_style: NativeAdTemplateStyle = None,
|
|
66
|
+
on_load=None,
|
|
67
|
+
on_error=None,
|
|
68
|
+
on_open=None,
|
|
69
|
+
on_close=None,
|
|
70
|
+
on_impression=None,
|
|
71
|
+
on_click=None,
|
|
72
|
+
on_will_dismiss=None,
|
|
73
|
+
#
|
|
74
|
+
# ConstrainedControl
|
|
75
|
+
#
|
|
76
|
+
ref: Optional[Ref] = None,
|
|
77
|
+
key: Optional[str] = None,
|
|
78
|
+
width: OptionalNumber = None,
|
|
79
|
+
height: OptionalNumber = None,
|
|
80
|
+
left: OptionalNumber = None,
|
|
81
|
+
top: OptionalNumber = None,
|
|
82
|
+
right: OptionalNumber = None,
|
|
83
|
+
bottom: OptionalNumber = None,
|
|
84
|
+
expand: Union[None, bool, int] = None,
|
|
85
|
+
expand_loose: Optional[bool] = None,
|
|
86
|
+
col: Optional[ResponsiveNumber] = None,
|
|
87
|
+
opacity: OptionalNumber = None,
|
|
88
|
+
rotate: RotateValue = None,
|
|
89
|
+
scale: ScaleValue = None,
|
|
90
|
+
offset: OffsetValue = None,
|
|
91
|
+
aspect_ratio: OptionalNumber = None,
|
|
92
|
+
animate_opacity: AnimationValue = None,
|
|
93
|
+
animate_size: AnimationValue = None,
|
|
94
|
+
animate_position: AnimationValue = None,
|
|
95
|
+
animate_rotation: AnimationValue = None,
|
|
96
|
+
animate_scale: AnimationValue = None,
|
|
97
|
+
animate_offset: AnimationValue = None,
|
|
98
|
+
on_animation_end=None,
|
|
99
|
+
tooltip: Optional[str] = None,
|
|
100
|
+
visible: Optional[bool] = None,
|
|
101
|
+
disabled: Optional[bool] = None,
|
|
102
|
+
data: Any = None,
|
|
103
|
+
):
|
|
104
|
+
BaseAd.__init__(
|
|
105
|
+
self,
|
|
106
|
+
unit_id=unit_id,
|
|
107
|
+
on_load=on_load,
|
|
108
|
+
on_error=on_error,
|
|
109
|
+
on_open=on_open,
|
|
110
|
+
on_close=on_close,
|
|
111
|
+
on_impression=on_impression,
|
|
112
|
+
on_click=on_click,
|
|
113
|
+
on_will_dismiss=on_will_dismiss,
|
|
114
|
+
#
|
|
115
|
+
# ConstrainedControl
|
|
116
|
+
#
|
|
117
|
+
ref=ref,
|
|
118
|
+
key=key,
|
|
119
|
+
width=width,
|
|
120
|
+
height=height,
|
|
121
|
+
left=left,
|
|
122
|
+
top=top,
|
|
123
|
+
right=right,
|
|
124
|
+
bottom=bottom,
|
|
125
|
+
expand=expand,
|
|
126
|
+
expand_loose=expand_loose,
|
|
127
|
+
col=col,
|
|
128
|
+
opacity=opacity,
|
|
129
|
+
rotate=rotate,
|
|
130
|
+
scale=scale,
|
|
131
|
+
offset=offset,
|
|
132
|
+
aspect_ratio=aspect_ratio,
|
|
133
|
+
animate_opacity=animate_opacity,
|
|
134
|
+
animate_size=animate_size,
|
|
135
|
+
animate_position=animate_position,
|
|
136
|
+
animate_rotation=animate_rotation,
|
|
137
|
+
animate_scale=animate_scale,
|
|
138
|
+
animate_offset=animate_offset,
|
|
139
|
+
on_animation_end=on_animation_end,
|
|
140
|
+
tooltip=tooltip,
|
|
141
|
+
visible=visible,
|
|
142
|
+
disabled=disabled,
|
|
143
|
+
data=data,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
self.template_style = template_style
|
|
147
|
+
self.factory_id = factory_id
|
|
148
|
+
|
|
149
|
+
def _get_control_name(self):
|
|
150
|
+
return "native_ad"
|
|
151
|
+
|
|
152
|
+
def before_update(self):
|
|
153
|
+
super().before_update()
|
|
154
|
+
self._set_attr_json("templateStyle", self.__template_style)
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def template_style(self):
|
|
158
|
+
return self.__template_style
|
|
159
|
+
|
|
160
|
+
@template_style.setter
|
|
161
|
+
def template_style(self, value):
|
|
162
|
+
self.__template_style = value
|
|
163
|
+
|
|
164
|
+
# factory_id
|
|
165
|
+
@property
|
|
166
|
+
def factory_id(self) -> Optional[str]:
|
|
167
|
+
return self._get_attr("factoryId")
|
|
168
|
+
|
|
169
|
+
@factory_id.setter
|
|
170
|
+
def factory_id(self, value: Optional[str]):
|
|
171
|
+
self._set_attr("factoryId", value)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: flet-ads
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ads controls for Flet
|
|
5
|
+
Author-email: Flet contributors <hello@flet.dev>
|
|
6
|
+
Project-URL: Homepage, https://flet.dev
|
|
7
|
+
Project-URL: Documentation, https://flet.dev/docs/controls/ads
|
|
8
|
+
Project-URL: Repository, https://github.com/flet-dev/flet-ads
|
|
9
|
+
Project-URL: Issues, https://github.com/flet-dev/flet-ads/issues
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: flet>=0.25.2
|
|
14
|
+
|
|
15
|
+
# Ads controls for Flet
|
|
16
|
+
|
|
17
|
+
`BannerAd` and `InterstitialAd` controls for Flet.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Add `flet-ads` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
|
|
25
|
+
```py
|
|
26
|
+
|
|
27
|
+
import flet as ft
|
|
28
|
+
|
|
29
|
+
import flet_ads as ads
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def main(page: ft.Page):
|
|
33
|
+
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
|
34
|
+
|
|
35
|
+
id_interstitial = (
|
|
36
|
+
"ca-app-pub-3940256099942544/1033173712"
|
|
37
|
+
if page.platform == ft.PagePlatform.ANDROID
|
|
38
|
+
else "ca-app-pub-3940256099942544/4411468910"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
id_banner = (
|
|
42
|
+
"ca-app-pub-3940256099942544/6300978111"
|
|
43
|
+
if page.platform == ft.PagePlatform.ANDROID
|
|
44
|
+
else "ca-app-pub-3940256099942544/2934735716"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def handle_interstitial_close(e):
|
|
48
|
+
nonlocal iad
|
|
49
|
+
print("InterstitialAd closed")
|
|
50
|
+
page.overlay.remove(e.control)
|
|
51
|
+
page.overlay.append(iad := get_new_interstitial_ad())
|
|
52
|
+
page.update()
|
|
53
|
+
|
|
54
|
+
def get_new_interstitial_ad():
|
|
55
|
+
return ads.InterstitialAd(
|
|
56
|
+
unit_id=id_interstitial,
|
|
57
|
+
on_load=lambda e: print("InterstitialAd loaded"),
|
|
58
|
+
on_error=lambda e: print("InterstitialAd error", e.data),
|
|
59
|
+
on_open=lambda e: print("InterstitialAd opened"),
|
|
60
|
+
on_close=handle_interstitial_close,
|
|
61
|
+
on_impression=lambda e: print("InterstitialAd impression"),
|
|
62
|
+
on_click=lambda e: print("InterstitialAd clicked"),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def display_new_banner_ad():
|
|
66
|
+
page.add(
|
|
67
|
+
ft.Container(
|
|
68
|
+
content=ads.BannerAd(
|
|
69
|
+
unit_id=id_banner,
|
|
70
|
+
on_click=lambda e: print("BannerAd clicked"),
|
|
71
|
+
on_load=lambda e: print("BannerAd loaded"),
|
|
72
|
+
on_error=lambda e: print("BannerAd error", e.data),
|
|
73
|
+
on_open=lambda e: print("BannerAd opened"),
|
|
74
|
+
on_close=lambda e: print("BannerAd closed"),
|
|
75
|
+
on_impression=lambda e: print("BannerAd impression"),
|
|
76
|
+
on_will_dismiss=lambda e: print("BannerAd will dismiss"),
|
|
77
|
+
),
|
|
78
|
+
width=320,
|
|
79
|
+
height=50,
|
|
80
|
+
bgcolor=ft.colors.TRANSPARENT,
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
page.overlay.append(iad := get_new_interstitial_ad())
|
|
85
|
+
page.appbar = ft.AppBar(
|
|
86
|
+
adaptive=True,
|
|
87
|
+
title=ft.Text("Mobile Ads Playground"),
|
|
88
|
+
bgcolor=ft.colors.LIGHT_BLUE_300,
|
|
89
|
+
)
|
|
90
|
+
page.add(
|
|
91
|
+
ft.OutlinedButton("Show InterstitialAd", on_click=lambda e: iad.show()),
|
|
92
|
+
ft.OutlinedButton("Show BannerAd", on_click=lambda e: display_new_banner_ad()),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
ft.app(main)
|
|
97
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
flet_ads/__init__.py,sha256=YmJRcMtuH33BZTprwZNCWz1kTXzPs7Ro7AusRt3kaUM,260
|
|
2
|
+
flet_ads/banner.py,sha256=0Z1WthSu5ikQw72-netom6TK8KNNO9MzGSWZdeyddkY,3388
|
|
3
|
+
flet_ads/base_ad.py,sha256=4jvDFwdeiSZUSfNq-7NpI8FuaAAL9t-H4YhMyKIiSmI,5144
|
|
4
|
+
flet_ads/interstitial.py,sha256=1r8Y0BIF641e2jMqRU19Xv0d_X4I3H99pvtOb2VUUWQ,3373
|
|
5
|
+
flet_ads/native.py,sha256=mx4haIzoEs_1cQe9HGtci4qgVx-mOg_YISd00hmWd40,5066
|
|
6
|
+
flutter/flet_ads/CHANGELOG.md,sha256=66sWepPaeTc9_lzcYIGU55AlxSU5Z1XVtknXpzd_-p8,40
|
|
7
|
+
flutter/flet_ads/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
8
|
+
flutter/flet_ads/README.md,sha256=PyyWlFSXK26RDkXzhow7KXNwhbnWXxnIvJNtqOcTYIE,110
|
|
9
|
+
flutter/flet_ads/analysis_options.yaml,sha256=32kjGAc-zF87inWaH5M46yGZWQDTwrwfvNLHeAocfG4,154
|
|
10
|
+
flutter/flet_ads/pubspec.lock,sha256=PC5lkP4lgUNzey5sINtW8rJCtv9M5kg4VQJqiroXCHs,22557
|
|
11
|
+
flutter/flet_ads/pubspec.yaml,sha256=TxD47c-N36ND1RDwmSzqoYTWEYisN25vdKPubqg3fXA,399
|
|
12
|
+
flutter/flet_ads/lib/flet_ads.dart,sha256=HDyBvKWjtM00srxdFl-O9uXAkgNID9tKtByEL7_dhVg,91
|
|
13
|
+
flutter/flet_ads/lib/src/banner.dart,sha256=6ODCVYoQCFd_wnjRBFb25ujWCgTG5YiONlVkbRZKtLM,3282
|
|
14
|
+
flutter/flet_ads/lib/src/create_control.dart,sha256=4S-OKSYA4wFxF8CxIWGjW43Hm_9z-lC-RRpNHl6b_2g,888
|
|
15
|
+
flutter/flet_ads/lib/src/interstitial.dart,sha256=g46c6RkFEzUVoiUtaw1g4wNEnfXXFFnEEy6Xuz8Ap-4,3044
|
|
16
|
+
flutter/flet_ads/lib/src/native.dart,sha256=gA3-wvqahV929JKEmxys4jXtNBUUTlo_3nDJUWvOryU,5609
|
|
17
|
+
flutter/flet_ads/lib/utils/native.dart,sha256=jiG1bT3shp3bix7gXL6GooUjTsvi7A1aZNn4ipQu76g,2425
|
|
18
|
+
flet_ads-0.1.0.dist-info/METADATA,sha256=AkkbeQvBzLF6Ajmd-HBAJUo2D_HVSG1ZlVzGXlNACpY,3127
|
|
19
|
+
flet_ads-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
20
|
+
flet_ads-0.1.0.dist-info/top_level.txt,sha256=Pguk7IG_usM8ZGyS1kjv-mZZhGKthm_734FmTIqDLBE,17
|
|
21
|
+
flet_ads-0.1.0.dist-info/RECORD,,
|