Skip to content

Commit e738dd0

Browse files
0.27.4 Android splash and Loading screen (#43)
* Remove splash colors for Android 12 * Set icon_background_color * Remove icon_background_color * Splash Screen test * Fix if * Splash screen * get_config_platform() * Fix package_platform * Platform-specific splash_screen * Added trim * splash_screen_text * Fix condition * hide_loading_animation: false * loading_screen * Test get_pyproject() * Declare get_pyproject * Test my_custom_function * Test foobar filter * Fix splash_screen * Test greeter * Test context aware function * Fix get_pyproject * Remove macros * Test boot and startup screens * Fix appBootScreenMessage * Fix show setting * Cleanup
1 parent f063f13 commit e738dd0

File tree

6 files changed

+88
-37
lines changed

6 files changed

+88
-37
lines changed

cookiecutter.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"copyright": "Copyright (c) 2023 Your Company",
1111
"flutter": null,
1212
"sep": "/",
13-
"hide_loading_animation": true,
1413
"bundle_id": "{{ cookiecutter.bundle_id if 'bundle_id' in cookiecutter else cookiecutter.org_name + '.' + cookiecutter.project_name_slug }}",
1514
"org_name_2": "{{ cookiecutter.bundle_id.rsplit('.', 1)[0] if 'bundle_id' in cookiecutter else cookiecutter.org_name if 'org_name' in cookiecutter else 'com.flet' }}",
1615
"ios_provisioning_profile": "",
@@ -28,5 +27,6 @@
2827
"pwa_theme_color": "#0175C2",
2928
"split_per_abi": false,
3029
"options": null,
31-
"pyproject": null
30+
"pyproject": null,
31+
"_extensions": ["cookiecutter_extensions.FletExtension"]
3232
}

cookiecutter_extensions.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from jinja2 import pass_context
2+
from jinja2.ext import Extension
3+
4+
5+
class FletExtension(Extension):
6+
def __init__(self, environment):
7+
super(FletExtension, self).__init__(environment)
8+
environment.globals["get_pyproject"] = self.get_pyproject
9+
10+
@pass_context
11+
def get_pyproject(self, context, setting):
12+
pyproject = context.get("cookiecutter", {}).get("pyproject", {})
13+
14+
if not setting:
15+
return pyproject
16+
17+
d = pyproject
18+
for k in setting.split("."):
19+
d = d.get(k)
20+
if d is None:
21+
return None
22+
return d

{{cookiecutter.out_dir}}/_macros.jinja2

Lines changed: 0 additions & 16 deletions
This file was deleted.

