flet-ads 0.1.0__py3-none-any.whl → 0.2.0.dev34__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 -9
- flet_ads/banner_ad.py +29 -0
- flet_ads/base_ad.py +65 -172
- flet_ads/interstitial_ad.py +21 -0
- flet_ads/native_ad.py +32 -0
- flet_ads/types.py +129 -0
- flet_ads-0.2.0.dev34.dist-info/METADATA +66 -0
- flet_ads-0.2.0.dev34.dist-info/RECORD +11 -0
- {flet_ads-0.1.0.dist-info → flet_ads-0.2.0.dev34.dist-info}/WHEEL +1 -1
- {flutter/flet_ads → flet_ads-0.2.0.dev34.dist-info/licenses}/LICENSE +1 -1
- {flet_ads-0.1.0.dist-info → flet_ads-0.2.0.dev34.dist-info}/top_level.txt +0 -1
- flet_ads/banner.py +0 -110
- flet_ads/interstitial.py +0 -111
- flet_ads/native.py +0 -171
- flet_ads-0.1.0.dist-info/METADATA +0 -97
- flet_ads-0.1.0.dist-info/RECORD +0 -21
- flutter/flet_ads/CHANGELOG.md +0 -3
- flutter/flet_ads/README.md +0 -3
- flutter/flet_ads/analysis_options.yaml +0 -4
- flutter/flet_ads/lib/flet_ads.dart +0 -3
- flutter/flet_ads/lib/src/banner.dart +0 -96
- flutter/flet_ads/lib/src/create_control.dart +0 -29
- flutter/flet_ads/lib/src/interstitial.dart +0 -83
- flutter/flet_ads/lib/src/native.dart +0 -153
- flutter/flet_ads/lib/utils/native.dart +0 -69
- flutter/flet_ads/pubspec.lock +0 -759
- flutter/flet_ads/pubspec.yaml +0 -18
flet_ads/interstitial.py
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
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)
|
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
```
|
flet_ads-0.1.0.dist-info/RECORD
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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,,
|
flutter/flet_ads/CHANGELOG.md
DELETED
flutter/flet_ads/README.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import 'dart:convert';
|
|
2
|
-
|
|
3
|
-
import 'package:flet/flet.dart';
|
|
4
|
-
import 'package:flutter/widgets.dart';
|
|
5
|
-
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
|
6
|
-
|
|
7
|
-
class BannerAdControl extends StatefulWidget {
|
|
8
|
-
final Control? parent;
|
|
9
|
-
final Control control;
|
|
10
|
-
final FletControlBackend backend;
|
|
11
|
-
|
|
12
|
-
const BannerAdControl(
|
|
13
|
-
{super.key,
|
|
14
|
-
required this.parent,
|
|
15
|
-
required this.control,
|
|
16
|
-
required this.backend});
|
|
17
|
-
|
|
18
|
-
@override
|
|
19
|
-
State<BannerAdControl> createState() => _BannerAdControlState();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class _BannerAdControlState extends State<BannerAdControl> with FletStoreMixin {
|
|
23
|
-
bool _isLoaded = false;
|
|
24
|
-
|
|
25
|
-
@override
|
|
26
|
-
Widget build(BuildContext context) {
|
|
27
|
-
debugPrint(
|
|
28
|
-
"BannerAd build: ${widget.control.id} (${widget.control.hashCode})");
|
|
29
|
-
return withPagePlatform((context, platform) {
|
|
30
|
-
final testAdUnitId = platform == TargetPlatform.iOS
|
|
31
|
-
? 'ca-app-pub-3940256099942544/4411468910'
|
|
32
|
-
: 'ca-app-pub-3940256099942544/1033173712';
|
|
33
|
-
BannerAd bannerAd = BannerAd(
|
|
34
|
-
adUnitId: widget.control.attrString("unitId", testAdUnitId)!,
|
|
35
|
-
request: const AdRequest(),
|
|
36
|
-
size: AdSize.banner,
|
|
37
|
-
listener: BannerAdListener(
|
|
38
|
-
// Called when an ad is successfully received.
|
|
39
|
-
onAdLoaded: (ad) {
|
|
40
|
-
widget.backend.triggerControlEvent(widget.control.id, "load");
|
|
41
|
-
setState(() {
|
|
42
|
-
_isLoaded = true;
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
// Called when an ad request failed.
|
|
46
|
-
onAdFailedToLoad: (ad, error) {
|
|
47
|
-
widget.backend.triggerControlEvent(
|
|
48
|
-
widget.control.id, "error", error.toString());
|
|
49
|
-
debugPrint("BANNER AD failed to load: $error");
|
|
50
|
-
// Dispose the ad to free resources.
|
|
51
|
-
ad.dispose();
|
|
52
|
-
setState(() {
|
|
53
|
-
_isLoaded = false;
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
// Called when an ad opens an overlay that covers the screen.
|
|
57
|
-
onAdOpened: (Ad ad) {
|
|
58
|
-
widget.backend.triggerControlEvent(widget.control.id, "open");
|
|
59
|
-
},
|
|
60
|
-
// Called when an ad removes an overlay that covers the screen.
|
|
61
|
-
onAdClosed: (Ad ad) {
|
|
62
|
-
widget.backend.triggerControlEvent(widget.control.id, "close");
|
|
63
|
-
},
|
|
64
|
-
onAdClicked: (Ad ad) {
|
|
65
|
-
widget.backend.triggerControlEvent(widget.control.id, "click");
|
|
66
|
-
},
|
|
67
|
-
onAdWillDismissScreen: (Ad ad) {
|
|
68
|
-
widget.backend
|
|
69
|
-
.triggerControlEvent(widget.control.id, "willDismiss");
|
|
70
|
-
},
|
|
71
|
-
onPaidEvent: (ad, valueMicros, precision, currencyCode) {
|
|
72
|
-
widget.backend.triggerControlEvent(
|
|
73
|
-
widget.control.id,
|
|
74
|
-
"paidEvent",
|
|
75
|
-
jsonEncode({
|
|
76
|
-
"value_micros": valueMicros,
|
|
77
|
-
"precision": precision,
|
|
78
|
-
"currency_code": currencyCode
|
|
79
|
-
}));
|
|
80
|
-
},
|
|
81
|
-
// Called when an impression occurs on the ad.
|
|
82
|
-
onAdImpression: (Ad ad) {
|
|
83
|
-
widget.backend.triggerControlEvent(widget.control.id, "impression");
|
|
84
|
-
},
|
|
85
|
-
),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
if (!_isLoaded) {
|
|
89
|
-
bannerAd.load();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return constrainedControl(
|
|
93
|
-
context, AdWidget(ad: bannerAd), widget.parent, widget.control);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import 'package:flet/flet.dart';
|
|
2
|
-
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
|
3
|
-
|
|
4
|
-
import 'banner.dart';
|
|
5
|
-
import 'interstitial.dart';
|
|
6
|
-
|
|
7
|
-
CreateControlFactory createControl = (CreateControlArgs args) {
|
|
8
|
-
switch (args.control.type) {
|
|
9
|
-
case "banner_ad":
|
|
10
|
-
return BannerAdControl(
|
|
11
|
-
parent: args.parent, control: args.control, backend: args.backend);
|
|
12
|
-
case "interstitial_ad":
|
|
13
|
-
return InterstitialAdControl(
|
|
14
|
-
parent: args.parent, control: args.control, backend: args.backend);
|
|
15
|
-
/* TODO: Finalize NativeAdControl -> https://developers.google.com/admob/flutter/native/platforms
|
|
16
|
-
case "native_ad":
|
|
17
|
-
return NativeAdControl(
|
|
18
|
-
parent: args.parent, control: args.control, backend: args.backend);
|
|
19
|
-
*/
|
|
20
|
-
default:
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
void ensureInitialized() {
|
|
26
|
-
if (isMobilePlatform()) {
|
|
27
|
-
MobileAds.instance.initialize();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import 'package:flet/flet.dart';
|
|
2
|
-
import 'package:flutter/widgets.dart';
|
|
3
|
-
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
|
4
|
-
|
|
5
|
-
class InterstitialAdControl extends StatefulWidget {
|
|
6
|
-
final Control? parent;
|
|
7
|
-
final Control control;
|
|
8
|
-
final FletControlBackend backend;
|
|
9
|
-
|
|
10
|
-
const InterstitialAdControl(
|
|
11
|
-
{super.key,
|
|
12
|
-
required this.parent,
|
|
13
|
-
required this.control,
|
|
14
|
-
required this.backend});
|
|
15
|
-
|
|
16
|
-
@override
|
|
17
|
-
State<InterstitialAdControl> createState() => _InterstitialAdControlState();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class _InterstitialAdControlState extends State<InterstitialAdControl>
|
|
21
|
-
with FletStoreMixin {
|
|
22
|
-
InterstitialAd? _interstitialAd;
|
|
23
|
-
|
|
24
|
-
@override
|
|
25
|
-
Widget build(BuildContext context) {
|
|
26
|
-
debugPrint(
|
|
27
|
-
"InterstitialAd build: ${widget.control.id} (${widget.control.hashCode})");
|
|
28
|
-
return withPagePlatform((context, platform) {
|
|
29
|
-
final testAdUnitId = platform == TargetPlatform.iOS
|
|
30
|
-
? 'ca-app-pub-3940256099942544/4411468910'
|
|
31
|
-
: 'ca-app-pub-3940256099942544/1033173712';
|
|
32
|
-
InterstitialAd.load(
|
|
33
|
-
adUnitId: widget.control.attrString("unitId", testAdUnitId)!,
|
|
34
|
-
request: const AdRequest(),
|
|
35
|
-
adLoadCallback: InterstitialAdLoadCallback(
|
|
36
|
-
onAdLoaded: (ad) {
|
|
37
|
-
ad.fullScreenContentCallback =
|
|
38
|
-
FullScreenContentCallback(onAdShowedFullScreenContent: (ad) {
|
|
39
|
-
widget.backend.triggerControlEvent(widget.control.id, "open");
|
|
40
|
-
}, onAdImpression: (ad) {
|
|
41
|
-
widget.backend
|
|
42
|
-
.triggerControlEvent(widget.control.id, "impression");
|
|
43
|
-
}, onAdFailedToShowFullScreenContent: (ad, err) {
|
|
44
|
-
widget.backend.triggerControlEvent(widget.control.id, "error");
|
|
45
|
-
// Dispose the ad here to free resources.
|
|
46
|
-
ad.dispose();
|
|
47
|
-
},
|
|
48
|
-
// Called when the ad dismissed full screen content.
|
|
49
|
-
onAdDismissedFullScreenContent: (ad) {
|
|
50
|
-
widget.backend.triggerControlEvent(widget.control.id, "close");
|
|
51
|
-
// Dispose the ad here to free resources.
|
|
52
|
-
ad.dispose();
|
|
53
|
-
}, onAdClicked: (ad) {
|
|
54
|
-
widget.backend.triggerControlEvent(widget.control.id, "click");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Keep a reference to show it later.
|
|
58
|
-
_interstitialAd = ad;
|
|
59
|
-
widget.backend.triggerControlEvent(widget.control.id, "load");
|
|
60
|
-
},
|
|
61
|
-
onAdFailedToLoad: (LoadAdError error) {
|
|
62
|
-
debugPrint('InterstitialAd failed to load: $error');
|
|
63
|
-
_interstitialAd?.dispose();
|
|
64
|
-
},
|
|
65
|
-
));
|
|
66
|
-
|
|
67
|
-
() async {
|
|
68
|
-
widget.backend.subscribeMethods(widget.control.id,
|
|
69
|
-
(methodName, args) async {
|
|
70
|
-
switch (methodName) {
|
|
71
|
-
case "show":
|
|
72
|
-
debugPrint("InterstitialAd.show($hashCode)");
|
|
73
|
-
_interstitialAd?.show();
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
});
|
|
78
|
-
}();
|
|
79
|
-
|
|
80
|
-
return const SizedBox.shrink();
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|