| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import '../styles/colors.dart';
- import 'dart:math';
- Future showUserGuide(BuildContext context) {
- return Navigator.of(context).push(
- PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return UserGuide();
- },
- ),
- );
- }
- class UserGuide extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return UserGuideState();
- }
- }
- class UserGuideState extends State<UserGuide> {
- final pageController = PageController(initialPage: 0);
- @override
- Widget build(BuildContext context) {
- return WillPopScope(
- onWillPop: () {
- return Future.value(true);
- },
- child: Scaffold(
- backgroundColor: Color(0xb3000000),
- body: Stack(
- children: <Widget>[
- PageView(
- controller: pageController,
- children: <Widget>[
- // _page(context, children: [
- // Align(
- // alignment: Alignment.topLeft,
- // child: Container(
- // margin: EdgeInsets.only(top: 23, left: 40),
- // child: Image.asset('images/zhezhao_01.png'),
- // ),
- // ),
- // Align(
- // alignment: Alignment.topCenter,
- // child: Container(
- // margin: EdgeInsets.only(top: 177),
- // child: Text(
- // '01、此处是您拥有金币的数量',
- // style: TextStyle(color: Colors.white, fontSize: 15),
- // ),
- // ),
- // )
- // ]),
- _page(context, children: [
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- margin: EdgeInsets.only(top: 128),
- child: Image.asset('images/zhezhao_02.png'),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- margin: EdgeInsets.only(top: 159, left: 106),
- child: Text(
- '01、带此标示的为VIP赛事\n 相对于普通赛事奖励更为丰厚',
- style: TextStyle(color: Colors.white, fontSize: 15),
- ),
- ),
- )
- ]),
- _page(context, children: [
- Align(
- alignment: Alignment.topRight,
- child: Container(
- margin: EdgeInsets.only(top: 126),
- child: Image.asset('images/zhezhao_03.png'),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- margin: EdgeInsets.only(top: 175, left: 30),
- child: Text(
- '02、这是您在此赛事中的排名情况',
- style: TextStyle(color: Colors.white, fontSize: 15),
- ),
- ),
- )
- ]),
- _page(context, isLast: true, children: [
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 150 / 345 + 133),
- child: Image.asset('images/zhezhao_04.png'),
- ),
- ),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- margin: EdgeInsets.only(
- top: (MediaQuery.of(context).size.width - 30) * 150 / 345 + 285,
- ),
- child: Text(
- '03、点击进入,开始您的比赛吧',
- style: TextStyle(color: Colors.white, fontSize: 15),
- ),
- ),
- )
- ]),
- ],
- ),
- ],
- ),
- ),
- );
- }
- Widget _page(BuildContext context, {@required List<Widget> children, bool isLast = false}) {
- List<Widget> list = [
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- margin: EdgeInsets.only(bottom: 92),
- child: SizedBox(
- width: 220,
- height: 36,
- child: OutlineButton(
- borderSide: BorderSide(color: PRIMARY_COLOR),
- highlightColor: Colors.transparent,
- color: PRIMARY_COLOR,
- onPressed: () {
- if (isLast) {
- Navigator.of(context).pop();
- return;
- }
- pageController.nextPage(duration: Duration(milliseconds: 300), curve: Curves.linearToEaseOut);
- },
- child: Text(
- isLast ? '知道了' : '下一步',
- style: TextStyle(color: PRIMARY_COLOR, fontSize: 14),
- ),
- ),
- ),
- ),
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- margin: EdgeInsets.only(bottom: 50),
- child: CupertinoButton(
- padding: EdgeInsets.all(0),
- child: Text(
- '关闭',
- style: TextStyle(color: Color(0xFF4F5C87), fontSize: 14),
- ),
- onPressed: () {
- Navigator.of(context).pop();
- }),
- ),
- )
- ];
- for (Widget widget in children) {
- list.add(widget);
- }
- return Stack(
- children: list,
- );
- }
- }
- Future showUserGuide1(BuildContext context) {
- return Navigator.of(context).push(
- PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return Material(
- color: Colors.black87,
- child: GestureDetector(
- child: Container(
- child: Stack(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 133, right: 0),
- child: Align(
- alignment: Alignment.topRight,
- child: Image.asset('images/zhezhao_01.png'),
- ),
- ),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- width: 200,
- margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 90),
- child: Text(
- '成为VIP后可以参与专属赛事赢得精美大奖',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
- ),
- ),
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.of(context).pop();
- },
- ),
- );
- },
- ),
- );
- }
- Future showUserGuide2(BuildContext context) {
- return Navigator.of(context).push(
- PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return Material(
- color: Colors.black87,
- child: GestureDetector(
- child: Container(
- child: Stack(
- children: <Widget>[
- Positioned(
- top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 0,
- right: 6,
- left: 6,
- child: Container(
- child: Image.asset(
- 'images/zhezhao_02.png',
- fit: BoxFit.fitWidth,
- ),
- ),
- ),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- width: 200,
- margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345, right: 60),
- child: Text(
- '选择一个等待中的房间进入即可参与本次比赛',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
- ),
- ),
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.of(context).pop();
- },
- ),
- );
- },
- ),
- );
- }
- Future showUserGuide3(BuildContext context) {
- return Navigator.of(context).push(
- PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return Material(
- color: Colors.black87,
- child: GestureDetector(
- child: Container(
- child: Stack(
- children: <Widget>[
- Positioned(
- bottom: 5,
- right: 6,
- left: 6,
- child: Container(
- child: Image.asset(
- 'images/zhezhao_03.png',
- fit: BoxFit.fitWidth,
- ),
- ),
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- width: 200,
- margin: EdgeInsets.only(bottom: 122, right: 60),
- child: Text(
- '加入房间后等待倒计时结束\n或者房主手动开启比赛',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
- ),
- ),
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.of(context).pop();
- },
- ),
- );
- },
- ),
- );
- }
|