Browse Source

部分依赖库升级

liukai 1 year ago
parent
commit
978861e816

+ 8 - 1
lib/comm/utils/dark_theme_util.dart

@@ -20,7 +20,14 @@ class DarkThemeUtil {
 
   /// 默认黑暗模式下的颜色不变.
   /// 如果想自定义黑暗模式下的图标颜色填充颜色就行
-  static Widget multiImageColor(String imgPath, double width, double height, {Color? darkColor, BoxFit? fit}) {
+  static Widget multiImageColorFit(String imgPath, double width, double height, {Color? darkColor, BoxFit? fit}) {
     return MyAssetImage(imgPath, width: width, height: height, color: Get.isDarkMode ? darkColor : null, fit: fit);
   }
+
+  /// 默认黑暗模式下的图片资源不变
+  /// 如果想自定义黑暗模式下的图片资源,可以直接替换图片
+  static Widget multiImagePath(String imgPath, double width, double height, {String? darkImagePath}) {
+    return MyAssetImage(Get.isDarkMode && darkImagePath != null ? darkImagePath : imgPath,
+        width: width, height: height);
+  }
 }

+ 2 - 1
lib/comm/widget/common_widget.dart

@@ -24,7 +24,8 @@ class CommonWidget {
             if (backCallback != null) {
               backCallback();
             } else {
-              Navigator.pop(context);
+              Get.back();
+              // Navigator.pop(context);
             }
           },
         ),

+ 4 - 4
lib/comm/widget/my_load_image.dart

