Skip to content

Commit

Permalink
feat: add splash screen on example app
Browse files Browse the repository at this point in the history
Add splash screen on example app.

Signed-off-by: Alex Manoel Ferreira Silva <alex@legytma.com.br>
  • Loading branch information
Alex Manoel Ferreira Silva committed Jul 22, 2020
1 parent 5fc367d commit 3d0d35a
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 3 deletions.
Binary file added assets/LegytmaSolucoesInteligentes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Expand Up @@ -6,7 +6,6 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="schema_widget_sample"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -16,6 +15,18 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specify that the launch screen should continue being displayed -->
<!-- until Flutter renders its first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />

<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Expand Up @@ -4,9 +4,9 @@
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</item>
</layer-list>
12 changes: 12 additions & 0 deletions example/android/app/src/main/res/drawable/normal_background.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item>
</layer-list>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Expand Up @@ -5,4 +5,7 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/normal_background</item>
</style>
</resources>
108 changes: 108 additions & 0 deletions lib/widget/schema_widget_splash_screen.dart
@@ -0,0 +1,108 @@
// Copyright (c) 2020 Legytma Soluções Inteligentes (https://legytma.com.br).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:flutter/material.dart';
import 'package:schema_widget/json_schema_resolver.dart';

import '../schema_widget.dart';

class SchemaWidgetSplashScreen extends StatefulWidget {
final Widget child;

const SchemaWidgetSplashScreen({Key key, this.child}) : super(key: key);

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

class _SchemaWidgetSplashScreenState extends State<SchemaWidgetSplashScreen> {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image(
image: AssetImage(
"assets/LegytmaSolucoesInteligentes.png",
package: "schema_widget",
),
),
StreamBuilder<FactoryStatistics>(
stream: SchemaWidget.factoryStream,
builder: (buildContext, snapshot) {
if (snapshot.hasData) {
var factoryStatistics = snapshot.data;

return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
factoryStatistics.toString(),
style: TextStyle(
fontSize: 7,
color: Colors.black54,
),
),
LinearProgressIndicator(
value: factoryStatistics.value,
),
],
);
}

return CircularProgressIndicator();
},
),
StreamBuilder<JsonSchemaResolverStatistics>(
stream: SchemaWidget.jsonSchemaResolverStream,
builder: (buildContext, snapshot) {
if (snapshot.hasData) {
var jsonSchemaResolverStatistics = snapshot.data;

return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
jsonSchemaResolverStatistics.toString(),
style: TextStyle(
fontSize: 7,
color: Colors.black54,
),
),
LinearProgressIndicator(
value: jsonSchemaResolverStatistics.requestValue,
),
],
);
}

return CircularProgressIndicator();
},
),
widget.child ??
StreamBuilder<FactoryStatistics>(
stream: SchemaWidget.factoryStream,
builder: (buildContext, snapshot) {
if (snapshot.hasError) {
return Text('${snapshot.error}');
}

return Container();
},
),
],
);
}
}

0 comments on commit 3d0d35a

Please sign in to comment.