Skip to content
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

[flutter_splash_tizen] Initial implementation #266

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0a3c42e
flutter tizen splash
JRazek Nov 5, 2021
0f4ad8a
img change
JRazek Nov 5, 2021
abc30f7
license, changelog
JRazek Nov 5, 2021
065e874
cleanup
JRazek Nov 5, 2021
1672142
minimal main, new line at the end of the file
JRazek Nov 5, 2021
5520b56
more cleanup
JRazek Nov 5, 2021
1ac69b2
example path fix
JRazek Nov 5, 2021
4620b31
main fixes
JRazek Nov 8, 2021
0ee9340
flag fixes
JRazek Nov 8, 2021
2f6303c
flag fixes
JRazek Nov 8, 2021
5917fce
flag fixes
JRazek Nov 8, 2021
0f73916
flag fixes
JRazek Nov 8, 2021
07f43b3
flag fixes
JRazek Nov 8, 2021
b3a41f7
suggested fixes and cleanups
JRazek Nov 9, 2021
0aa13d9
version
JRazek Nov 9, 2021
02e6a45
homepage, repository
JRazek Nov 9, 2021
898757b
tv info removal
JRazek Nov 9, 2021
0b43e66
tizen-manifest cleanup
JRazek Nov 9, 2021
0cd16b6
cleanup...
JRazek Nov 9, 2021
220a58d
remove bug fix
JRazek Nov 9, 2021
6301cb7
intergration test exclude
JRazek Nov 9, 2021
2ce30eb
intergration test exclude
JRazek Nov 9, 2021
e047ba7
integration, LICENSE
JRazek Nov 9, 2021
5eacc8a
new lines files
JRazek Nov 9, 2021
3944f4a
pretty XML
JRazek Nov 9, 2021
1c44a2a
example should be out of box working
JRazek Nov 9, 2021
6c75101
file_utils.dart not needed anymore. Removed redundant file read.
JRazek Nov 9, 2021
f41ffb1
remove not added fix
JRazek Nov 9, 2021
bbd104d
integration tests comments
JRazek Nov 10, 2021
e64f750
readme supported platforms
JRazek Nov 10, 2021
b3e8736
dart format
JRazek Nov 15, 2021
7794d00
analyze
JRazek Nov 15, 2021
ce20502
curly brackets and key widget constructor
JRazek Nov 16, 2021
3f1f7bb
formating, consts
JRazek Nov 17, 2021
73a9641
formating, consts
JRazek Nov 17, 2021
718934e
readme, labeler
JRazek Nov 17, 2021
9a3a0d3
not a package, formatting in pubspec
JRazek Nov 26, 2021
7973e7b
published
JRazek Nov 26, 2021
18278a6
readme wasnt added in the first push
JRazek Nov 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/flutter_splash_tizen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.dart_tool/

.packages
.pub/
.vscode/
.idea/
build/
10 changes: 10 additions & 0 deletions packages/flutter_splash_tizen/.metadata
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: plugin
3 changes: 3 additions & 0 deletions packages/flutter_splash_tizen/CHANGELOG.md
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
26 changes: 26 additions & 0 deletions packages/flutter_splash_tizen/LICENSE
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.
32 changes: 32 additions & 0 deletions packages/flutter_splash_tizen/README.md
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dependencies:
flutter_splash_tizen: ^0.0.1
dev_dependencies:
flutter_splash_tizen: ^0.1.0

```
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
```
4 changes: 4 additions & 0 deletions packages/flutter_splash_tizen/analysis_options.yaml
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
36 changes: 36 additions & 0 deletions packages/flutter_splash_tizen/bin/create.dart
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'];
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc can be null. please check it.

Copy link
Member

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.

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
}
28 changes: 28 additions & 0 deletions packages/flutter_splash_tizen/bin/file_utils.dart
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");
}
}
20 changes: 20 additions & 0 deletions packages/flutter_splash_tizen/bin/remove.dart
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'];
Copy link
Contributor

Choose a reason for hiding this comment

The 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());
}
44 changes: 44 additions & 0 deletions packages/flutter_splash_tizen/example/.gitignore
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
10 changes: 10 additions & 0 deletions packages/flutter_splash_tizen/example/.metadata
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
16 changes: 16 additions & 0 deletions packages/flutter_splash_tizen/example/README.md
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
29 changes: 29 additions & 0 deletions packages/flutter_splash_tizen/example/analysis_options.yaml
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
62 changes: 62 additions & 0 deletions packages/flutter_splash_tizen/example/lib/main.dart
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 =
Copy link
Contributor

Choose a reason for hiding this comment

The 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'),
),
),
);
}
}
28 changes: 28 additions & 0 deletions packages/flutter_splash_tizen/example/pubspec.yaml
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.
Copy link
Member

Choose a reason for hiding this comment

The 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this out to dev_dependencies.

path: ../

cupertino_icons: ^1.0.2
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no new line at the end of file

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Loading