some updates requiring attention

This commit is contained in:
mem3Dealer
2021-01-15 16:09:30 +03:00
parent 4b8c6fa586
commit cae80a4ab8
3 changed files with 162 additions and 42 deletions

View File

@@ -1,5 +1,8 @@
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:moving_hole/animprovider.dart';
import 'package:provider/provider.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
@@ -10,39 +13,131 @@ void main() {
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Transform.rotate(
angle: 0,
child: Scaffold(
return MultiProvider(
providers: [ChangeNotifierProvider(create: (_) => AnimProv())],
child: MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Hello, again'),
),
body: Stack(
// fit: StackFit.expand,
children: [
Container(
height: 800,
width: 800,
child: Image.network(
'https://wallpaperplay.com/walls/full/e/5/3/13586.jpg',
fit: BoxFit.cover,
)),
_getOverlay()
])));
body: Center(
child: MyWidget(),
),
),
));
}
}
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
void initState() {
AnimProv ap = Provider.of<AnimProv>(context, listen: false);
ap.foneScreen = 'assets/scrns/scrn1.png';
// MyTimer(context, true, 10);
super.initState();
}
@override
Widget build(BuildContext context) {
return Stack(fit: StackFit.expand, children: [
Consumer<AnimProv>(
builder: (context, ap, child) => Container(
height: 360,
width: 480,
child: Image(
image: AssetImage(
ap.foneScreen,
),
// fit: BoxFit.contain,
))),
// _getOverlay(),
// imageOverlay(),
// textOverlay(),
// Positioned(
// child: Consumer<AnimProv>(
// 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 {
AnimProv ap = Provider.of<AnimProv>(context, listen: false);
if (start) {
int t = 0;
while (t < time) {
if (t == 0) {
ap.width = 0;
ap.height = 0;
ap.alignX = 0.0;
ap.alignY = 0;
ap.picAsset = 'assets/scrns/sign.png';
ap.foneScreen = 'assets/scrns/scrn1.png';
ap.message = 'welcome to Magichess quick tutorial ';
}
if (t == 3) {
ap.width = 345;
ap.height = 170;
ap.alignX = 0.5;
ap.alignY = -0.95;
ap.picAsset = '';
ap.foneScreen = 'assets/scrns/scrn2.png';
ap.message = 'In Magichess you can play either online...';
}
if (t == 6) {
ap.width = 345;
ap.height = 170;
ap.alignX = 0.5;
ap.alignY = 0.14;
ap.foneScreen = 'assets/scrns/scrn3.png';
ap.message = '... or offline!';
}
if (t == 9) {
ap.width = 345;
ap.height = 170;
ap.alignX = 0.5;
ap.alignY = 0.14;
ap.foneScreen = 'assets/scrns/scrn4.png';
}
await Future.delayed(Duration(seconds: 1));
t++;
}
}
}
Widget textOverlay() {
return Consumer<AnimProv>(
builder: (context, ap, child) => Container(
child: Text(ap.message,
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold)),
alignment: Alignment.bottomCenter,
));
}
Widget imageOverlay() {
return Consumer<AnimProv>(
builder: (context, ap, child) => Container(
child: Image.asset(ap.picAsset, fit: BoxFit.contain),
width: 400,
height: 400,
alignment: Alignment.center,
));
}
Widget _getOverlay() {
@@ -54,15 +149,20 @@ class MyWidget extends StatelessWidget {
decoration: BoxDecoration(
color: Colors.transparent,
),
child: Align(
alignment: Alignment(-0.3, -0.8), // need to animate this
child: Container(
margin: const EdgeInsets.only(right: 4, bottom: 4),
height: 80, // need to animate this
width: 160, // need to animate this
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(40),
child: Consumer<AnimProv>(
builder: (context, ap, child) => AnimatedAlign(
duration: Duration(milliseconds: 1000),
alignment:
Alignment(ap.alignX, ap.alignY), // need to animate this
child: AnimatedContainer(
duration: Duration(milliseconds: 1000),
margin: const EdgeInsets.only(right: 4, bottom: 4),
height: ap.height, // need to animate this
width: ap.width, // need to animate this
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
),
),
),

View File

@@ -81,6 +81,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
path:
dependency: transitive
description:
@@ -88,6 +95,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
provider:
dependency: "direct main"
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2+4"
sky_engine:
dependency: transitive
description: flutter
@@ -151,3 +165,4 @@ packages:
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"

View File

@@ -28,6 +28,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
provider:
dev_dependencies:
flutter_test:
@@ -45,9 +46,13 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/scrns/
# - assets/scrns/scrn1.png
# - assets/scrns/scrn2.png
# - assets/scrns/scrn3.png
# - assets/scrns/scrn4.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.