| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- import 'package:fast/constants.dart';
- import 'package:fast/model/model.dart';
- import 'package:fast/utils/api.dart';
- import 'package:fast/utils/global.dart';
- import 'package:fast/utils/http_utils.dart';
- import 'package:fast/utils/size_fit.dart';
- import 'package:fast/view/calendar.dart';
- import 'package:fast/view/component/header.dart';
- import 'package:fast/view/recharge.dart';
- import 'package:fast/view/setting.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'dart:convert' as convert;
- import 'package:shared_preferences/shared_preferences.dart';
- import 'balance_history.dart';
- class MePage extends StatefulWidget {
- const MePage({Key? key}) : super(key: key);
- @override
- State<MePage> createState() => _MePageState();
- }
- class _MePageState extends State<MePage> with RouteAware {
- late UserBean userBean;
- @override
- void initState() {
- userBean = Global().userBean!;
- super.initState();
- }
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- Global().routeObserver!.subscribe(this, ModalRoute.of(context)!);
- }
- @override
- void didPopNext() {
- getUserInfo();
- super.didPopNext();
- }
- Future getUserInfo() async {
- if (mounted) {
- final prefs = await SharedPreferences.getInstance();
- String? temp = prefs.getString('userInfo');
- if (temp != null) {
- Map<String, dynamic> data = convert.jsonDecode(temp);
- UserBean bean = UserBean.fromJson(data);
- setState(() {
- userBean = bean;
- });
- }
- }
- }
- @override
- Widget build(BuildContext context) {
- SizeFit.initialize(context);
- var size = MediaQuery.of(context).size;
- bool isNight = false;
- DateTime now = DateTime.now();
- if (now.hour >= 18 || now.hour < 6) {
- isNight = true;
- }
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: Column(
- children: [
- Stack(
- children: [
- Header(
- isIndexPage: false,
- ),
- Container(
- padding: EdgeInsets.fromLTRB(24.px, size.height<=667?50.px:68.px, 24.px, 0),
- height: size.height<=667?162.px:180.px,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ClipOval(
- child: Image.network(
- userBean.avatar!,
- width: 64.px,
- height: 64.px,
- fit: BoxFit.cover,
- ),
- ),
- SizedBox(
- width: 10.px,
- ),
- Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- userBean.nickname!,
- textAlign: TextAlign.left,
- style: TextStyle(
- color: isNight
- ? Colors.white
- : const Color(0xFF000D1F),
- fontSize: 20.px,
- fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 6.px,
- ),
- Row(
- children: [
- Container(
- height: 24.px,
- padding: EdgeInsets.only(
- left: 9.px, right: 9.px),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(12.px)),
- border: Border.all(
- color: const Color(0x80FFFFFF),
- width: 1.px),
- color: const Color(0x33000D1F)),
- child: Row(
- children: [
- Text(
- '逆龄石',
- style: TextStyle(
- color: Colors.white,
- fontSize: 12.px),
- ),
- SizedBox(
- width: 2.px,
- ),
- Image.asset(
- 'assets/images/stone.png',
- width: 16.px,
- height: 16.px,
- ),
- SizedBox(
- width: 2.px,
- ),
- Text(
- '×${userBean.rjvBalance}',
- style: TextStyle(
- color: kThemeColor,
- fontSize: 14.px,
- fontFamily: 'Exo2',
- fontWeight: FontWeight.w600),
- ),
- Container(
- width: 1.px,
- height: 14.px,
- margin: EdgeInsets.only(left: 6.px,right: 6.px),
- color: const Color(0x80FFFFFF),
- ),
- GestureDetector(onTap: (){
- Get.to(() => const Recharge());
- },
- child: Text('去充值',style: TextStyle(color: Colors.white,fontSize: 10.px),),
- )
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- Get.to(() => const Setting());
- },
- child: Container(
- width: 24.px,
- height: 24.px,
- margin: EdgeInsets.only(left: 10.px),
- alignment: Alignment.center,
- child: Image.asset(
- 'assets/images/setting.png',
- width: 16.px,
- height: 16.px,
- ),
- decoration: BoxDecoration(
- color: const Color(0x33000D1F),
- borderRadius: BorderRadius.all(
- Radius.circular(12.px)),
- border: Border.all(
- color: const Color(0x80FFFFFF),
- width: 1.px)),
- ),
- )
- ],
- )
- ])
- ],
- ),
- )
- ],
- ),
- const Expanded(child: Calendar())
- ],
- ),
- );
- }
- }
|