diff --git a/lib/util/bubble_tabIndicator/bubble_tabIndicator.dart b/lib/util/bubble_tabIndicator/bubble_tabIndicator.dart new file mode 100644 index 0000000..69e27ad --- /dev/null +++ b/lib/util/bubble_tabIndicator/bubble_tabIndicator.dart @@ -0,0 +1,113 @@ +library flutter_bubble_tab_indicator; + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +/// Used with [TabBar.indicator] to draw a bubble on the +/// selected tab. +/// +/// The [indicatorHeight] defines the bubble height. +/// The [indicatorColor] defines the bubble color. +/// The [indicatorRadius] defines the bubble corner radius. +/// The [tabBarIndicatorSize] specifies the type of TabBarIndicatorSize i.e label or tab. +/// /// The selected tab bubble is inset from the tab's boundary by [insets] when [tabBarIndicatorSize] is tab. +/// The selected tab bubble is applied padding by [padding] when [tabBarIndicatorSize] is label. +/// tabvbar的背景装饰器 +class BubbleTabIndicator extends Decoration { + final double indicatorHeight; + final Color indicatorColor; + final double indicatorRadius; + final EdgeInsetsGeometry padding; + final EdgeInsetsGeometry insets; + final TabBarIndicatorSize tabBarIndicatorSize; + + const BubbleTabIndicator({ + this.indicatorHeight: 20.0, + this.indicatorColor: Colors.greenAccent, + this.indicatorRadius: 100.0, + this.tabBarIndicatorSize = TabBarIndicatorSize.label, + this.padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0), + this.insets: const EdgeInsets.symmetric(horizontal: 5.0), + }) : assert(indicatorHeight != null), + assert(indicatorColor != null), + assert(indicatorRadius != null), + assert(padding != null), + assert(insets != null); + + @override + Decoration lerpFrom(Decoration a, double t) { + if (a is BubbleTabIndicator) { + return new BubbleTabIndicator( + padding: EdgeInsetsGeometry.lerp(a.padding, padding, t), + insets: EdgeInsetsGeometry.lerp(a.insets, insets, t), + ); + } + return super.lerpFrom(a, t); + } + + @override + Decoration lerpTo(Decoration b, double t) { + if (b is BubbleTabIndicator) { + return new BubbleTabIndicator( + padding: EdgeInsetsGeometry.lerp(padding, b.padding, t), + insets: EdgeInsetsGeometry.lerp(insets, b.insets, t), + ); + } + return super.lerpTo(b, t); + } + + @override + _BubblePainter createBoxPainter([VoidCallback onChanged]) { + return new _BubblePainter(this, onChanged); + } +} + +class _BubblePainter extends BoxPainter { + _BubblePainter(this.decoration, VoidCallback onChanged) + : assert(decoration != null), + super(onChanged); + + final BubbleTabIndicator decoration; + + double get indicatorHeight => decoration.indicatorHeight; + Color get indicatorColor => decoration.indicatorColor; + double get indicatorRadius => decoration.indicatorRadius; + EdgeInsetsGeometry get padding => decoration.padding; + EdgeInsetsGeometry get insets => decoration.insets; + TabBarIndicatorSize get tabBarIndicatorSize => decoration.tabBarIndicatorSize; + + Rect _indicatorRectFor(Rect rect, TextDirection textDirection) { + assert(rect != null); + assert(textDirection != null); + + Rect indicator = padding.resolve(textDirection).inflateRect(rect); + + if (tabBarIndicatorSize == TabBarIndicatorSize.tab) { + indicator = insets.resolve(textDirection).deflateRect(rect); + } + + return new Rect.fromLTWH( + indicator.left, + indicator.top, + indicator.width, + indicator.height, + ); + } + + @override + void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { + assert(configuration != null); + assert(configuration.size != null); + final Rect rect = Offset( + offset.dx, (configuration.size.height / 2) - indicatorHeight / 2) & + Size(configuration.size.width, indicatorHeight); + final TextDirection textDirection = configuration.textDirection; + final Rect indicator = _indicatorRectFor(rect, textDirection); + final Paint paint = Paint(); + paint.color = indicatorColor; + paint.style = PaintingStyle.fill; + canvas.drawRRect( + RRect.fromRectAndRadius(indicator, Radius.circular(indicatorRadius)), + paint); + } +} \ No newline at end of file diff --git a/lib/util/net_util.dart b/lib/util/net_util.dart index d3bd139..5a733bd 100644 --- a/lib/util/net_util.dart +++ b/lib/util/net_util.dart @@ -54,7 +54,7 @@ class NetUtil { if (_dio == null) { var setting = await NativeUtil.getSetting(); String domain = setting['domain']; //'http://www.hairuyi.com/'; - _config(domain, proxyUrl: ''); // 192.168.0.66:8866 + _config(domain, proxyUrl: '192.168.0.102:8866'); // 192.168.0.66:8866 } return _dio; } diff --git a/lib/util/turn_chain/turn_chain_util.dart b/lib/util/turn_chain/turn_chain_util.dart index b6884b8..b9260e3 100644 --- a/lib/util/turn_chain/turn_chain_util.dart +++ b/lib/util/turn_chain/turn_chain_util.dart @@ -55,9 +55,10 @@ class TurnChainUtil { /// 微盘: sinavdisk:// /// 名片全能王: camcard:// /// - static Future openReceiveCoupon(BuildContext context, UserInfoModel userInfoModel, String goodsId, String provider, Map data) async { + static Future openReceiveCoupon(BuildContext context, UserInfoModel userInfoModel, String goodsId, String provider, Map data, {bool isFree}) async { ///iOS 审核状态 String is_ios_review = await SharedPreferencesUtil.getStringValue(GlobalConfig.IS_IOS_REVIEW, defaultVal: '0'); + /// 1、先判断是否登陆 if (EmptyUtil.isEmpty(userInfoModel) || EmptyUtil.isEmpty(userInfoModel?.token)) { RouterUtil.goLogin(context); @@ -71,7 +72,7 @@ class TurnChainUtil { } /// 3、获取转链,进行跳转 - Map result = await getTurnChainResult(context, goodsId, provider, data, isShare: false); + Map result = await getTurnChainResult(context, goodsId, provider, data, isShare: false, isFree: isFree); if (!EmptyUtil.isEmpty(result)) { String openAppUrl = result['open_app_url']; String appUrl = result['app_url']; @@ -86,10 +87,10 @@ class TurnChainUtil { if (Platform.isAndroid) { tradeResult = await FlutterAlibc.openByUrl(url: openAppUrl, backUrl: "alisdk://"); } else if (Platform.isIOS) { - if(is_ios_review=='1'){ - print('iOS审核:'+is_ios_review); + if (is_ios_review == '1') { + print('iOS审核:' + is_ios_review); RouterUtil.openWebview(webUrl, context); - }else{ + } else { tradeResult = await FlutterAlibc.openByUrl(url: openAppUrl); } } @@ -200,13 +201,19 @@ class TurnChainUtil { /// 根据商品id等信息,获取领券或者分享的转链接 /// /// - static Future> getTurnChainResult(BuildContext context, String goodsId, String provider, Map data, {bool isShare = false}) async { + static Future> getTurnChainResult(BuildContext context, String goodsId, String provider, Map data, + {bool isShare = false, bool isFree = false}) async { try { TurnChainDialogRepository repository = TurnChainDialogRepository(); if (!EmptyUtil.isEmpty(context) && !EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(data) && !EmptyUtil.isEmpty('gid')) { TurnChainStyleModel model = await repository.fetchCacheData(goodsId, provider, data['commission'], data['coupon_price']); // 设置是否分享还是转链 data['is_share'] = isShare ? '1' : '0'; + + ///1为免单,0为普通 + data['isFree'] = isFree ? "1" : "0"; + isFree ? print("免单") : print("普通"); + if (EmptyUtil.isEmpty(model)) { // 开启loading Loading.show(context); diff --git a/lib/zhiying_comm.dart b/lib/zhiying_comm.dart index 01851fd..4a008b4 100644 --- a/lib/zhiying_comm.dart +++ b/lib/zhiying_comm.dart @@ -38,4 +38,5 @@ export 'models/base/base_change_notifier.dart'; export 'util/parse_util.dart'; export 'util/download/download.dart'; export 'util/alipay_util.dart'; +export 'util/bubble_tabIndicator/bubble_tabIndicator.dart';