From 3d5d7fbfb4f0eb72bfa24b4b1eeb8bcb3f38ec94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Sat, 23 Jan 2021 18:09:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E5=8F=AF=E7=94=A8tabbar?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=9B=BE=E7=9A=84=E8=A3=85=E9=A5=B0=E7=B1=BB?= =?UTF-8?q?=202.=E8=BD=AC=E9=93=BE=E6=B7=BB=E5=8A=A0isFree=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bubble_tabIndicator.dart | 113 ++++++++++++++++++ lib/util/net_util.dart | 2 +- lib/util/turn_chain/turn_chain_util.dart | 19 ++- lib/zhiying_comm.dart | 1 + 4 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 lib/util/bubble_tabIndicator/bubble_tabIndicator.dart 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';