{{cookiecutter.out_dir}}/android/app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% import "_macros.jinja2" as macros %}
21
plugins {
32
id "com.android.application"
43
id "kotlin-android"
@@ -50,8 +49,8 @@ android {
5049
main.java.srcDirs += 'src/main/kotlin'
5150
}
5251

53-
{% set min_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.min_sdk_version") | trim %}
54-
{% set target_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.target_sdk_version") | trim %}
52+
{% set min_sdk_version = get_pyproject("tool.flet.android.min_sdk_version") %}
53+
{% set target_sdk_version = get_pyproject("tool.flet.android.target_sdk_version") %}
5554

5655
defaultConfig {
5756
applicationId "{{ cookiecutter.org_name_2 }}.{{ cookiecutter.package_name }}"

{{cookiecutter.out_dir}}/lib/main.dart

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ import 'package:window_manager/window_manager.dart';
1414

1515
import "python.dart";
1616

17+
/*
18+
{% set show_boot_screen = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.boot_screen.show")
19+
or get_pyproject("tool.flet.app.boot_screen.show")
20+
or False %}
21+
{% set boot_screen_message = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.boot_screen.message")
22+
or get_pyproject("tool.flet.app.boot_screen.message") %}
23+
24+
{% set show_startup_screen = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.startup_screen.show")
25+
or get_pyproject("tool.flet.app.startup_screen.show")
26+
or False %}
27+
{% set startup_screen_message = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.startup_screen.message")
28+
or get_pyproject("tool.flet.app.startup_screen.message") %}
29+
30+
show_boot_screen: {{ show_boot_screen }}
31+
boot_screen_message: {{ boot_screen_message }}
32+
show_startup_screen: {{ show_startup_screen }}
33+
startup_screen_message: {{ startup_screen_message }}
34+
*/
35+
1736
{% for dep in cookiecutter.flutter.dependencies %}
1837
import 'package:{{ dep }}/{{ dep }}.dart' as {{ dep }};
1938
{% endfor %}
@@ -22,9 +41,10 @@ const bool isProduction = bool.fromEnvironment('dart.vm.product');
2241

2342
const assetPath = "app/app.zip";
2443
const pythonModuleName = "{{ cookiecutter.python_module_name }}";
25-
final hideLoadingPage =
26-
bool.tryParse("{{ cookiecutter.hide_loading_animation }}".toLowerCase()) ??
27-
true;
44+
final showAppBootScreen = bool.tryParse("{{ show_boot_screen }}".toLowerCase()) ?? false;
45+
const appBootScreenMessage = '{{ boot_screen_message | default("Preparing the app for its first launch…", true) }}';
46+
final showAppStartupScreen = bool.tryParse("{{ show_startup_screen }}".toLowerCase()) ?? false;
47+
const appStartupScreenMessage = '{{ startup_screen_message | default("Getting things ready…", true) }}';
2848

2949
List<CreateControlFactory> createControlFactories = [
3050
{% for dep in cookiecutter.flutter.dependencies %}
@@ -53,7 +73,8 @@ void main(List<String> args) async {
5373
? FletApp(
5474
pageUrl: pageUrl,
5575
assetsDir: assetsDir,
56-
hideLoadingPage: hideLoadingPage,
76+
showAppStartupScreen: showAppStartupScreen,
77+
appStartupScreenMessage: appStartupScreenMessage,
5778
createControlFactories: createControlFactories)
5879
: FutureBuilder(
5980
future: runPythonApp(args),
@@ -71,7 +92,8 @@ void main(List<String> args) async {
7192
return FletApp(
7293
pageUrl: pageUrl,
7394
assetsDir: assetsDir,
74-
hideLoadingPage: hideLoadingPage,
95+
showAppStartupScreen: showAppStartupScreen,
96+
appStartupScreenMessage: appStartupScreenMessage,
7597
createControlFactories: createControlFactories);
7698
}
7799
});
@@ -83,7 +105,7 @@ void main(List<String> args) async {
83105
text: snapshot.error.toString()));
84106
} else {
85107
// loading
86-
return const MaterialApp(home: BlankScreen());
108+
return MaterialApp(home: showAppBootScreen ? const BootScreen() : const BlankScreen());
87109
}
88110
}));
89111
}
@@ -294,6 +316,34 @@ class ErrorScreen extends StatelessWidget {
294316
}
295317
}
296318

319+
class BootScreen extends StatelessWidget {
320+
const BootScreen({
321+
super.key,
322+
});
323+
324+
@override
325+
Widget build(BuildContext context) {
326+
return Scaffold(
327+
body: Center(
328+
child: Column(
329+
mainAxisAlignment: MainAxisAlignment.center,
330+
children: [
331+
const SizedBox(
332+
width: 30,
333+
height: 30,
334+
child: CircularProgressIndicator(strokeWidth: 3),
335+
),
336+
const SizedBox(
337+
height: 10,
338+
),
339+
Text(appBootScreenMessage, style: Theme.of(context).textTheme.bodySmall,)
340+
],
341+
),
342+
),
343+
);
344+
}
345+
}
346+
297347
class BlankScreen extends StatelessWidget {
298348
const BlankScreen({
299349
super.key,

{{cookiecutter.out_dir}}/pubspec.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ dependencies:
2121
window_manager: ^0.4.3
2222

2323
dependency_overrides:
24-
flet: 0.27.4
24+
#flet: 0.27.4
2525

26-
# flet:
27-
# git:
28-
# path: packages/flet
29-
# ref: main
30-
# url: https://github.com/flet-dev/flet.git
26+
flet:
27+
git:
28+
path: packages/flet
29+
ref: feodor/flet-0-27-5-fixes
30+
url: https://github.com/flet-dev/flet.git
3131

3232
# serious_python:
3333
# git:
@@ -121,14 +121,10 @@ flutter_native_splash:
121121
# 768 pixels in diameter.
122122
image: "images/icon.png"
123123

124-
# Splash screen background color.
125-
color: "#ffffff"
126-
127124
# The image_dark, color_dark, icon_background_color_dark, and branding_dark set values that
128125
# apply when the device is in dark mode. If they are not specified, the app will use the
129126
# parameters from above.
130127
image_dark: "images/icon.png"
131-
color_dark: "#333333"
132128

133129
# The android, ios and web parameters can be used to disable generating a splash screen on a given
134130
# platform.

0 commit comments

Comments
 (0)