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

门户网站做啥网页小游戏手机版

门户网站做啥,网页小游戏手机版,网站正在建设中php,怎样找到专业做网站人在分页中,实现tab吸顶。 TDNavBar的screenAdaptation: true, 开启屏幕适配。 该属性已自动对不同手机状态栏高度进行适配。我们只需关注如何实现吸顶。 view import package:ducafe_ui_core/ducafe_ui_core.dart; import package:flutter/material.dart; import p…

在分页中,实现tab吸顶。
TDNavBar的screenAdaptation: true, 开启屏幕适配。
该属性已自动对不同手机状态栏高度进行适配。我们只需关注如何实现吸顶。
在这里插入图片描述
在这里插入图片描述

view

import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import 'package:xiaoshukeji/common/index.dart';import 'index.dart';// 1. SliverPersistentHeaderDelegate:必须实现的抽象类
class _StickyTabBarDelegate extends SliverPersistentHeaderDelegate {final Widget child;_StickyTabBarDelegate({required this.child});@overrideWidget build(BuildContext context, double shrinkOffset, bool overlapsContent) {// shrinkOffset: 滚动距离// overlapsContent: 是否与其他内容重叠return Container(color: AppTheme.pageBgColor,child: child,);}@overridedouble get maxExtent => 92.w; // 最大高度,已知tab高度72+上下padding:10@overridedouble get minExtent => 92.w; // 最小高度@overridebool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) => true;
}class RankingPage extends GetView<RankingController> {const RankingPage({super.key});// 头部皇冠位置Widget _buildHeader() {return <Widget>[].toRow().card(color: AppTheme.pageBgColor).tight(width: 750.w,height: 300.w,);}// tab,可吸顶Widget _buildTab() {return <Widget>[<Widget>[TextWidget.body('日榜', size: 28.sp, weight: FontWeight.w600, color: AppTheme.textColorfff),].toRow(mainAxisAlignment: MainAxisAlignment.center).card(color: AppTheme.primaryYellow).tight(width: 336.w,height: 72.w,),<Widget>[TextWidget.body('总榜', size: 28.sp, weight: FontWeight.w600, color: AppTheme.textColor6a7),].toRow(mainAxisAlignment: MainAxisAlignment.center).card(color: AppTheme.navBarBgColor).tight(width: 336.w,height: 72.w,),].toRow(mainAxisAlignment: MainAxisAlignment.spaceBetween);}// 数据列表Widget _buildDataList() {return SliverList(delegate: SliverChildBuilderDelegate((context, index) {return <Widget>[].toRow().paddingHorizontal(30.w).card(color: AppTheme.blockBgColor).tight(width: 690.w,height: 120.w,).marginOnly(bottom: 20.w);},childCount: 20,),);}// 主视图Widget _buildView() {return SmartRefresher(controller: controller.refreshController,enablePullUp: true,onRefresh: controller.onRefresh,onLoading: controller.onLoading,footer: const SmartRefresherFooterWidget(),header: const SmartRefresherHeaderWidget(),child: CustomScrollView(slivers: [// 头部_buildHeader().sliverToBoxAdapter().sliverPaddingHorizontal(30.w),// 2. SliverPersistentHeader:实现吸顶的核心组件SliverPersistentHeader(pinned: true,  // 设置为 true 实现吸顶delegate: _StickyTabBarDelegate(child: Container(padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 10.w),child: _buildTab(),),),),// 列表内容_buildDataList().sliverPaddingHorizontal(30.w),],),);}@overrideWidget build(BuildContext context) {return GetBuilder<RankingController>(init: RankingController(),id: "ranking",builder: (_) {return Scaffold(backgroundColor: AppTheme.pageBgColor, // 自定义颜色appBar: const TDNavBar(height: 0,titleColor: AppTheme.textColorfff,titleFontWeight: FontWeight.w600,backgroundColor: AppTheme.pageBgColor,screenAdaptation: true, // 是否进行屏幕适配,默认trueuseDefaultBack: false,),body: _buildView(),);},);}
}

controller

import 'package:get/get.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';class RankingController extends GetxController {RankingController();List items = [];/** 分页* refreshController:分页控制器* _page:分页* _limit:每页条数* _loadNewsSell:拉取数据(是否刷新)* onLoading:上拉加载新商品* onRefresh:下拉刷新* */final RefreshController refreshController = RefreshController(initialRefresh: true,);// int _page = 1;// int _limit = 20;Future<bool> _loadNewsSell(bool isRefresh) async {return false;// var result = await ProductApi.products(ProductsReq(//   page:isRefresh ? 1:_page,//     prePage:_limit// ));// if(isRefresh){//   _page = 1;//   items.clear();// }// if(result.isNotEmpty){//   _page++;//   items.addAll(result);// }// // 是否是空// return result.isEmpty;}// 上拉载入新商品void onLoading() async {if (items.isNotEmpty) {try {// 拉取数据是否为空 ? 设置暂无数据 : 加载完成var isEmpty = await _loadNewsSell(false);isEmpty? refreshController.loadNoData(): refreshController.loadComplete();} catch (e) {refreshController.loadFailed(); // 加载失败}} else {refreshController.loadNoData(); // 设置无数据}update(["ranking"]);}// 下拉刷新void onRefresh() async {try {await _loadNewsSell(true);refreshController.refreshCompleted();} catch (e) {refreshController.refreshFailed();}update(["ranking"]);}_initData() {update(["ranking"]);}void onTap() {}// @override// void onInit() {//   super.onInit();// }@overridevoid onReady() {super.onReady();_initData();}// @override// void onClose() {//   super.onClose();// }
}

记录tab切换

int currentTab = 0; // 当前选中的tab索引
// tab切换方法
void switchTab(int index) {if (currentTab == index) return;currentTab = index;items.clear();// 切换tab时重置列表数据refreshController.requestRefresh();update(["ranking"]);
}// tab切换
Widget _buildTab() {return <Widget>[<Widget>[TextWidget.body('日榜', size: 28.sp, weight: FontWeight.w600, color: controller.currentTab == 0 ?  AppTheme.textColorfff : AppTheme.textColor646),].toRow(mainAxisAlignment: MainAxisAlignment.center).card(color: controller.currentTab == 0 ? AppTheme.primaryYellow : AppTheme.navBarBgColor).tight(width: 336.w,height: 72.w,).onTap(() {controller.switchTab(0);}),<Widget>[TextWidget.body('总榜', size: 28.sp, weight: FontWeight.w600, color: controller.currentTab == 1 ?  AppTheme.textColorfff : AppTheme.textColor646),].toRow(mainAxisAlignment: MainAxisAlignment.center).card(color: controller.currentTab == 1 ? AppTheme.primaryYellow : AppTheme.navBarBgColor ).tight(width: 336.w,height: 72.w,).onTap(() {controller.switchTab(1);}),].toRow(mainAxisAlignment: MainAxisAlignment.spaceBetween);
}
http://www.yayakq.cn/news/129950/

相关文章:

