import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import 'package:flutter/material.dart';

import 'login_page.dart';

// 用户未登录页面
class PersonalNoLoginPage extends StatefulWidget {
  const PersonalNoLoginPage({Key key}) : super(key: key);

  @override
  State<PersonalNoLoginPage> createState() => _PersonalNoLoginPageState();
}

class _PersonalNoLoginPageState extends State<PersonalNoLoginPage> {
  bool isDown = false;

  @override
  Widget build(BuildContext context) {
    timeDilation = 2.0;
    return Container(
      decoration: const BoxDecoration(
          image: DecorationImage(
              image: AssetImage("assets/images/bg1.png"), fit: BoxFit.cover)),
      child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: AppBar(
            backgroundColor: Colors.transparent,
            elevation: 0,
            centerTitle: true,
            title: const Text(
              '我的',
              style: TextStyle(color: Color(0xCFA77300)),
            ),
          ),
          body: Center(
            child: Stack(
              alignment: Alignment.center,
              children: [
                GestureDetector(
                  onTapDown: (TapDownDetails details) {
                    // 按下
                    setState(() {
                      isDown = true;
                    });
                  },
                  onTapCancel: () {
                    setState(() {
                      isDown = false;
                    });
                  },
                  onTap: () {
                    // 跳转登录页面
                    setState(() {
                      isDown = false;
                    });
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => const LoginPage()));
                  },
                  child: buildHero(),
                )
              ],
            ),
          )),
    );
  }

  Hero buildHero() {
    return Hero(
      tag: "logo",
      child: Material(
        color: Colors.transparent,
        child: buildContainer(),
      ),
    );
  }

  Container buildContainer() {
    return Container(
      alignment: Alignment.center,
      width: 96,
      height: 96,
      decoration: BoxDecoration(
        color: const Color(0xCFA77300),
        borderRadius: const BorderRadius.all(Radius.circular(50)),
        boxShadow: isDown
            ? [
                const BoxShadow(
                    offset: Offset(3, 4), color: Colors.black, blurRadius: 13)
              ]
            : null,
      ),
      child: const Text(
        "登录",
        style: TextStyle(
            color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
      ),
    );
  }
}
