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 'dart:math';
import 'package:flutter/material.dart'; 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); final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
@@ -10,39 +13,131 @@ void main() {
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MultiProvider(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), providers: [ChangeNotifierProvider(create: (_) => AnimProv())],
debugShowCheckedModeBanner: false, child: MaterialApp(
home: Scaffold( theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
body: Center( debugShowCheckedModeBanner: false,
child: MyWidget(), home: Scaffold(
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Transform.rotate(
angle: 0,
child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('Hello, again'), title: Text('Hello, again'),
), ),
body: Stack( body: Center(
// fit: StackFit.expand, child: MyWidget(),
children: [ ),
Container( ),
height: 800, ));
width: 800, }
child: Image.network( }
'https://wallpaperplay.com/walls/full/e/5/3/13586.jpg',
fit: BoxFit.cover, class MyWidget extends StatefulWidget {
)), @override
_getOverlay() _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() { Widget _getOverlay() {
@@ -54,15 +149,20 @@ class MyWidget extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.transparent, color: Colors.transparent,
), ),
child: Align( child: Consumer<AnimProv>(
alignment: Alignment(-0.3, -0.8), // need to animate this builder: (context, ap, child) => AnimatedAlign(
child: Container( duration: Duration(milliseconds: 1000),
margin: const EdgeInsets.only(right: 4, bottom: 4), alignment:
height: 80, // need to animate this Alignment(ap.alignX, ap.alignY), // need to animate this
width: 160, // need to animate this child: AnimatedContainer(
decoration: BoxDecoration( duration: Duration(milliseconds: 1000),
color: Colors.black, margin: const EdgeInsets.only(right: 4, bottom: 4),
borderRadius: BorderRadius.circular(40), 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" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0-nullsafety.3"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
path: path:
dependency: transitive dependency: transitive
description: description:
@@ -88,6 +95,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" 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: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@@ -151,3 +165,4 @@ packages:
version: "2.1.0-nullsafety.3" version: "2.1.0-nullsafety.3"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" 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. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.0
provider:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@@ -45,9 +46,13 @@ flutter:
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: assets:
# - images/a_dot_burr.jpeg - assets/scrns/
# - images/a_dot_ham.jpeg # - 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 # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware. # https://flutter.dev/assets-and-images/#resolution-aware.