提交 6c817aa7 authored 作者: 张国庆's avatar 张国庆

基础刷新列表控件
上级 952a6e9a
...@@ -27,7 +27,6 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" ...@@ -27,7 +27,6 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 33 compileSdkVersion 33
ndkVersion flutter.ndkVersion
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_11 sourceCompatibility JavaVersion.VERSION_11
...@@ -45,7 +44,7 @@ android { ...@@ -45,7 +44,7 @@ android {
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21 minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion 31
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }
......
import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base_example/l10n/translations/en.dart';
import 'package:flutter_clx_base_example/l10n/translations/zh_cn.dart';
class AppTranslations extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en': en,
'zh_CN': zhCN,
};
static const List<Locale> supportedLocales = [
Locale('en'),
Locale('zh', 'CN'),
];
static const fallbackLocale = Locale('en');
}
const en = {
'Sample': 'Sample',
'Style': 'Style',
'More': 'More',
'Theme': 'Theme',
'System': 'System',
'Light': 'Light',
'Dark': 'Dark',
'Classic': 'Classic',
'Classic and default': 'Classic and default',
'Direction': 'Direction',
'Vertical': 'Vertical',
'Horizontal': 'Horizontal',
'Clamping': 'Clamping',
'Background': 'Background',
'Alignment': 'Alignment',
'Center': 'Center',
'Start': 'Start',
'End': 'End',
'Infinite': 'Infinite',
'Message': 'Message',
'Text': 'Text',
'Animation': 'Animation',
'Bounce': 'Bounce',
'List Spring': 'List Spring',
'Pull to refresh': 'Pull to refresh',
'Release ready': 'Release ready',
'Refreshing...': 'Refreshing...',
'Succeeded': 'Succeeded',
'No more': 'No more',
'Failed': 'Failed',
'Last updated at %T': 'Last updated at %T',
'Pull to load': 'Pull to load',
'Loading...': 'Loading...',
'Bezier curve': 'Bezier curve',
'Disable': 'Disable',
'Display balls': 'Display balls',
'Bezier circle': 'Bezier circle',
'Golden campus': 'Golden campus',
'Rush to the sky': 'Rush to the sky',
'Balloon delivery': 'Balloon delivery',
'Star track': 'Star track',
'Lumberjack Squats': 'Lumberjack Squats',
'Skating boy': 'BSkating boy',
'Halloween horror': 'Halloween horror',
'User profile': 'User profile',
'User personal center': 'User personal center',
'QQ group': 'QQ group',
'Name': 'Name',
'Age': 'Age',
'Not yet bald': 'Not yet bald',
'City': 'City',
'China - ChengDu': 'China - ChengDu',
'Phone': 'Phone',
'Mail': 'Mail',
'NestedScrollView example': 'NestedScrollView example',
'Carousel': 'Carousel',
'Carousel example': 'Carousel example',
'Refresh on start': 'Refresh on start',
'Refresh when the list is displayed and specify the Header':
'Refresh when the list is displayed and specify the Header',
'Listener': 'Listener',
'Use listener to respond anywhere': 'Use listener to respond anywhere',
'Secondary': 'Secondary',
'Combine existing Header with secondary':
'Combine existing Header with secondary',
'Open the second floor': 'Open the second floor',
'Chat': 'Chat',
'Chat page example': 'Chat page example',
'PageView example': 'PageView example',
'Join discussion': 'Join discussion',
'Join the QQ group (554981921)': 'Join the QQ group (554981921)',
'Repository': 'Repository',
'Support me': 'Support me',
'Buy me a coffee ~': 'Buy me a coffee ~',
'Alipay': 'Alipay',
'Alipay donation': 'Alipay donation',
'Wechat': 'Wechat',
'Wechat donation': 'Wechat donation',
'Cryptocurrency': 'Cryptocurrency',
'Cryptocurrency donation': 'Cryptocurrency donation',
'Bitcoin donation': 'Bitcoin donation',
'Ethereum series, ETH, BNB, MATIC, USDT and other tokens':
'Ethereum series, ETH, BNB, MATIC, USDT and other tokens',
'Tron chain, TRX, USDT, USDC and other tokens':
'Tron chain, TRX, USDT, USDC and other tokens',
'Dogecoin donation': 'Dogecoin donation',
'%s copied!': '%s copied!',
'Trigger immediately': 'Trigger immediately',
'TabBarView example': 'NestedScrollView + TabBarView example',
'Paging': 'Paging',
'Paging example': 'Paging example',
'No Data': 'No Data',
'Theme switch': 'Theme switch',
'Theme switch example': 'Theme switch example',
'Theme switch describe':
'Pull down to display the switching panel, slide left and right to select the theme color, and release to switch.',
'Bubbles launch': 'Bubbles launch',
};
const zhCN = {
'Sample': '示例',
'Style': '样式',
'More': '更多',
'Theme': '主题',
'System': '系统',
'Light': '明亮',
'Dark': '暗黑',
'Classic': '经典',
'Classic and default': '经典和默认',
'Direction': '方向',
'Vertical': '垂直',
'Horizontal': '水平',
'Clamping': '固定',
'Background': '背景',
'Alignment': '对齐',
'Center': '中心',
'Start': '开端',
'End': '结尾',
'Infinite': '无限',
'Message': '信息',
'Text': '文本',
'Animation': '动画',
'Bounce': '回弹',
'List Spring': '列表弹簧',
'Pull to refresh': '下拉刷新',
'Release ready': '释放开始',
'Refreshing...': '刷新中...',
'Succeeded': '成功了',
'No more': '没有更多',
'Failed': '失败了',
'Last updated at %T': '最后更新于 %T',
'Pull to load': '上拉加载',
'Loading...': '加载中...',
'Bezier curve': '贝塞尔曲线',
'Disable': '禁用',
'Display balls': '显示小球',
'Bezier circle': '弹出圆圈',
'Golden campus': '金色校园',
'Rush to the sky': '冲上云霄',
'Balloon delivery': '气球快递',
'Star track': '太空轨道',
'Lumberjack Squats': '暴力深蹲',
'Skating boy': '滑雪少年',
'Halloween horror': '万圣节惊魂',
'User profile': '个人中心',
'User personal center': '用户个人中心',
'QQ group': 'QQ群',
'Name': '名字',
'Age': '年龄',
'Not yet bald': '尚未秃顶',
'City': '城市',
'China - ChengDu': '中国 - 成都',
'Phone': '电话',
'Mail': '邮箱',
'NestedScrollView example': 'NestedScrollView示例',
'Carousel': '轮播',
'Carousel example': '轮播示例',
'Refresh on start': '启动时刷新',
'Refresh when the list is displayed and specify the Header':
'列表显示时刷新并指定Header',
'Listener': '监听器',
'Use listener to respond anywhere': '使用监听器,在任意位置响应',
'Secondary': '二楼',
'Combine existing Header with secondary': '将已有的Header结合二楼',
'Open the second floor': '打开二楼',
'Chat': '聊天',
'Chat page example': '聊天页面示例',
'PageView example': 'PageView 示例',
'Join discussion': '加入讨论',
'Join the QQ group (554981921)': '加入QQ群(554981921)',
'Repository': '项目地址',
'Support me': '支持作者',
'Buy me a coffee ~': '请作者喝一杯咖啡~',
'Alipay': '支付宝',
'Alipay donation': '支付宝捐赠',
'Wechat': '微信',
'Wechat donation': '微信捐赠',
'Cryptocurrency': '加密货币',
'Cryptocurrency donation': '加密货币捐赠',
'Bitcoin donation': '比特币捐赠',
'Ethereum series, ETH, BNB, MATIC, USDT and other tokens':
'以太坊系列,ETH、BNB、MATIC、USDT及其他代币',
'Tron chain, TRX, USDT, USDC and other tokens': '波场链,TRX、USDT、USDC及其他代币',
'Dogecoin donation': '狗狗币捐赠',
'%s copied!': '%s 已复制!',
'Trigger immediately': '立即触发',
'TabBarView example': 'NestedScrollView + TabBarView示例',
'Paging': '分页',
'Paging example': '分页示例',
'No Data': '暂无数据',
'Theme switch': '主题切换',
'Theme switch example': '主题切换示例',
'Theme switch describe': '下拉显示切换面板,左右滑动选中主题色,释放进行切换。',
'Bubbles launch': '泡泡发射',
};
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart'; import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base_example/l10n/translations.dart';
import 'package:flutter_clx_base_example/sample.dart'; import 'package:flutter_clx_base_example/sample.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
...@@ -14,6 +16,15 @@ class MyApp extends StatelessWidget { ...@@ -14,6 +16,15 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetMaterialApp( return GetMaterialApp(
title: 'Flutter clx_base Demo', title: 'Flutter clx_base Demo',
translations: AppTranslations(),
supportedLocales: AppTranslations.supportedLocales,
locale: Get.deviceLocale,
fallbackLocale: AppTranslations.fallbackLocale,
localizationsDelegates: const [
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
theme: ThemeData( theme: ThemeData(
// This is the theme of your application. // This is the theme of your application.
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart'; import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base/widget/base_list_widget.dart'; import 'package:flutter_clx_base/widget/base_list_widget.dart';
import 'package:rive/rive.dart';
class BaseListWidgetTest extends StatefulWidget { class BaseListWidgetTest extends StatefulWidget {
const BaseListWidgetTest({super.key}); const BaseListWidgetTest({super.key});
...@@ -12,11 +13,12 @@ class BaseListWidgetTest extends StatefulWidget { ...@@ -12,11 +13,12 @@ class BaseListWidgetTest extends StatefulWidget {
class _BaseListWidgetTestState extends State<BaseListWidgetTest> { class _BaseListWidgetTestState extends State<BaseListWidgetTest> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final themeData = Theme.of(context);
return MyScaffold( return MyScaffold(
title: 'BaseListWidget', title: 'BaseListWidget',
body: BaseListWidget( body: BaseListWidget(
requestData: (page, pageSize, success, error) async { requestData: (page, pageSize, success, error) async {
await Future.delayed(const Duration(seconds: 2)); await Future.delayed(const Duration(seconds: 5));
if (page == 1) { if (page == 1) {
success([ success([
'1', '1',
...@@ -61,6 +63,28 @@ class _BaseListWidgetTestState extends State<BaseListWidgetTest> { ...@@ -61,6 +63,28 @@ class _BaseListWidgetTestState extends State<BaseListWidgetTest> {
child: Text(item.toString()), child: Text(item.toString()),
); );
}, },
header: TaurusHeader(
skyColor: themeData.colorScheme.primary,
),
footer: ClassicFooter(
dragText: 'Pull to load'.tr,
armedText: 'Release ready'.tr,
readyText: 'Loading...'.tr,
processingText: 'Loading...'.tr,
processedText: 'Succeeded'.tr,
noMoreText: 'No more'.tr,
failedText: 'Failed'.tr,
messageText: 'Last updated at %T'.tr,
),
startLoadWidget: Container(
alignment: Alignment.center,
width: double.infinity,
height: 300,
child: const RiveAnimation.asset(
'assets/rive/highway-truck.riv',
fit: BoxFit.cover,
),
),
), ),
); );
} }
......
...@@ -16,6 +16,8 @@ environment: ...@@ -16,6 +16,8 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_localizations:
sdk: flutter
flutter_clx_base: flutter_clx_base:
# When depending on this package from a real application you should use: # When depending on this package from a real application you should use:
...@@ -28,6 +30,7 @@ dependencies: ...@@ -28,6 +30,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
rive: ^0.10.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
...@@ -52,6 +55,7 @@ flutter: ...@@ -52,6 +55,7 @@ flutter:
uses-material-design: true uses-material-design: true
assets: assets:
- assets/images/ - assets/images/
- assets/rive/
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
......
import 'package:easy_refresh/easy_refresh.dart'; import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
export 'package:easy_refresh/easy_refresh.dart';
class BaseListWidget extends StatefulWidget { class BaseListWidget extends StatefulWidget {
final RequestDataCallback requestData; final RequestDataCallback requestData;
final int pageSize; final int pageSize;
final ItemBuilder itemBuilder; final ItemBuilder itemBuilder;
final Header? header;
final Footer? footer;
final Widget? startLoadWidget;
const BaseListWidget({ const BaseListWidget({
Key? key, Key? key,
required this.requestData, required this.requestData,
required this.pageSize, required this.pageSize,
required this.itemBuilder, required this.itemBuilder,
this.header,
this.footer,
this.startLoadWidget,
}) : super(key: key); }) : super(key: key);
@override @override
...@@ -37,6 +44,8 @@ class _BaseListWidgetState extends State<BaseListWidget> { ...@@ -37,6 +44,8 @@ class _BaseListWidgetState extends State<BaseListWidget> {
return EasyRefresh( return EasyRefresh(
controller: _controller, controller: _controller,
refreshOnStart: true, refreshOnStart: true,
header: widget.header,
footer: widget.footer,
refreshOnStartHeader: BuilderHeader( refreshOnStartHeader: BuilderHeader(
triggerOffset: 70, triggerOffset: 70,
clamping: true, clamping: true,
...@@ -52,11 +61,11 @@ class _BaseListWidgetState extends State<BaseListWidget> { ...@@ -52,11 +61,11 @@ class _BaseListWidgetState extends State<BaseListWidget> {
width: double.infinity, width: double.infinity,
height: state.viewportDimension, height: state.viewportDimension,
alignment: Alignment.center, alignment: Alignment.center,
child: SpinKitFadingCube( child: widget.startLoadWidget ??
size: 24, SpinKitFadingCircle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), size: 30,
); ));
}, },
), ),
onRefresh: _onRefresh, onRefresh: _onRefresh,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论