|
- import 'dart:convert' as convert;
-
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.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 StatelessWidget {
- 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
- Widget build(BuildContext context) {
- return Container(
- height: 34,
- width: double.infinity,
- margin: EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4),
- decoration: BoxDecoration(
- color: HexColor.fromHex(_style?.bgColor ?? 'ffffff'),
- borderRadius: BorderRadius.circular(17),
- boxShadow: [
- BoxShadow(
- offset: Offset(2, 1), //x,y轴
- color: HexColor.fromHex(_style?.shadowColor ?? '767676')
- .withAlpha(70), //投影颜色
- blurRadius: 5 //投影距离
- )
- ]),
- child: Row(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(left: 10, right: 8),
- width: 20,
- height: 20,
- child: CachedNetworkImage(
- imageUrl: _style.icon,
- fit: BoxFit.contain,
- ),
- ),
- Expanded(
- child: Text(
- _style?.text ?? '',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.bold,
- color: HexColor.fromHex(_style?.textColor ?? '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(_style?.tipBtnBgColor ?? 'FF4242'),
- borderRadius: BorderRadius.circular(20)),
- child: Text(
- _style?.tipBtnText ?? '',
- style: TextStyle(
- fontSize: 12,
- color: HexColor.fromHex(_style?.tipBtnTextColor ?? 'ffffff'),
- ),
- ),
- ),
- onTap: () async {
- bool isAuth = await TaobaoAuth.isAuth();
- if (!isAuth) {
- TaobaoAuth.auth(context);
- } else {
- Logger.debug('您已经授权过了');
- }
- },
- ),
- ],
- ),
- );
- }
- }
|