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

@@ -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) {