diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7cf4774 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "moving_hole", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/assets/scrns/scrn1.jpg b/assets/scrns/scrn1.jpg new file mode 100644 index 0000000..03984cf Binary files /dev/null and b/assets/scrns/scrn1.jpg differ diff --git a/assets/scrns/scrn1.png b/assets/scrns/scrn1.png deleted file mode 100644 index c24d237..0000000 Binary files a/assets/scrns/scrn1.png and /dev/null differ diff --git a/assets/scrns/scrn2.jpg b/assets/scrns/scrn2.jpg new file mode 100644 index 0000000..7183890 Binary files /dev/null and b/assets/scrns/scrn2.jpg differ diff --git a/assets/scrns/scrn2.png b/assets/scrns/scrn2.png deleted file mode 100644 index 82001d9..0000000 Binary files a/assets/scrns/scrn2.png and /dev/null differ diff --git a/assets/scrns/scrn3.jpg b/assets/scrns/scrn3.jpg new file mode 100644 index 0000000..fecf483 Binary files /dev/null and b/assets/scrns/scrn3.jpg differ diff --git a/assets/scrns/scrn3.png b/assets/scrns/scrn3.png deleted file mode 100644 index 0417b10..0000000 Binary files a/assets/scrns/scrn3.png and /dev/null differ diff --git a/assets/scrns/scrn4.jpg b/assets/scrns/scrn4.jpg new file mode 100644 index 0000000..05bf3db Binary files /dev/null and b/assets/scrns/scrn4.jpg differ diff --git a/assets/scrns/scrn4.png b/assets/scrns/scrn4.png deleted file mode 100644 index dbbdc23..0000000 Binary files a/assets/scrns/scrn4.png and /dev/null differ diff --git a/lib/main.dart b/lib/main.dart index dee1dd9..c443d0a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; import 'package:moving_hole/animprovider.dart'; import 'package:provider/provider.dart'; @@ -18,14 +18,7 @@ class MyApp extends StatelessWidget { child: MaterialApp( theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), debugShowCheckedModeBanner: false, - home: Scaffold( - appBar: AppBar( - title: Text('Hello, again'), - ), - body: Center( - child: MyWidget(), - ), - ), + home: MyWidget(), )); } } @@ -38,41 +31,43 @@ class MyWidget extends StatefulWidget { class _MyWidgetState extends State { @override void initState() { - AnimProv ap = Provider.of(context, listen: false); - ap.foneScreen = 'assets/scrns/scrn1.png'; - // MyTimer(context, true, 10); + SchedulerBinding.instance.addPostFrameCallback((timeStamp) async { + AnimProv ap = Provider.of(context, listen: false); + ap.foneScreen = 'assets/scrns/scrn1.jpg'; + myTimer(context, true, 10); + }); super.initState(); } @override Widget build(BuildContext context) { - return Stack(fit: StackFit.expand, children: [ - Consumer( - builder: (context, ap, child) => Container( - height: 360, - width: 480, - child: Image( - image: AssetImage( - ap.foneScreen, - ), - // fit: BoxFit.contain, - ))), - // _getOverlay(), - // imageOverlay(), - // textOverlay(), - // Positioned( - // child: Consumer( - // builder: (context, ap, child) => - // RaisedButton(onPressed: () { - // ap.width = 300; - // ap.height = 150; - // ap.alignX = 0; - // ap.alignY = -0.5; - // }))) - ]); + return Scaffold( + body: Stack(fit: StackFit.expand, children: [ + Consumer( + builder: (context, ap, child) => Container( + height: 360, + width: 480, + child: Image.asset(ap.foneScreen ?? 'assets/scrns/scrn1.jpg' + + // fit: BoxFit.contain, + ))), + _getOverlay(), + imageOverlay(), + textOverlay(), + // Positioned( + // child: Consumer( + // builder: (context, ap, child) => + // RaisedButton(onPressed: () { + // ap.width = 300; + // ap.height = 150; + // ap.alignX = 0; + // ap.alignY = -0.5; + // }))) + ]), + ); } - void MyTimer(BuildContext context, bool start, int time) async { + void myTimer(BuildContext context, bool start, int time) async { AnimProv ap = Provider.of(context, listen: false); if (start) { int t = 0; @@ -84,7 +79,7 @@ class _MyWidgetState extends State { ap.alignX = 0.0; ap.alignY = 0; ap.picAsset = 'assets/scrns/sign.png'; - ap.foneScreen = 'assets/scrns/scrn1.png'; + ap.foneScreen = 'assets/scrns/scrn1.jpg'; ap.message = 'welcome to Magichess quick tutorial '; } if (t == 3) { @@ -93,7 +88,7 @@ class _MyWidgetState extends State { ap.alignX = 0.5; ap.alignY = -0.95; ap.picAsset = ''; - ap.foneScreen = 'assets/scrns/scrn2.png'; + ap.foneScreen = 'assets/scrns/scrn2.jpg'; ap.message = 'In Magichess you can play either online...'; } if (t == 6) { @@ -101,7 +96,7 @@ class _MyWidgetState extends State { ap.height = 170; ap.alignX = 0.5; ap.alignY = 0.14; - ap.foneScreen = 'assets/scrns/scrn3.png'; + ap.foneScreen = 'assets/scrns/scrn3.jpg'; ap.message = '... or offline!'; } @@ -110,7 +105,7 @@ class _MyWidgetState extends State { ap.height = 170; ap.alignX = 0.5; ap.alignY = 0.14; - ap.foneScreen = 'assets/scrns/scrn4.png'; + ap.foneScreen = 'assets/scrns/scrn4.jpg'; } await Future.delayed(Duration(seconds: 1)); t++; @@ -121,11 +116,7 @@ class _MyWidgetState extends State { Widget textOverlay() { return Consumer( builder: (context, ap, child) => Container( - child: Text(ap.message, - style: TextStyle( - color: Colors.white, - fontSize: 20, - fontWeight: FontWeight.bold)), + child: Text(ap.message, style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold)), alignment: Alignment.bottomCenter, )); } @@ -133,7 +124,7 @@ class _MyWidgetState extends State { Widget imageOverlay() { return Consumer( builder: (context, ap, child) => Container( - child: Image.asset(ap.picAsset, fit: BoxFit.contain), + child: ap.picAsset.isNotEmpty ? Image.asset(ap.picAsset) : Container(), width: 400, height: 400, alignment: Alignment.center, @@ -152,8 +143,7 @@ class _MyWidgetState extends State { child: Consumer( builder: (context, ap, child) => AnimatedAlign( duration: Duration(milliseconds: 1000), - alignment: - Alignment(ap.alignX, ap.alignY), // need to animate this + alignment: Alignment(ap.alignX, ap.alignY), // need to animate this child: AnimatedContainer( duration: Duration(milliseconds: 1000), margin: const EdgeInsets.only(right: 4, bottom: 4),