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

chore: Move in flame_splash_screen to monorepo #2800

Merged
merged 11 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions packages/flame_splash_screen/.metadata
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: 68841bdab9840b5d72499f9cdd80b69894046ed0
channel: master

project_type: package
8 changes: 8 additions & 0 deletions packages/flame_splash_screen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 0.1.0

- Added non nullability support
- Update to new logo

## 0.0.1

- Initial implementation with theme, controller and of course, the splash screen widget.
22 changes: 22 additions & 0 deletions packages/flame_splash_screen/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2021 Blue Fire

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

147 changes: 147 additions & 0 deletions packages/flame_splash_screen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<!-- markdownlint-disable MD013 -->
<p align="center">
<a href="https://flame-engine.org">
<img alt="flame" width="200px" src="https://user-images.githubusercontent.com/6718144/101553774-3bc7b000-39ad-11eb-8a6a-de2daa31bd64.png">
</a>
</p>

Style your [Flame](https://github.com/flame-engine/flame) game with a beautiful splash screen.

This package includes a `FlameSplashScreen` widget.

<p align="center">
<a title="Pub" href="https://pub.dev/packages/flame_splash_screen" ><img src="https://img.shields.io/pub/v/flame_splash_screen.svg?style=popout" /></a>
<a title="Test" href="https://github.com/flame-engine/flame/actions?query=workflow%3Acicd+branch%3Amain"><img src="https://github.com/flame-engine/flame/workflows/cicd/badge.svg?branch=main&event=push"/></a>
<a title="Discord" href="https://discord.gg/pxrBmy4"><img src="https://img.shields.io/discord/509714518008528896.svg"/></a>
<a title="Melos" href="https://github.com/invertase/melos"><img src="https://img.shields.io/badge/maintained%20with-melos-f700ff.svg"/></a>
</p>

<p align="center">
<img src="demo.gif" />
</p>

<!-- markdownlint-disable-next-line MD002 -->
## Install

Add `flame_splash_screen` as a dependency to
[your pubspec.yaml file](https://pub.dev/packages/flame_splash_screen/install).

Import the widget:

```dart
import 'package:flame_splash_screen/flame_splash_screen.dart';
```


## Usage

The splash screen is a widget that can be used to show the splash screen.


### Simple usage

There is just two required params:

- `onFinish`, a callback that is executed when all animations from the splash screen is over.
- `theme`, than can be either `FlameSplashTheme.dark` or `FlameSplashTheme.white`.

```dart
FlameSplashScreen(
theme: FlameSplashTheme.dark,
onFinish: (BuildContext context) => Navigator.pushNamed(context, '/your-game-initial-screen'),
)
```


#### Adding your own content

You can pass your own logo (or/and anything else) to be shown before or after the Flame's logo.

```dart
FlameSplashScreen(
theme: FlameSplashTheme.dark,
showBefore: (BuildContext context) {
return Text("To be shown before flame animation");
},
onFinish: (BuildContext context) => Navigator.pushNamed(context, '/your-game-initial-screen'),
)
```

```dart
FlameSplashScreen(
theme: FlameSplashTheme.dark,
showAfter: (BuildContext context) {
return Text("To be shown after flame animation");
},
onFinish: (BuildContext context) => Navigator.pushNamed(context, '/your-game-initial-screen'),
)
```

Remember: you can also specify both `showBefore` and `showAfter` at the same time.


#### Changing theme

By default the splash screen has a dark background. You can change it by specifying the `white`
theme.

Aside from `FlameSplashTheme.dark`, you can pass `FlameSplashTheme.white` for a white background.

```dart
FlameSplashScreen(
theme: FlameSplashTheme.white,
onFinish: (BuildContext context) => Navigator.pushNamed(context, '/your-game-initial-screen'),
)
```

You can create your own theme passing a custom logo builder (changing flames logo for another one)
and a background decoration


### Usage with controller

Controller enables `FlameSplashScreen` to be customized regarding animation duration and when it
starts.

There is duration params and `autoStart` (which is true by default).

To use it, make the controller lives as much as a widget state:

```dart
class SplashScreenGameState extends State<SplashScreenGame> {
FlameSplashController controller;
@override
void initState() {
super.initState();
controller = FlameSplashController(
fadeInDuration: Duration(seconds: 1),
fadeOutDuration: Duration(milliseconds: 250),
waitDuration: Duration(seconds: 2),
autoStart: false,
);
}

@override
void dispose() {
controller.dispose(); // dispose it when necessary
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: FlameSplashScreen(
showBefore: (BuildContext context) {
return Text("Before the logo");
},
showAfter: (BuildContext context) {
return Text("After the logo");
},
theme: FlameSplashTheme.white,
onFinish: (context) => Navigator.pushNamed(context, '/the-game-initial-screen'),
controller: controller,
),
);
}
}
```
1 change: 1 addition & 0 deletions packages/flame_splash_screen/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flame_lint/analysis_options.yaml
Binary file added packages/flame_splash_screen/assets/layer1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/flame_splash_screen/assets/layer2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/flame_splash_screen/assets/layer3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/flame_splash_screen/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions packages/flame_splash_screen/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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: "12fccda598477eddd19f93040a1dba24f915b9be"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 12fccda598477eddd19f93040a1dba24f915b9be
base_revision: 12fccda598477eddd19f93040a1dba24f915b9be
- platform: linux
create_revision: 12fccda598477eddd19f93040a1dba24f915b9be
base_revision: 12fccda598477eddd19f93040a1dba24f915b9be

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions packages/flame_splash_screen/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Splash screen example app

Example of usage
1 change: 1 addition & 0 deletions packages/flame_splash_screen/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flame_lint/analysis_options.yaml
68 changes: 68 additions & 0 deletions packages/flame_splash_screen/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:flame_splash_screen/flame_splash_screen.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: const SplashScreenGame(),
theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
);
}
}

class OtherScreen extends StatelessWidget {
const OtherScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('Come again'),
onPressed: () {
Navigator.push<void>(
context,
MaterialPageRoute(builder: (context) => const SplashScreenGame()),
);
},
),
),
);
}
}

class SplashScreenGame extends StatefulWidget {
const SplashScreenGame({super.key});

@override
SplashScreenGameState createState() => SplashScreenGameState();
}

class SplashScreenGameState extends State<SplashScreenGame> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: FlameSplashScreen(
showBefore: (BuildContext context) {
return const Text('Before logo');
},
showAfter: (BuildContext context) {
return const Text('After logo');
},
theme: FlameSplashTheme.dark,
onFinish: (context) => Navigator.pushReplacement<void, void>(
context,
MaterialPageRoute(builder: (context) => const OtherScreen()),
),
),
);
}
}
20 changes: 20 additions & 0 deletions packages/flame_splash_screen/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: flame_splash_screen_example
description: Flame Splash Screen Example
publish_to: none

version: 1.0.0+1

environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.13.0"

dependencies:
flame_splash_screen: ^0.1.0
flutter:
sdk: flutter

dev_dependencies:
flame_lint: ^1.1.1
flutter_test:
sdk: flutter

3 changes: 3 additions & 0 deletions packages/flame_splash_screen/lib/flame_splash_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'src/controller.dart';
export 'src/splash.dart';
export 'src/theme.dart';
Loading