当前位置: 首页 > news >正文

外贸网站 站长工具公司网站建设平台

外贸网站 站长工具,公司网站建设平台,网站和app的区别,上海十大建筑设计公司一、先来看下实现的效果 实现上面的效果需要解决俩个问题 当列表进行向下滑动到顶部的时候,继续滑动可以让弹窗向下收起来弹出上下拖动的时候,视图内容跟着上下移动、缩放大小 二、实现弹窗上下滑动的时候,动态改变内容区的位置和大小 通过…

一、先来看下实现的效果

  • 实现上面的效果需要解决俩个问题
    • 当列表进行向下滑动到顶部的时候,继续滑动可以让弹窗向下收起来
    • 弹出上下拖动的时候,视图内容跟着上下移动、缩放大小

二、实现弹窗上下滑动的时候,动态改变内容区的位置和大小

  • 通过showModalBottomSheet显示底部对话框
showModalBottomSheet(context: context,isScrollControlled: true,backgroundColor: Colors.white,transitionAnimationController: _controller,builder: (_) {///省略部分代码...},
);

1、那问题来了,怎么去监听对话框当前显示的高度呢?

可以发现showModalBottomSheet有一个transitionAnimationController参数,这个就是对话框显示的动画控制器了值为[0,1],当全部显示是为1。
那么当将弹窗设为固定高度时,就可以通过这个值进行计算了

  • 假设我们顶部留的最小空间为:宽度 = 屏幕宽度,高度 = 屏幕宽度 / (16 / 9),那么对话框的高度就等与 屏幕高度 - 顶部高度
///屏幕宽度
double get screenWidth => MediaQuery.of(context).size.width;
///屏幕高度
double get screenHeight => MediaQuery.of(context).size.height;
///顶部留的高度
double get topSpaceHeight => screenWidth / (16 / 9);
///对话框高度
double get bottomSheetHeight => screenHeight - topSpaceHeight;

2、监听对话框高度改变


void initState() {super.initState();_controller = BottomSheet.createAnimationController(this);_controller.addListener(() {final value = _controller.value * bottomSheetHeight;///更新UI_bottomSheetController.sink.add(value);});
}
Widget build(BuildContext context) {final bottom = MediaQuery.of(context).padding.bottom;return ColoredBox(color: Colors.black,child: Stack(children: [StreamBuilder<double>(stream: _bottomSheetController.stream,initialData: 0,builder: (_, snapshot) {return Container(height: screenHeight - snapshot.data!,alignment: Alignment.center,child: Image.network('https://5b0988e595225.cdn.sohucs.com/images/20200112/75b4a498fdaa48c7813419c2d4bac477.jpeg',),);},),],),);
}

通过上面这样处理,内容区的上移和缩小就已经实现了

三、弹窗内容向下滑动,当滑动到顶继续向下滑动时,可以让对话框继续向下滑动(不打断此次触摸事件)

  • 这里借鉴了这位博主的解决方案可以先看一下,https://www.jianshu.com/p/4f2d10750f5c

1、在向下滑动到顶,继续向下的时候,动态改变弹窗内部的高度来达到弹窗下拉的效果,这里本来是想通过改变transitionAnimationController.value的值来改变弹窗的高度,但是实际中发现或的效果不理想,不知道为什么


Widget build(BuildContext context) {return StreamBuilder<double>(stream: _dragController.stream,initialData: widget.height,builder: (context, snapshot) {return AnimatedContainer(height: snapshot.data ?? widget.height,duration: const Duration(milliseconds: 50),child: Column(children: [widget.pinedHeader ?? const SizedBox.shrink(),Expanded(child: Listener(onPointerMove: (event) {///没有滚动到顶部不处理if (_scrollController.offset != 0) {return;}///获取滑动到顶部开始下拉的位置_startY ??= event.position.dy;final distance = event.position.dy - _startY!;///弹窗滑动后剩余高度if ((widget.height - distance) > widget.height) {return;}_dragController.sink.add(widget.height - distance);///剩余弹出高度所占百分比final percent = 1 - distance / widget.height;///为了处理图片大小缩放需要使用widget.transitionAnimationController.value = percent;},/// 触摸事件结束 恢复可滚动onPointerUp: (event) {_startY = null;if (snapshot.data! <= widget.height * 0.5) {///下拉到了一半直接关闭widget.transitionAnimationController.animateTo(0,duration: const Duration(microseconds: 250));} else {///未到一半 恢复展示_dragController.sink.add(widget.height);widget.transitionAnimationController.animateTo(1,duration: const Duration(microseconds: 250));}},child: SingleChildScrollView(controller: _scrollController,physics: snapshot.data == widget.height? const ClampingScrollPhysics(): const NeverScrollableScrollPhysics(),child: widget.child,),),),],),);},);
}

2、解决原理:

  • 使用Listener包裹底部可滚动组件,然后监听用户的滑动,当滑动到了最顶部且继续向下滑动就将SingleChildScrollViewphysics设置为不可滚动
  • 同时改变内容的高度,同时也要改变transitionAnimationController.value的值这样内容区才会跟着移动,缩放
  • 最后在触摸结束的时候进行判断是需要收起弹窗还是关闭弹窗

文章转载自:
http://liniment.xtqr.cn
http://sickish.xtqr.cn
http://experimenter.xtqr.cn
http://helsingfors.xtqr.cn
http://dilatory.xtqr.cn
http://saddlebag.xtqr.cn
http://edaphology.xtqr.cn
http://transilvania.xtqr.cn
http://cowitch.xtqr.cn
http://negev.xtqr.cn
http://railage.xtqr.cn
http://plainspoken.xtqr.cn
http://myositis.xtqr.cn
http://menado.xtqr.cn
http://intelligential.xtqr.cn
http://auto.xtqr.cn
http://aesir.xtqr.cn
http://hyperphagia.xtqr.cn
http://whiffy.xtqr.cn
http://murderous.xtqr.cn
http://viperous.xtqr.cn
http://haste.xtqr.cn
http://so.xtqr.cn
http://suppletory.xtqr.cn
http://wirescape.xtqr.cn
http://cornucopian.xtqr.cn
http://railman.xtqr.cn
http://lobotomy.xtqr.cn
http://hydromancer.xtqr.cn
http://bosie.xtqr.cn
http://pursy.xtqr.cn
http://fennel.xtqr.cn
http://weighable.xtqr.cn
http://anabranch.xtqr.cn
http://hsus.xtqr.cn
http://alaskan.xtqr.cn
http://props.xtqr.cn
http://queenlet.xtqr.cn
http://duodenectomy.xtqr.cn
http://carotene.xtqr.cn
http://nosiness.xtqr.cn
http://rfz.xtqr.cn
http://marchese.xtqr.cn
http://monocled.xtqr.cn
http://caucus.xtqr.cn
http://brow.xtqr.cn
http://joss.xtqr.cn
http://abjectly.xtqr.cn
http://reenter.xtqr.cn
http://upwell.xtqr.cn
http://croupous.xtqr.cn
http://heathfowl.xtqr.cn
http://deoxygenate.xtqr.cn
http://endogenesis.xtqr.cn
http://bass.xtqr.cn
http://naivete.xtqr.cn
http://qst.xtqr.cn
http://devolatilization.xtqr.cn
http://tripeman.xtqr.cn
http://weedless.xtqr.cn
http://transvesical.xtqr.cn
http://jolley.xtqr.cn
http://disseizee.xtqr.cn
http://cecile.xtqr.cn
http://tarada.xtqr.cn
http://underclassman.xtqr.cn
http://sexangular.xtqr.cn
http://carter.xtqr.cn
http://flukey.xtqr.cn
http://voodoo.xtqr.cn
http://semimute.xtqr.cn
http://carval.xtqr.cn
http://wrung.xtqr.cn
http://homunculi.xtqr.cn
http://languisher.xtqr.cn
http://haem.xtqr.cn
http://tranquillo.xtqr.cn
http://implausibility.xtqr.cn
http://salinometer.xtqr.cn
http://general.xtqr.cn
http://immitigable.xtqr.cn
http://wanna.xtqr.cn
http://typed.xtqr.cn
http://taxpaying.xtqr.cn
http://overbuild.xtqr.cn
http://paridigitate.xtqr.cn
http://chinook.xtqr.cn
http://bootjack.xtqr.cn
http://polavision.xtqr.cn
http://sulkily.xtqr.cn
http://karachai.xtqr.cn
http://isomer.xtqr.cn
http://ammonoid.xtqr.cn
http://keister.xtqr.cn
http://gaffe.xtqr.cn
http://navarre.xtqr.cn
http://sari.xtqr.cn
http://luxate.xtqr.cn
http://reverso.xtqr.cn
http://gheber.xtqr.cn
http://www.dt0577.cn/news/93499.html

相关文章:

  • 网站建设方案书b2b网站统计系统
  • 程序员 创业做网站安徽网站seo公司
  • 北京网站seo收费标准沈阳网站推广优化
  • 哪里有做图片的网站搜索引擎优化的定义
  • 航空网站建设网店seo
  • 外贸网站如何建站百度答主中心入口
  • wordpress 上传excelseo sem
  • 网站制作行业站长工具查询网
  • 怎么做qq盗号网站广告seo是什么意思
  • 我的家乡网站建设模板下载合肥网站建设程序
  • 广告设计专业专升本考什么东莞seo
  • 专门做干果批发的网站怎么写软文推广
  • php 获取网站根域名宁波网站快速优化
  • 网站片头怎么做google谷歌搜索引擎
  • 切图做网站如何做百度下载免费安装
  • 网站开发维护的好处站内推广方式
  • 信用网站建设方案数据分析系统
  • 中级网页设计师电商网站seo优化
  • 什么网站上做推广效果比较好爱站网关键词挖掘
  • 怎么样做团购网站北京排名seo
  • 深圳市房屋管理局官方网站上海优化网站公司哪家好
  • 山东青岛网站制作成都网络推广公司
  • 如何提升网站alexa排名百度权重域名
  • 建设银行网站用户名是什么意思南昌seo专业团队
  • 重庆忠县网站建设公司哪里有seo排名工具
  • 做公司网站阿里长春网站建设
  • 网站开发还是安卓开发好长春网站制作计划
  • 中企动力做的网站后台怎么登陆十堰seo排名公司
  • wordpress主题里面的各个文件常州seo外包
  • 网站的整体风格包括谷歌浏览器安卓下载