Navigation between screens without previous states showing.

This commit is contained in:
Ivan Murashov
2018-03-09 08:30:07 +03:00
parent 58e58671de
commit ff72bd5403
5 changed files with 53 additions and 28 deletions

View File

@@ -15,15 +15,15 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
compileSdkVersion 27
buildToolsVersion '27.0.3'
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
targetSdkVersion 21
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "com.dinect.checker"
}
@@ -38,7 +38,9 @@ android {
}
}
// Не смог разобраться, как коомбинировать flavors в flutter при запуске
flavorDimensions "checker"
// Не смог разобраться, как коомбинировать flavors в flutter при запуске
productFlavors {
@@ -185,7 +187,7 @@ flutter {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.okio:okio:1.13.0'
compile 'me.dm7.barcodescanner:zxing:1.9.8'

View File

@@ -15,15 +15,13 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="56dp"
android:layout_weight="0.5"
android:background="#с0000000" />
android:layout_weight="0.5"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="56dp"
android:layout_weight="0.5"
android:background="#с0000000" />
android:layout_weight="0.5" />
</LinearLayout>

View File

@@ -1,16 +1,18 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}

View File

@@ -39,10 +39,17 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
}
@override
Widget build(BuildContext ctx) {
void initState() {
setState(() {
requestAsyncData(user);
});
super.initState();
}
@override
Widget build(BuildContext ctx) {
return getMainWidget();
}
@@ -172,7 +179,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
child: new FlatButton(
child: new Text(title, style: new TextStyle(color: textColor)),
// FIXME: onPressed: () => startScanner(context, app, helper)),
onPressed: () => print('startScanner')),
onPressed: () => Navigator.of(context).pop(true)),
decoration: new BoxDecoration(
border: new Border.all(
color: Resources.getButtonColor(app), width: 1.0),

View File

@@ -28,13 +28,28 @@ class SplashScreen extends BaseScreen {
class _SplashScreenState extends BaseState<SplashScreen> {
_SplashScreenState(SqliteHelper helper, String app) : super(helper, app);
bool a = false;
@override
void initState() {
print('init state!');
new Future.delayed(const Duration(milliseconds: 1000), () {
showNextScreen();
a = true;
});
super.initState();
}
@override
Widget build(BuildContext ctx) {
new Future.delayed(const Duration(milliseconds: 1000), () {
showNextScreen();
});
return getScreenContent();
return a ? new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new ExactAssetImage(Resources.getSplash(nullq)),
fit: BoxFit.cover))) : getScreenContent();
}
@override
@@ -151,6 +166,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
// Канал ловит вызовы методов из "нативной" части приложения.
// Могут быть вызваны либо exit либо faq, либо purchase.
platform.setMethodCallHandler((MethodCall call) {
print(this.toString());
if (call.method == 'findUser') {
String cardPhone = call.arguments[0];
var userResponse = getUser(call.arguments[1], cardPhone, token);
@@ -190,18 +206,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
String card = call.arguments[1];
print('$userString, $card');
new Future.delayed(const Duration(milliseconds: 200), () {
var route = new MaterialPageRoute<bool>(
builder: (BuildContext context) => new PurchaseScreen(helper, app, userString, card),
fullscreenDialog: true);
Navigator.of(context).push(route).then((b) {
if (b) {
setState(() {
print('restart scanner!');
});
}
});
});
startScanner(token, userString, card);
}
});
@@ -221,6 +226,17 @@ class _SplashScreenState extends BaseState<SplashScreen> {
});
}
startScanner(String token, String userString, String card) {
new Future.delayed(const Duration(milliseconds: 200), () {
var route = new MaterialPageRoute<bool>(
builder: (BuildContext context) => new PurchaseScreen(helper, app, userString, card), fullscreenDialog: true);
Navigator.of(context).push(route).then((b) {
print('purchase closed: $b');
_initAndStartScanner(context, app, token, helper);
});
});
}
Future<Response> getUser(String type, String cardPhone, String token) {
try {
switch (type) {