2017-05-28 13:13:36 -04:00
|
|
|
/*
|
|
|
|
* fluro
|
|
|
|
* A Posse Production
|
|
|
|
* http://goposse.com
|
2018-01-17 00:12:32 -05:00
|
|
|
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
|
2017-05-28 13:13:36 -04:00
|
|
|
* See LICENSE for distribution and usage details.
|
|
|
|
*/
|
2018-01-17 00:12:32 -05:00
|
|
|
import 'dart:async';
|
2017-05-28 13:13:36 -04:00
|
|
|
|
|
|
|
import '../../config/application.dart';
|
|
|
|
import 'package:fluro/fluro.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2018-01-17 00:12:32 -05:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
class HomeComponent extends StatefulWidget {
|
|
|
|
|
|
|
|
@override
|
|
|
|
State createState() => new HomeComponentState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class HomeComponentState extends State<HomeComponent> {
|
|
|
|
|
|
|
|
var _deepLinkOpacity = 1.0;
|
2018-03-23 11:53:23 -04:00
|
|
|
final _deepLinkURL = "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21";
|
2018-01-17 00:12:32 -05:00
|
|
|
final _daysOfWeek = const [
|
2018-06-03 04:13:31 -04:00
|
|
|
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
|
2018-01-17 00:12:32 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
Widget deepLinkWidget(BuildContext context) {
|
|
|
|
return new Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
// copied widget
|
|
|
|
new AnimatedOpacity(
|
|
|
|
opacity: (_deepLinkOpacity - 1.0).abs(),
|
|
|
|
duration: new Duration(milliseconds: 400),
|
|
|
|
child: new Center(
|
|
|
|
child: new Text(
|
|
|
|
"Copied to clipboard!",
|
|
|
|
style: new TextStyle(
|
|
|
|
fontSize: 14.0,
|
|
|
|
color: const Color(0xFFFFFFFF),
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// button widget
|
|
|
|
new AnimatedOpacity(
|
|
|
|
opacity: _deepLinkOpacity,
|
|
|
|
duration: new Duration(milliseconds: 250),
|
|
|
|
child: new Center(
|
|
|
|
child: new FlatButton(
|
|
|
|
highlightColor: const Color(0x11FFFFFF),
|
|
|
|
splashColor: const Color(0x22FFFFFF),
|
|
|
|
onPressed: () {
|
|
|
|
if (_deepLinkOpacity == 1.0) {
|
|
|
|
new Timer(new Duration(milliseconds: 2000), () {
|
|
|
|
setState(() {
|
|
|
|
_deepLinkOpacity = 1.0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
setState(() {
|
|
|
|
_deepLinkOpacity = 0.0;
|
|
|
|
});
|
|
|
|
final clipboardData = new ClipboardData(text: _deepLinkURL);
|
|
|
|
Clipboard.setData(clipboardData);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: new Padding(
|
|
|
|
padding: new EdgeInsets.all(8.0),
|
|
|
|
child: new Text(
|
|
|
|
"Click here to copy a deep link url to the clipboard",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: new TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
color: const Color(0xCCFFFFFF),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2017-05-28 13:13:36 -04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var menuWidgets = <Widget>[
|
|
|
|
new Padding(
|
2018-01-17 00:12:32 -05:00
|
|
|
padding: new EdgeInsets.only(bottom: 35.0),
|
2017-05-28 13:13:36 -04:00
|
|
|
child: new Image(image: new AssetImage("assets/images/logo_fluro.png"), width: 200.0),
|
|
|
|
),
|
|
|
|
menuButton(context, "Native Animation", "native"),
|
|
|
|
menuButton(context, "Preset (In from Left)", "preset-from-left"),
|
|
|
|
menuButton(context, "Preset (Fade In)", "preset-fade"),
|
|
|
|
menuButton(context, "Custom Transition", "custom"),
|
2017-10-13 20:10:21 -04:00
|
|
|
menuButton(context, "Navigator Result", "pop-result"),
|
2018-01-17 00:12:32 -05:00
|
|
|
menuButton(context, "Function Call", "function-call"),
|
2017-05-28 13:13:36 -04:00
|
|
|
new Padding(
|
|
|
|
padding: new EdgeInsets.only(top: 65.0, left: 60.0, right: 60.0),
|
|
|
|
child: new Center(
|
|
|
|
child: new ConstrainedBox(
|
2018-01-17 00:12:32 -05:00
|
|
|
constraints: new BoxConstraints.tightFor(height: 60.0),
|
|
|
|
child: deepLinkWidget(context),
|
2017-05-28 13:13:36 -04:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
return new Material(
|
|
|
|
color: const Color(0xFF00D6F7),
|
|
|
|
child: new Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: menuWidgets,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// helpers
|
|
|
|
Widget menuButton(BuildContext context, String title, String key) {
|
|
|
|
return new Padding(
|
|
|
|
padding: new EdgeInsets.all(4.0),
|
|
|
|
child: new ConstrainedBox(
|
2018-01-17 00:12:32 -05:00
|
|
|
constraints: new BoxConstraints(minHeight: 42.0),
|
2017-05-28 13:13:36 -04:00
|
|
|
child: new FlatButton(
|
2018-01-17 00:12:32 -05:00
|
|
|
highlightColor: const Color(0x11FFFFFF),
|
|
|
|
splashColor: const Color(0x22FFFFFF),
|
2017-05-28 13:13:36 -04:00
|
|
|
child: new Text(
|
|
|
|
title,
|
|
|
|
style: new TextStyle(
|
2018-01-17 00:12:32 -05:00
|
|
|
color: const Color(0xAA001133),
|
2017-05-28 13:13:36 -04:00
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
tappedMenuButton(context, key);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// actions
|
|
|
|
void tappedMenuButton(BuildContext context, String key) {
|
|
|
|
String message = "";
|
|
|
|
String hexCode = "#FFFFFF";
|
2017-10-13 20:10:21 -04:00
|
|
|
String result;
|
2017-05-28 13:13:36 -04:00
|
|
|
TransitionType transitionType = TransitionType.native;
|
|
|
|
if (key != "custom" && key != "function-call") {
|
|
|
|
if (key == "native") {
|
|
|
|
hexCode = "#F76F00";
|
|
|
|
message = "This screen should have appeared using the default flutter animation for the current OS";
|
|
|
|
} else if (key == "preset-from-left") {
|
|
|
|
hexCode = "#5BF700";
|
|
|
|
message = "This screen should have appeared with a slide in from left transition";
|
|
|
|
transitionType = TransitionType.inFromLeft;
|
|
|
|
} else if (key == "preset-fade") {
|
|
|
|
hexCode = "#F700D2";
|
|
|
|
message = "This screen should have appeared with a fade in transition";
|
|
|
|
transitionType = TransitionType.fadeIn;
|
2017-10-13 20:10:21 -04:00
|
|
|
} else if (key == "pop-result") {
|
|
|
|
transitionType = TransitionType.native;
|
2018-01-17 00:12:32 -05:00
|
|
|
hexCode = "#7d41f4";
|
|
|
|
message = "When you close this screen you should see the current day of the week";
|
2018-06-03 04:13:31 -04:00
|
|
|
result = "Today is ${_daysOfWeek[new DateTime.now().weekday - 1]}!";
|
2017-05-28 13:13:36 -04:00
|
|
|
}
|
2017-10-13 20:10:21 -04:00
|
|
|
|
|
|
|
String route = "/demo?message=$message&color_hex=$hexCode";
|
|
|
|
|
|
|
|
if (result != null) {
|
|
|
|
route = "$route&result=$result";
|
|
|
|
}
|
|
|
|
|
|
|
|
Application.router.navigateTo(
|
|
|
|
context, route,
|
|
|
|
transition: transitionType).then((result) {
|
|
|
|
if (key == "pop-result") {
|
|
|
|
Application.router.navigateTo(context, "/demo/func?message=$result");
|
|
|
|
}
|
|
|
|
});
|
2017-05-28 13:13:36 -04:00
|
|
|
} else if (key == "custom") {
|
|
|
|
hexCode = "#DFF700";
|
|
|
|
message = "This screen should have appeared with a crazy custom transition";
|
|
|
|
var transition =
|
2017-10-13 20:10:21 -04:00
|
|
|
(BuildContext context, Animation<double> animation,
|
|
|
|
Animation<double> secondaryAnimation, Widget child) {
|
2017-05-28 13:13:36 -04:00
|
|
|
return new ScaleTransition(
|
|
|
|
scale: animation,
|
|
|
|
child: new RotationTransition(
|
|
|
|
turns: animation,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
Application.router.navigateTo(
|
|
|
|
context,
|
|
|
|
"/demo?message=$message&color_hex=$hexCode",
|
|
|
|
transition: TransitionType.custom,
|
|
|
|
transitionBuilder: transition,
|
|
|
|
transitionDuration: const Duration(milliseconds: 600),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
message = "You tapped the function button!";
|
|
|
|
Application.router.navigateTo(context, "/demo/func?message=$message");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|