|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import 'dart:convert' as convert;
-
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import 'package:zhiying_base_widget/widgets/home/home_auth/models/home_auth_model.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- class HomeAuth extends StatefulWidget {
- final Map<String, dynamic> data;
- Map<String, dynamic> _json;
- HomeAuthModel _style;
-
- HomeAuth(this.data, {Key key}) : super(key: key) {
- String d = data['data'];
- _json = convert.jsonDecode(d);
- _style = HomeAuthModel.fromJson(Map<String, dynamic>.from(_json));
- }
-
- @override
- _HomeAuthState createState() => _HomeAuthState();
- }
-
- class _HomeAuthState extends State<HomeAuth> {
- UserInfoModel _user;
- bool _isAuth = false;
-
- @override
- void initState() {
- TaobaoAuth.isAuth().then((isAuth) {
- _isAuth = isAuth;
- setState(() {});
- });
-
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- _user = Provider.of<UserInfoNotifier>(context).userInfo;
- if (_isAuth) {
- // 授权过,不显示
- return Container();
- }
- return Container(
- height: 34,
- width: double.infinity,
- margin: EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4),
- decoration: BoxDecoration(
- color: HexColor.fromHex(widget._style?.taoaboTipBgColor ?? 'ffffff'),
- borderRadius: BorderRadius.circular(17),
- boxShadow: [
- BoxShadow(
- offset: Offset(2, 1), //x,y轴
- color: HexColor.fromHex(
- widget._style?.taoaboTipShadowColor ?? '767676')
- .withAlpha(70), //投影颜色
- blurRadius: 5 //投影距离
- )
- ]),
- child: Row(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(left: 10, right: 8),
- width: 20,
- height: 20,
- child: CachedNetworkImage(
- imageUrl: widget._style.taobaoAuthIcon,
- fit: BoxFit.contain,
- ),
- ),
- Expanded(
- child: Text(
- widget._style?.taoaboTipText ?? '',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.bold,
- color: HexColor.fromHex(
- widget._style?.taoaboTipTextColor ?? '333333'),
- ),
- ),
- ),
- GestureDetector(
- child: Container(
- padding: EdgeInsets.only(left: 12, right: 12, top: 3, bottom: 3),
- margin: EdgeInsets.only(left: 8, right: 8),
- decoration: BoxDecoration(
- color: HexColor.fromHex(
- widget._style?.taoaboTipBtnBgColor ?? 'FF4242'),
- borderRadius: BorderRadius.circular(20)),
- child: Text(
- widget._style?.taoaboTipBtnText ?? '',
- style: TextStyle(
- fontSize: 12,
- color: HexColor.fromHex(
- widget._style?.taoaboTipBtnTextColor ?? 'ffffff'),
- ),
- ),
- ),
- onTap: () async {
- if (_user?.token == null || _user.token == '') {
- print('need login...');
- RouterUtil.goLogin(context);
- return;
- }
- TaobaoAuth.auth(context);
- },
- ),
- ],
- ),
- );
- }
- }
|