diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 309af34c..1c922f80 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,3 @@ { - "flutterSdkVersion": "2.0.0" + "flutterSdkVersion": "stable" } \ No newline at end of file diff --git a/lib/ui/home/home_notification.dart b/lib/ui/home/home_notification.dart index 731cd930..a2f44d7c 100644 --- a/lib/ui/home/home_notification.dart +++ b/lib/ui/home/home_notification.dart @@ -1,6 +1,4 @@ -import 'dart:async'; -import 'dart:math'; - +import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -9,7 +7,6 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/model/community/board_model.dart'; -import 'package:akuCommunity/ui/community/notice/notice_detail_page.dart'; import 'package:akuCommunity/ui/community/notice/notice_page.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -22,26 +19,6 @@ class HomeNotification extends StatefulWidget { } class _HomeNotificationState extends State { - BoardItemModel get randomItem { - if (widget.items.isEmpty) return null; - int index = Random().nextInt(widget.items.length - 1); - return widget.items[index]; - } - - Timer _timer; - - @override - void initState() { - super.initState(); - _timer = Timer.periodic( - Duration(milliseconds: 5000), (timer) => setState(() {})); - } - - @override - void dispose() { - _timer?.cancel(); - super.dispose(); - } @override Widget build(BuildContext context) { @@ -57,20 +34,17 @@ class _HomeNotificationState extends State { 24.wb, widget.items.isEmpty ? Spacer() - : GestureDetector( - onTap: () { - if (randomItem != null) - Get.to(() => NoticeDetailPage(id: randomItem.id)); - }, - child: AnimatedSwitcher( - duration: Duration(milliseconds: 1000), - child: Align( - alignment: Alignment.centerLeft, - key: ObjectKey(randomItem), - child: Text(randomItem?.title ?? ''), - ), + : Container( + alignment: Alignment.centerLeft, + height: 85.w, + child: AnimatedTextKit( + animatedTexts: widget.items + .map((e) => RotateAnimatedText(e.title)) + .toList(), + repeatForever: true, ), - ).expand(), + ), + Spacer(), MaterialButton( shape: StadiumBorder(), padding: EdgeInsets.symmetric(horizontal: 12.w), diff --git a/pubspec.lock b/pubspec.lock index 50d439fc..9ab4aaf2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -24,6 +24,13 @@ packages: url: "http://159.75.73.143:8080/third_packages/amap_flutter_map" source: git version: "2.0.2-nullsafety" + animated_text_kit: + dependency: "direct main" + description: + name: animated_text_kit + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.1" animator: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8d9112f7..81a1dfa3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,17 +12,12 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - # 权限组件 permission_handler: ^6.1.1 - # 版本信息 package_info: ^2.0.0 provider: ^5.0.0 - # 屏幕适配 flutter_screenutil: ^5.0.0-nullsafety.11 cupertino_icons: ^1.0.2 - # 打电话等各种功能 url_launcher: ^6.0.2 - # 工具类 flustars: ^2.0.1 # icons # TODO need remove @@ -70,6 +65,7 @@ dependencies: ref: nullsafety amap_flutter_location: ^1.0.1 amap_flutter_base: ^1.0.2 + animated_text_kit: ^4.1.1 dev_dependencies: flutter_test: