import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../../models/app.dart';

class UserInfo extends StatelessWidget {
  AppController userInfo = AppController.t;

  UserInfo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print(userInfo.user().phone);

    return Container(
      margin: EdgeInsets.only(top: 20.0, bottom: 0.0),
      alignment: Alignment.center,
      height: 173.w,
      width: 345.w,
      decoration: BoxDecoration(
        image: const DecorationImage(
          image: AssetImage("images/mineBack.png"),
          fit: BoxFit.cover,
        ),
        borderRadius: BorderRadius.circular(10),
      ),
      child: Stack(
        fit: StackFit.expand,
        children: [
          Positioned(
            top: 0,
            right: 0,
            child: Container(
                alignment: Alignment.center,
                height: 24.w,
                width: 93.w,
                decoration: const BoxDecoration(
                  borderRadius: BorderRadius.only(
                      bottomLeft: Radius.circular(20),
                      topRight: Radius.circular(20)),
                  color: Color(0x30000000),
                ),
                child: GestureDetector(
                  child: const Text(
                    '修改个人信息',
                    style: TextStyle(color: Colors.white, fontSize: 14),
                  ),
                  onTap: () {
                    Get.toNamed('/userInfo');
                  },
                )),
          ),
          Row(
            children: [
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    width: 63.w,
                    height: 63.w,
                    decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      image: userInfo.user().avatar != null
                          ? DecorationImage(
                              image: NetworkImage(
                                  userInfo.user().avatar.toString()),
                              fit: BoxFit.cover,
                            )
                          : DecorationImage(
                              image: AssetImage('images/userMoren.png')),
                      border: Border.all(
                        color: Colors.white,
                        width: 2,
                      ),
                    ),
                    margin: EdgeInsets.fromLTRB(30, 0, 15, 0),
                  ),
                ],
              ),
              Container(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                      child: Text(
                        userInfo.user().nickName != null
                            ? userInfo.user().nickName.toString()
                            : '请修改个人信息!',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 17,
                        ),
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
                      child: Text(
                        userInfo.user().phone != null
                            ? userInfo.user().phone.toString()
                            : '请修改手机号!',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 17,
                        ),
                      ),
                    ),
                    // const Text(
                    //      '点击登陆',
                    //      style: TextStyle(
                    //        color: Colors.white,
                    //        fontSize: 17,
                    //      ),
                    //    ),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}