-
Notifications
You must be signed in to change notification settings - Fork 51
[flutter_splash_tizen] Initial implementation #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0a3c42e
0f4ad8a
abc30f7
065e874
1672142
5520b56
1ac69b2
4620b31
0ee9340
2f6303c
5917fce
0f73916
07f43b3
b3a41f7
0aa13d9
02e6a45
898757b
0b43e66
0cd16b6
220a58d
6301cb7
2ce30eb
e047ba7
5eacc8a
3944f4a
1c44a2a
6c75101
f41ffb1
bbd104d
e64f750
b3e8736
7794d00
ce20502
3f1f7bb
73a9641
718934e
9a3a0d3
7973e7b
18278a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
.vscode/ | ||
.idea/ | ||
build/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## 0.1.0 | ||
* Initial release |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of the copyright holder nor the names of the | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# flutter_splash_tizen | ||
|
||
Flutter-tizen package that allows to add custom splash-screen images into your apps. | ||
## Getting Started | ||
|
||
First you should add the package to dev_dependencies section in your `pubspec.yaml` | ||
|
||
```yaml | ||
dev_dependencies: | ||
flutter_splash_tizen: ^0.1.0 | ||
``` | ||
After that run | ||
``` | ||
flutter-tizen pub get | ||
``` | ||
in order to download the dependency. | ||
|
||
By adding | ||
```yaml | ||
flutter_splash_tizen: | ||
image: test.png | ||
``` | ||
section in your `pubspec.yaml` and running | ||
``` | ||
flutter-tizen pub run flutter_splash_tizen:create | ||
``` | ||
the image from `tizen/shared/res/test.png` will be added as splash screen. Each call of `create` will override the previous. <br> | ||
|
||
If you wish to remove the splash image from your app simply run | ||
``` | ||
flutter-tizen pub run flutter_splash_tizen:remove | ||
``` | ||
Package has been tested on Mobile 6.0, Wearable 6.0 and IoT Headed 6.5 platform. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:flutter_lints/flutter.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'dart:io'; | ||
import 'package:yaml/yaml.dart'; | ||
import 'package:xml/xml.dart'; | ||
|
||
Map? loadYamlFileSync(String path) { | ||
File file = File(path); | ||
if (file.existsSync()) { | ||
return loadYaml(file.readAsStringSync()); | ||
} | ||
return null; | ||
} | ||
|
||
XmlDocument? loadXMLFileSync(String path) { | ||
File file = File(path); | ||
if (file.existsSync()) { | ||
return XmlDocument.parse(file.readAsStringSync()); | ||
} | ||
return null; | ||
} | ||
|
||
void main() { | ||
var doc = loadYamlFileSync("pubspec.yaml")?['flutter_splash_tizen']; | ||
if (doc == null) throw const FormatException("could not read pubspec.yaml!"); | ||
|
||
String? image = doc["image"]; | ||
if (image == null) { | ||
throw const FormatException("could not find image section!"); | ||
} | ||
const String tizenManifestPath = "tizen/tizen-manifest.xml"; | ||
|
||
XmlDocument? tizenManifest = loadXMLFileSync(tizenManifestPath); | ||
if (tizenManifest == null) { | ||
throw const FormatException("could not read tizen-manifext.xml!"); | ||
} | ||
XmlNode el = tizenManifest.root; | ||
|
||
XmlElement? uiApp = el.getElement("manifest")?.getElement("ui-application"); | ||
if (uiApp == null) { | ||
throw const FormatException("error when reading $tizenManifestPath"); | ||
} | ||
XmlElement? splashScreens = uiApp.getElement("splash-screens"); | ||
if (splashScreens == null) { | ||
splashScreens = XmlElement(XmlName("splash-screens")); | ||
uiApp.children.add(splashScreens); | ||
} | ||
|
||
splashScreens.children.clear(); | ||
XmlElement splashScreen = XmlElement(XmlName("splash-screen")); | ||
splashScreen.setAttribute("src", image); | ||
splashScreen.setAttribute("type", "img"); | ||
splashScreen.setAttribute("indicator-display", "false"); | ||
splashScreen.setAttribute("orientation", "portrait"); | ||
splashScreens.children.add(splashScreen); | ||
|
||
File(tizenManifestPath) | ||
.writeAsStringSync(el.toXmlString(pretty: true, indent: ' ') + '\n'); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:io'; | ||
import 'package:xml/xml.dart'; | ||
|
||
void main() { | ||
const String tizenManifestPath = "tizen/tizen-manifest.xml"; | ||
File tizenManifestFile = File(tizenManifestPath); | ||
if (!tizenManifestFile.existsSync()) { | ||
throw const FormatException("could not read tizen-manifext.xml!"); | ||
} | ||
XmlDocument? tizenManifest = | ||
XmlDocument.parse(tizenManifestFile.readAsStringSync()); | ||
XmlNode el = tizenManifest.root; | ||
|
||
XmlElement? uiApp = el.getElement("manifest")?.getElement("ui-application"); | ||
if (uiApp == null) { | ||
throw const FormatException("error when reading $tizenManifestPath"); | ||
} | ||
XmlElement? splashScreens = uiApp.getElement("splash-screens"); | ||
|
||
if (splashScreens != null) { | ||
splashScreens.children.clear(); | ||
File(tizenManifestPath) | ||
.writeAsStringSync(el.toXmlString(pretty: true, indent: ' ') + '\n'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# VS Code related | ||
.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# flutter_splash_tizen_example | ||
|
||
Demonstrates how to use the flutter_splash_tizen package. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
rules: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() => runApp(const MyApp()); | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({Key? key}) : super(key: key); | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Welcome to Flutter', | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Welcome to Flutter'), | ||
), | ||
body: const Center( | ||
child: Text('sample app for flutter splash tizen'), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: flutter_splash_tizen_example | ||
description: Demonstrates how to use the flutter_splash_tizen package. | ||
|
||
publish_to: 'none' | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
cupertino_icons: ^1.0.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort the dependencies alphabetically and remove extra newlines between the dependencies. |
||
|
||
dev_dependencies: | ||
flutter: | ||
sdk: flutter | ||
flutter_lints: ^1.0.0 | ||
flutter_splash_tizen: | ||
path: ../ | ||
|
||
flutter: | ||
uses-material-design: true | ||
|
||
flutter_splash_tizen: | ||
image: test.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flutter/ | ||
.vs/ | ||
*.user | ||
bin/ | ||
obj/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Tizen.Flutter.Embedding; | ||
|
||
namespace Runner | ||
{ | ||
public class App : FlutterApplication | ||
{ | ||
protected override void OnCreate() | ||
{ | ||
base.OnCreate(); | ||
|
||
GeneratedPluginRegistrant.RegisterPlugins(this); | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
var app = new App(); | ||
app.Run(args); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Tizen.NET.Sdk/1.1.6"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>tizen40</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugType>portable</DebugType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>none</DebugType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(FlutterEmbeddingPath)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<FlutterEphemeral Include="flutter\ephemeral\**\*" /> | ||
<TizenTpkUserIncludeFiles Include="@(FlutterEphemeral)"> | ||
<TizenTpkSubDir>%(RecursiveDir)</TizenTpkSubDir> | ||
</TizenTpkUserIncludeFiles> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.example.flutter_splash_tizen_example" version="1.0.0" api-version="4.0" xmlns="http://tizen.org/ns/packages"> | ||
<profile name="wearable"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this package support TV as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you confirm whether splash screen is supported on TV devices or not? If not, you should mention the fact in the package's README. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @swift-kim As far as I see - it does not run on TV. It runs on mobile and on Wearable fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this work for that?
|
||
<ui-application appid="com.example.flutter_splash_tizen_example" exec="Runner.dll" type="dotnet" multiple="false" nodisplay="false" taskmanage="true" api-version="4"> | ||
<label>flutter_splash_tizen_example</label> | ||
<icon>ic_launcher.png</icon> | ||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/> | ||
<splash-screens> | ||
<splash-screen src="test.png" type="img" indicator-display="false" orientation="portrait"/> | ||
</splash-screens> | ||
</ui-application> | ||
<feature name="http://tizen.org/feature/screen.size.all"/> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: flutter_splash_tizen | ||
description: Flutter-tizen package that allows to add custom splash-screen images into your apps. | ||
homepage: https://github.com/flutter-tizen/plugins | ||
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/flutter_splash_tizen | ||
version: 0.1.0 | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
flutter: ">=1.20.0" | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
xml: ^5.3.1 | ||
yaml: ^3.1.0 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
flutter_lints: ^1.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I understand correctly, current flow supports only adding a file once, then file added to yaml will be copied to tizen-manifest. What about changing a file mentioned in yaml during the development? Shouldn't we consider a scenario that a file is added to manifest file everytime when application is built which means that the file used in tizen manifest will be kept in sync with file mentioned in pubspec.yaml file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swift-kim could you please share your opinion regarding this comment? Should we set splash screen 'on demand' only, or rather do it automatically on every build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to sync automatically every build if possible. By the way, is there a way to run this package every build?
Should we add this feature to
flutter-tizen
tool?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc
can benull
. please check it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pkosko You can just follow flutter_native_splash's way. So manually running the pub run command every time the attributes are changed should just be enough.