  • 网站开发文献资料自己做的网站怎么接入银联支付
  • wordpress快站平台外包建网站多少钱
  • 怎么知道网站有没有被收录西安网站制作 西安彩铃400电话
  • 专业网站建设微信网站定制页面上影响网站排名的因素
  • 响应式网站建设团队全网天下wordpress 多page
  • 台州做网站的公司在手机上建网站
  • 灯网一家专门做灯的网站智慧团建网站首页
  • 彩票网站开发制作h5蚁百杭州网站seo优化
  • 网站开发需要哪些人才wordpress社
  • 咸阳网站开发联系方式深圳画册设计企业
  • 阿里巴巴网站本土化建设dw友情链接怎么设置
  • 杭州专业网站设计制作做一个综合性的网站多少钱
  • 淄博公司网站建设效果90字体设计
  • aspcms 网站无法显示该页面网络推广官网首页
  • 一般公司网站用什么域名套餐为什么不能进入wordpress
  • 织梦做商城网站焊工培训ppt课件
  • dw 做静态网站竞价排名深度解析
  • 企业网站的建设思维导图红桃免费观看电视剧高清斗破苍穹
  • 做网站要学什么东西深圳互联网
  • 武隆网站建设报价多屏网站建设
  • 东阳建设公司网站wordpress默认邮件文件夹
  • 网站建设综合推荐简单网站搭建
  • 绿色农产品网站 模板深圳网站建设迅美
  • 网站美工培训课程网站备案是不是就是空间备案
  • 暗红色网站做的新网站做百度推广怎么弄
  • 网站幻灯片效果代码重庆建一个网站
  • 宁夏网站建设公司山东网建设
  • 零基础建设网站视频教程深圳定制建设网站
  • 盐城市城乡和住房建设厅网站衡水企业网站设计
  • 久商推网站建设中英网站模板 照明