@@ -24,7 +24,7 @@ class MyLoadImage extends StatelessWidget {
     this.width,
     this.height,
     this.fit = BoxFit.cover,
-    this.placeholderPath = 'none',
+    this.placeholderPath = '',
     this.cacheWidth,
     this.cacheHeight,
     this.isCircle,
@@ -45,7 +45,7 @@ class MyLoadImage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     if (image.isEmpty || image.startsWith('http')) {
-      final Widget holder = MyAssetImage(placeholderPath, height: height, width: width, fit: fit);
+      final Widget placeholder = MyAssetImage(placeholderPath, height: height, width: width, fit: fit);
 
       return Container(
           decoration: BoxDecoration(
@@ -58,8 +58,8 @@ class MyLoadImage extends StatelessWidget {
                 borderRadius: BorderRadius.circular(cornerRadius ?? 0),
                 child: CachedNetworkImage(
                   imageUrl: image,
-                  placeholder: (_, __) => holder,
-                  errorWidget: (_, __, dynamic error) => holder,
+                  placeholder: (_, __) => placeholder,
+                  errorWidget: (_, __, dynamic error) => placeholder,
                   width: width,
                   height: height,
                   fit: fit,

+ 97 - 90
lib/comm/widget/refresh/custom_foot_view.dart

@@ -1,90 +1,97 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_easyrefresh/easy_refresh.dart';
-import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
-
-class CustomFootView extends Footer {
-  /// Key
-  final Key? key;
-
-  final LinkFooterNotifier linkNotifier = LinkFooterNotifier();
-
-  CustomFootView({
-    this.key,
-    bool enableHapticFeedback = true,
-    bool enableInfiniteLoad = true,
-    bool overScroll = false,
-  }) : super(
-          extent: 50.0,
-          triggerDistance: 50.0,
-          float: false,
-          enableHapticFeedback: enableHapticFeedback,
-          enableInfiniteLoad: enableInfiniteLoad,
-          overScroll: overScroll,
-        );
-
-  @override
-  Widget contentBuilder(
-      BuildContext context,
-      LoadMode loadState,
-      double pulledExtent,
-      double loadTriggerPullDistance,
-      double loadIndicatorExtent,
-      AxisDirection axisDirection,
-      bool float,
-      Duration? completeDuration,
-      bool enableInfiniteLoad,
-      bool success,
-      bool noMore) {
-    // 不能为水平方向
-    assert(axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal');
-    linkNotifier.contentBuilder(context, loadState, pulledExtent, loadTriggerPullDistance, loadIndicatorExtent,
-        axisDirection, float, completeDuration, enableInfiniteLoad, success, noMore);
-    return CustomMoreWidget(
-      key: key,
-      linkNotifier: linkNotifier,
-    );
-  }
-}
-
-//LoadMore-底部加载更多的布局
-class CustomMoreWidget extends StatefulWidget {
-  final LinkFooterNotifier linkNotifier;
-
-  const CustomMoreWidget({Key? key, required this.linkNotifier}) : super(key: key);
-
-  @override
-  CustomFooterWidgetState createState() {
-    return CustomFooterWidgetState();
-  }
-}
-
-class CustomFooterWidgetState extends State<CustomMoreWidget> {
-  LoadMode get _refreshState => widget.linkNotifier.loadState;
-
-  bool get _noMore => widget.linkNotifier.noMore;
-
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      height: 50,
-      alignment:Alignment.center ,
-      padding: const EdgeInsets.symmetric(vertical: 10.0),
-      child: Row(
-        mainAxisAlignment: MainAxisAlignment.center,
-        children: <Widget>[
-          if (!_noMore) const CupertinoActivityIndicator(),
-          if (!_noMore)
-            const SizedBox(
-              width: 5,
-            ),
-
-          // 只有一页的时候,就不显示FooterView了
-          Text(!_noMore ? '正在加载中...' : '没有了呦~',
-              style: TextStyle(
-                  fontSize: 14, color: DarkThemeUtil.multiColors(const Color(0x8A000000), darkColor: Colors.white54))),
-        ],
-      ),
-    );
-  }
-}
+// import 'package:easy_refresh/easy_refresh.dart';
+// import 'package:flutter/cupertino.dart';
+// import 'package:flutter/material.dart';
+//
+// import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
+//
+// class CustomFootView extends Footer {
+//   /// Key
+//   final Key? key;
+//
+//   final LinkFooterNotifier linkNotifier = LinkFooterNotifier();
+//
+//   CustomFootView({
+//     this.key,
+//     bool enableHapticFeedback = true,
+//     bool enableInfiniteLoad = true,
+//     bool overScroll = false,
+//   }) : super(
+//           extent: 50.0,
+//           triggerDistance: 50.0,
+//           float: false,
+//           enableHapticFeedback: enableHapticFeedback,
+//           enableInfiniteLoad: enableInfiniteLoad,
+//           overScroll: overScroll,
+//         );
+//
+//   @override
+//   Widget contentBuilder(
+//       BuildContext context,
+//       LoadMode loadState,
+//       double pulledExtent,
+//       double loadTriggerPullDistance,
+//       double loadIndicatorExtent,
+//       AxisDirection axisDirection,
+//       bool float,
+//       Duration? completeDuration,
+//       bool enableInfiniteLoad,
+//       bool success,
+//       bool noMore) {
+//     // 不能为水平方向
+//     assert(axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal');
+//     linkNotifier.contentBuilder(context, loadState, pulledExtent, loadTriggerPullDistance, loadIndicatorExtent,
+//         axisDirection, float, completeDuration, enableInfiniteLoad, success, noMore);
+//     return CustomMoreWidget(
+//       key: key,
+//       linkNotifier: linkNotifier,
+//     );
+//   }
+//
+//   @override
+//   Widget build(BuildContext context, IndicatorState state) {
+//     // TODO: implement build
+//     throw UnimplementedError();
+//   }
+// }
+//
+// //LoadMore-底部加载更多的布局
+// class CustomMoreWidget extends StatefulWidget {
+//   final LinkFooterNotifier linkNotifier;
+//
+//   const CustomMoreWidget({Key? key, required this.linkNotifier}) : super(key: key);
+//
+//   @override
+//   CustomFooterWidgetState createState() {
+//     return CustomFooterWidgetState();
+//   }
+// }
+//
+// class CustomFooterWidgetState extends State<CustomMoreWidget> {
+//   LoadMode get _refreshState => widget.linkNotifier.loadState;
+//
+//   bool get _noMore => widget.linkNotifier.noMore;
+//
+//   @override
+//   Widget build(BuildContext context) {
+//     return Container(
+//       height: 50,
+//       alignment:Alignment.center ,
+//       padding: const EdgeInsets.symmetric(vertical: 10.0),
+//       child: Row(
+//         mainAxisAlignment: MainAxisAlignment.center,
+//         children: <Widget>[
+//           if (!_noMore) const CupertinoActivityIndicator(),
+//           if (!_noMore)
+//             const SizedBox(
+//               width: 5,
+//             ),
+//
+//           // 只有一页的时候,就不显示FooterView了
+//           Text(!_noMore ? '正在加载中...' : '没有了呦~',
+//               style: TextStyle(
+//                   fontSize: 14, color: DarkThemeUtil.multiColors(const Color(0x8A000000), darkColor: Colors.white54))),
+//         ],
+//       ),
+//     );
+//   }
+// }

+ 2 - 7
lib/local/language/en_US.dart

@@ -1,13 +1,8 @@
 const Map<String, String> en_US = {
   'app_name': 'YY Circle',
-  'welcome': 'Welcome',
-  'title': 'This is Title!',
   'loading': 'Loading...',
   'load_error_try_again': 'Load Error,Please click to try again!',
   'load_no_data': 'No Data',
-  'part_time': 'Part Time',
-  'full_time': 'Full Time',
-  'e_wallet': 'E-Wallet',
-  'news_feed': 'News Feed',
-  'me': 'Me',
+
+
 };

+ 2 - 7
lib/local/language/zh_CN.dart

@@ -1,13 +1,8 @@
 const Map<String, String> zh_CN = {
   'app_name': 'YY Circle',
-  'welcome': '欢迎',
-  'title': '这是标题',
   'loading': '加载中...',
   'load_error_try_again': '加载失败,请点击重试',
   'load_no_data': '暂无数据',
-  'part_time': '兼职工作',
-  'full_time': '全职工作',
-  'e_wallet': '电子钱包',
-  'news_feed': '朋友圈',
-  'me': '我的',
+
+
 };

+ 1 - 1
lib/main.dart

@@ -68,7 +68,7 @@ class MyApp extends StatelessWidget {
       initialBinding: AppBinding(),
       smartManagement: SmartManagement.keepFactory,
       //网页Title显示
-      title: 'YYCircle Malay',
+      title: 'FullTime Recruiter',
       //样式相关
       theme: ThemeConfig.lightTheme,
       darkTheme: ThemeConfig.darkTheme,

+ 1 - 2
lib/modules/zdemo/demo_page.dart

@@ -104,8 +104,7 @@ class DemoPage extends GetView<DemoController> {
               onEmpty: const Text("onEmpty"),
             ),
             const SizedBox(height: 10.0),
-            DarkThemeUtil.multiImageColor("assets/images/splash_center_blue_logo.webp", 144, 112,
-                darkColor: Colors.white),
+            DarkThemeUtil.multiImageColorFit("assets/images/splash_center_blue_logo.webp", 144, 112, darkColor: Colors.white),
             const SizedBox(height: 10.0),
             MyInputField(
               controller: controller.registerEmailController,

+ 100 - 0
lib/modules/zdemo/list_item.dart

@@ -0,0 +1,100 @@
+import 'package:flutter/material.dart';
+import 'package:easy_refresh/src/painter/paths_painter.dart';
+
+/// List item.
+class ListItem extends StatelessWidget {
+  const ListItem({
+    Key? key,
+    required this.title,
+    this.subtitle,
+    this.leading,
+    this.icon,
+    this.iconPaths,
+    this.trailing,
+    this.onTap,
+    this.selected = false,
+    this.divider = false,
+  }) : super(key: key);
+
+  final String title;
+
+  final String? subtitle;
+
+  final Widget? leading;
+
+  final IconData? icon;
+
+  final List<String>? iconPaths;
+
+  final Widget? trailing;
+
+  final bool selected;
+
+  final VoidCallback? onTap;
+
+  final bool divider;
+
+  Widget? get _leading {
+    if (leading != null) {
+      return leading!;
+    }
+    if (icon != null) {
+      return Container(
+        height: 36,
+        width: 36,
+        decoration: BoxDecoration(
+          color: Colors.white,
+          borderRadius: const BorderRadius.all(Radius.circular(18)),
+        ),
+        alignment: Alignment.center,
+        child: Icon(
+          icon!,
+          color: Colors.white,
+        ),
+      );
+    }
+    if (iconPaths != null) {
+      return Container(
+        height: 36,
+        width: 36,
+        decoration: BoxDecoration(
+          color: Colors.white,
+          borderRadius: const BorderRadius.all(Radius.circular(18)),
+        ),
+        alignment: Alignment.center,
+        child: PathsPaint(
+          paths: iconPaths!,
+          colors: List.filled(
+              iconPaths!.length, Colors.white),
+          width: 24,
+        ),
+      );
+    }
+    return null;
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Column(
+      children: [
+        ListTile(
+          title: Text(title),
+          subtitle: subtitle == null ? null : Text(subtitle!),
+          leading: _leading,
+          trailing: trailing,
+          selected: selected,
+          onTap: onTap,
+        ),
+        if (divider)
+          Padding(
+            padding: EdgeInsets.only(
+                left: leading == null && icon == null ? 16 : 72, right: 16),
+            child: const Divider(
+              thickness: 1,
+              height: 1,
+            ),
+          ),
+      ],
+    );
+  }
+}

+ 75 - 54
lib/modules/zdemo/page_four.dart

@@ -1,9 +1,7 @@
+import 'package:easy_refresh/easy_refresh.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/rendering.dart';
-import 'package:flutter_easyrefresh/easy_refresh.dart';
-import 'package:get/get.dart';
-import 'package:ftrecruiter/comm/widget/my_refresh_list.dart';
-import 'package:ftrecruiter/comm/widget/refresh/custom_foot_view.dart';
+import 'package:ftrecruiter/modules/zdemo/list_item.dart';
 
 //Demo列表3,使用StatefulWidget+GetBuilder的方式 可以保存状态了,推荐使用
 class PageFour extends StatefulWidget {
@@ -18,7 +16,12 @@ class _GoodsListPageState extends State<PageFour>
   List<String> _list = List.generate(10, (index) => "1234");
   int _page = 1;
   final int _maxPage = 10;
-  EasyRefreshController easyRefreshController = EasyRefreshController();
+
+  //刷新控件控制器
+  final EasyRefreshController _controller = EasyRefreshController(
+    controlFinishRefresh: true,
+    controlFinishLoad: true,
+  );
 
   Future _onRefresh() async {
     // 设置两秒后关闭刷新,时间可以随便设置,根据项目需求,正常在请求成功后,也要关闭
@@ -28,7 +31,8 @@ class _GoodsListPageState extends State<PageFour>
         _list = List.generate(10, (index) => "1234");
 
         // 控制器关闭刷新功能
-        easyRefreshController.finishRefresh(success: true);
+        _controller.finishRefresh();
+        _controller.resetFooter();
       });
     });
   }
@@ -40,65 +44,82 @@ class _GoodsListPageState extends State<PageFour>
         _list.addAll(List.generate(10, (i) => "4567"));
 
         // 控制器关闭加载功能,还可以设置没有更多数据noMore
-        easyRefreshController.finishLoad(success: true);
+        _controller.finishLoad(IndicatorResult.success);
       });
     });
   }
 
   @override
   Widget build(BuildContext context) {
-    return EasyRefresh.custom(
+    return EasyRefresh(
       //创建的刷新控制器
-      controller: easyRefreshController,
+      controller: _controller,
+
       //自定义刷新头
-      header: ClassicalHeader(
-        enableInfiniteRefresh: false,
-        float: false,
-        enableHapticFeedback: false,
-        refreshText: "pullToRefresh",
-        refreshReadyText: "releaseToRefresh",
-        refreshingText: "refreshing",
-        refreshedText: "refreshed",
-        refreshFailedText: "refreshFailed",
-        noMoreText: "noMore",
-        infoText: "updateAt %T",
-      ),
+      // header: MaterialHeader(),
+
+      // ClassicalHeader(
+      //   enableInfiniteRefresh: false,
+      //   float: false,
+      //   enableHapticFeedback: false,
+      //   refreshText: "pullToRefresh",
+      //   refreshReadyText: "releaseToRefresh",
+      //   refreshingText: "refreshing",
+      //   refreshedText: "refreshed",
+      //   refreshFailedText: "refreshFailed",
+      //   noMoreText: "noMore",
+      //   infoText: "updateAt %T",
+      // ),
+
       //自定义刷新脚
-      footer:
-          // ClassicalFooter(
-          //   enableInfiniteLoad: true,
-          //   enableHapticFeedback: false,
-          //   loadText: "pushToLoad",
-          //   loadReadyText: "releaseToLoad",
-          //   loadingText: "loading",
-          //   loadedText: "loaded",
-          //   loadFailedText: "loadFailed",
-          //   noMoreText: "noMore",
-          //   infoText: "updateAt %T",
-          // ),
-          // BallPulseFooter(),
-      CustomFootView(),
+      // footer: MaterialFooter(),
+
+      // ClassicalFooter(
+      //   enableInfiniteLoad: true,
+      //   enableHapticFeedback: false,
+      //   loadText: "pushToLoad",
+      //   loadReadyText: "releaseToLoad",
+      //   loadingText: "loading",
+      //   loadedText: "loaded",
+      //   loadFailedText: "loadFailed",
+      //   noMoreText: "noMore",
+      //   infoText: "updateAt %T",
+      // ),
+      // CustomFootView(),
+
       onRefresh: _onRefresh,
       onLoad: _loadMore,
-      slivers: <Widget>[
-        // 这里设置列表 - 可以用SliverList,这里是固定高度,使用SliverFixedExtentList更好
-        SliverFixedExtentList(
-          itemExtent: 100,
-          delegate: SliverChildBuilderDelegate((context, index) {
-            return Container(
-              margin: const EdgeInsets.only(top: 10.0),
-              width: double.infinity,
-              height: 100,
-              color: Colors.pink,
-              child: Row(
-                children: [
-                  Text("我是列表Item:$index"),
-                ],
-              ),
-            );
-          }, childCount: _list.length),
-        ),
-      ],
+
+      // childBuilder: (BuildContext context, ScrollPhysics physics) {
+      //   return NestedScrollView(
+      //       physics: physics,
+      //       headerSliverBuilder: (context, innerBoxIsScrolled) {
+      //         return [
+      //           const HeaderLocator.sliver(clearExtent: false),
+      //         ];
+      //       },
+      //       body: ListView.builder(
+      //
+      //         itemBuilder: (BuildContext context, int index) {
+      //           //Item布局
+      //           return ListTile(title: Text("$index"));
+      //         },
+      //       ));
+      // },
+
+      child: CustomScrollView(
+        slivers: [
+          SliverFixedExtentList( //或者直接用Sliver也是可以的,只是一个固定Item高度,一个不固定高度而已
+            itemExtent: 100,
+            delegate: SliverChildBuilderDelegate(
+              (context, index) {
+                return const ListItem(title: "index");
+              },
+              childCount: _list.length,
+            ),
+          ),
+        ],
+      ),
     );
   }
 

+ 8 - 3
pubspec.yaml

@@ -46,11 +46,16 @@ dependencies:
   # 兼容Android iOS的键盘逻辑处理
   keyboard_actions: ^4.2.0
 
-  # WebView插件 https://github.com/flutter/plugins/tree/master/packages/webview_flutter
-  webview_flutter: 3.0.2
+    # WebView插件 https://github.com/flutter/plugins/tree/master/packages/webview_flutter
+    #  webview_flutter: 3.0.2(可以用这一种,也能用下面一种)
+    # 如何使用?WebviewScaffold 整体WebView带上下结构布局
+    #          FlutterWebviewPlugin  单独的WebView插件
+  # https://pub.dev/packages/flutter_webview_plugin#-readme-tab
+  flutter_webview_plugin: ^0.4.0
 
   # 自定义下拉刷新控件 https://github.com/xuelongqy/flutter_easyrefresh
-  flutter_easyrefresh: 2.2.1
+  # sample示例:https://github.com/xuelongqy/flutter_easy_refresh/tree/v3/example/lib/page/sample
+  easy_refresh: ^3.3.1
 
 dev_dependencies:
   flutter_test: