首页公告可点击

hmxc
小赖 4 years ago
parent e8c1d86fd1
commit 4f6c703b66

@ -28,6 +28,7 @@ class _NoticeDetailPageState extends State<NoticeDetailPage> {
); );
Widget docView(String title, String path) { Widget docView(String title, String path) {
if (title.isEmpty) return SizedBox();
return Container( return Container(
margin: EdgeInsets.only(right: 113.w), margin: EdgeInsets.only(right: 113.w),
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,

@ -3,9 +3,11 @@ import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:akuCommunity/model/community/board_model.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/ui/community/notice/notice_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
// Package imports: // Package imports:
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
@ -23,10 +25,10 @@ class HomeNotification extends StatefulWidget {
} }
class _HomeNotificationState extends State<HomeNotification> { class _HomeNotificationState extends State<HomeNotification> {
String get randomItem { BoardItemModel get randomItem {
if (widget.items.isEmpty) return ''; if (widget.items.isEmpty) return null;
int index = Random().nextInt(widget.items.length - 1); int index = Random().nextInt(widget.items.length - 1);
return widget.items[index].title ?? ''; return widget.items[index];
} }
Timer _timer; Timer _timer;
@ -59,13 +61,16 @@ class _HomeNotificationState extends State<HomeNotification> {
widget.items.isEmpty widget.items.isEmpty
? Spacer() ? Spacer()
: GestureDetector( : GestureDetector(
onTap: () {}, onTap: () {
if (randomItem != null)
Get.to(NoticeDetailPage(id: randomItem.id));
},
child: AnimatedSwitcher( child: AnimatedSwitcher(
duration: Duration(milliseconds: 1000), duration: Duration(milliseconds: 1000),
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
key: ValueKey(randomItem), key: ValueKey(randomItem?.id ?? 0),
child: Text(randomItem), child: Text(randomItem?.title ?? ''),
), ),
), ),
).expand(), ).expand(),

Loading…
Cancel
Save