-
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 4 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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: ffb2ecea5223acdd139a5039be2f9c796962833d | ||
channel: unknown | ||
|
||
project_type: plugin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* Initial release |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2013 The Flutter Authors. All rights reserved. | ||
Copyright (c) 2021, Samsung Electronics Co., Ltd. All rights reserved. | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,32 @@ | ||||||||||
# 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 dependencies section in your `pubspec.yaml` | ||||||||||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
```yaml | ||||||||||
dependencies: | ||||||||||
flutter_splash_tizen: ^0.0.1 | ||||||||||
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.
Suggested change
|
||||||||||
``` | ||||||||||
After that run | ||||||||||
``` | ||||||||||
flutter-tizen pub get | ||||||||||
``` | ||||||||||
in order to download all the dependencies.<br> | ||||||||||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
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 | ||||||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'file_utils.dart'; | ||
import 'package:xml/xml.dart'; | ||
|
||
void main() { | ||
var doc = loadYamlFileSync("pubspec.yaml")?['flutter_splash_tizen']; | ||
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. 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 commentThe 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 commentThe 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? 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.
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. @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. |
||
String color = doc["color"] ?? ""; //[TODO] generation of image in this color? | ||
String image = doc["image"] ?? ""; | ||
bool tizenFlag = doc["tizen"] ?? false; | ||
if (!tizenFlag) return; | ||
|
||
String tizenManifestPath = "tizen/tizen-manifest.xml"; | ||
|
||
XmlDocument tizenManifest = loadXMLFileSync(tizenManifestPath); | ||
XmlNode el = tizenManifest.root; | ||
|
||
XmlElement? uiApp = el.getElement("manifest")?.getElement("ui-application"); | ||
if (uiApp == null) { | ||
throw FormatException("error when reading $tizenManifestPath"); | ||
} | ||
XmlElement? splashScreens = uiApp.getElement("splash-screens"); | ||
if (splashScreens == null) { | ||
splashScreens = XmlElement(XmlName("splash-screen")); | ||
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", "true"); | ||
splashScreen.setAttribute("app-control-operation", "true"); | ||
splashScreen.setAttribute("orientation", "portrait"); | ||
splashScreens.children.add(splashScreen); | ||
|
||
writeToFileSync(tizenManifestPath, el.toXmlString()); | ||
WonyoungChoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'dart:io'; | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import 'package:yaml/yaml.dart'; | ||
import 'package:xml/xml.dart'; | ||
|
||
Map? loadYamlFileSync(String path) { | ||
File file = File(path); | ||
if (file.existsSync() == true) { | ||
WonyoungChoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return loadYaml(file.readAsStringSync()); | ||
} | ||
return null; | ||
} | ||
|
||
XmlDocument loadXMLFileSync(String path) { | ||
File file = File(path); | ||
if (file.existsSync() == true) { | ||
WonyoungChoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return XmlDocument.parse(file.readAsStringSync()); | ||
} | ||
throw FormatException("could not read $path"); | ||
WonyoungChoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
void writeToFileSync(String path, String data) { | ||
File file = File(path); | ||
if (file.existsSync() == true) { | ||
file.writeAsStringSync(data); | ||
} else { | ||
throw FormatException("could not write to $path"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'file_utils.dart'; | ||
import 'package:xml/xml.dart'; | ||
|
||
void main() { | ||
var doc = loadYamlFileSync("pubspec.yaml")?['flutter_splash_tizen']; | ||
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. unnecessary loading yaml file. |
||
String tizenManifestPath = "tizen/tizen-manifest.xml"; | ||
|
||
XmlDocument tizenManifest = loadXMLFileSync(tizenManifestPath); | ||
XmlNode el = tizenManifest.root; | ||
|
||
XmlElement? splashScreens = el | ||
.getElement("manifest") | ||
?.getElement("ui-application") | ||
?.getElement("splash-screens"); | ||
if (splashScreens == null) { | ||
throw FormatException("error when reading $tizenManifestPath"); | ||
} | ||
splashScreens.children.clear(); | ||
writeToFileSync(tizenManifestPath, el.toXmlString()); | ||
} |
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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: ffb2ecea5223acdd139a5039be2f9c796962833d | ||
channel: unknown | ||
|
||
project_type: app |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# flutter_splash_tizen_example | ||
|
||
Demonstrates how to use the flutter_splash_tizen plugin. | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
|
||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_splash_tizen/flutter_splash_tizen.dart'; | ||
|
||
void main() { | ||
runApp(const MyApp()); | ||
} | ||
|
||
class MyApp extends StatefulWidget { | ||
const MyApp({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<MyApp> createState() => _MyAppState(); | ||
} | ||
|
||
class _MyAppState extends State<MyApp> { | ||
String _platformVersion = 'Unknown'; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
initPlatformState(); | ||
} | ||
|
||
// Platform messages are asynchronous, so we initialize in an async method. | ||
Future<void> initPlatformState() async { | ||
String platformVersion; | ||
// Platform messages may fail, so we use a try/catch PlatformException. | ||
// We also handle the message potentially returning null. | ||
try { | ||
platformVersion = | ||
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. is the platformVersion really a part of splash plugin? or is it just leftover after some base for development? |
||
await FlutterNativeSplashTizen.platformVersion ?? 'Unknown platform version'; | ||
} on PlatformException { | ||
platformVersion = 'Failed to get platform version.'; | ||
} | ||
|
||
// If the widget was removed from the tree while the asynchronous platform | ||
// message was in flight, we want to discard the reply rather than calling | ||
// setState to update our non-existent appearance. | ||
if (!mounted) return; | ||
|
||
setState(() { | ||
_platformVersion = platformVersion; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Plugin example app'), | ||
), | ||
body: Center( | ||
child: Text('Running on: $_platformVersion\n'), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: flutter_splash_tizen_example | ||
description: Demonstrates how to use the flutter_splash_tizen plugin. | ||
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. Not a plugin. |
||
|
||
publish_to: 'none' | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
|
||
flutter_splash_tizen: | ||
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. Move this out to dev_dependencies. |
||
path: ../ | ||
|
||
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_test: | ||
sdk: flutter | ||
|
||
flutter_lints: ^1.0.0 | ||
|
||
flutter: | ||
uses-material-design: true | ||
|
||
flutter_splash_tizen: | ||
image: assets/test.png | ||
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. no new line at the end of file 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. one more comment - I assume that the example application is after adding a splash file with flutter-tizen pub run flutter_splash_tizen:create because related line is added to tizen-manifest.xml. But file assets/test.png does not exist, so removing splash and re-adding it again will probably fail - please check it. I am not also sure if packages/flutter_splash_tizen/example/tizen/shared/res/test.png file will work as a splash screen, as the tizen-manifest file uses: assets/test.png. |
Uh oh!
There was an error while loading. Please reload this page.