首页公告栏,全部公告页逻辑调整

hmxc
张萌 4 years ago
parent 263cdbd328
commit b011ff388b

@ -1,3 +1,4 @@
import 'package:aku_community_manager/provider/anouncement_provider.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/provider/fix_provider.dart';
import 'package:aku_community_manager/provider/manage_provider.dart';
@ -31,6 +32,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (context) => OutdoorProvider()),
ChangeNotifierProvider(create: (context) => GreenManageProvider()),
ChangeNotifierProvider(create: (context) => InspectionManageProvider()),
ChangeNotifierProvider(create: (context)=>AnouncementProvider()),
],
child: GetMaterialApp(
title: '小蜜蜂管家',

@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
class AnouncementCardModel {
String title;
String date;
String body;
AnouncementCardModel(this.title, this.date, {this.body});
static List<AnouncementCardModel> initList() {
return [
AnouncementCardModel(
'关于国庆放假的通知和安排',
'2020-10-22 10:00',
body: '''
201610177108
''',
),
AnouncementCardModel(
'关于国庆放假的通知和安排',
'2020-10-22 10:00',
),
AnouncementCardModel('关于中秋放假通知与工作安排', '2020-10-22 10:00'),
AnouncementCardModel('疫情期间对大家的表扬和鼓励', '2020-10-22 11:00'),
];
}
}

@ -0,0 +1,12 @@
import 'package:aku_community_manager/mock_models/anouncement/anouncement_model.dart';
import 'package:flutter/material.dart';
class AnouncementProvider extends ChangeNotifier{
List<AnouncementCardModel> _anouncementCardModel=AnouncementCardModel.initList();
List<AnouncementCardModel> get anouncementCardModels =>_anouncementCardModel;
addAnouncementCardModel(AnouncementCardModel model){
_anouncementCardModel.insert(0, model);
notifyListeners();
}
}

@ -1,5 +1,7 @@
import 'dart:ui';
import 'package:aku_community_manager/mock_models/anouncement/anouncement_model.dart';
import 'package:aku_community_manager/provider/anouncement_provider.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/announcement/anouncement_details.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
@ -8,40 +10,27 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community_manager/const/resource.dart';
import 'package:get/get.dart';
class AnouncementCardModel {
String title;
String date;
AnouncementCardModel(
this.title,
this.date,
);
}
import 'package:provider/provider.dart';
class AllAnouncement extends StatefulWidget {
AllAnouncement({Key key}) : super(key: key);
@override
_AllAnouncementState createState() => _AllAnouncementState();
AllAnouncementState createState() => AllAnouncementState();
}
class _AllAnouncementState extends State<AllAnouncement> {
Widget _anounceCard(
String title,
String date,
class AllAnouncementState extends State<AllAnouncement> {
static Widget anounceCard(
AnouncementCardModel model
) {
return Column(
children: [
AkuButton(
onPressed: () {
Get.to(AnouncementDetails(
title: title,
date: date,
body: '''
201610177108
''',
title: model.title,
date: model.date,
body: model.body==null?'':model.body,
));
},
child: Container(
@ -74,7 +63,7 @@ class _AllAnouncementState extends State<AllAnouncement> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
model.title,
style: AppStyle().primaryStyle,
),
SizedBox(height: 12.w),
@ -85,7 +74,7 @@ class _AllAnouncementState extends State<AllAnouncement> {
width: 24.w,
),
Text(
date,
model.date,
style: AppStyle().minorStyle,
),
Spacer(),
@ -121,7 +110,7 @@ class _AllAnouncementState extends State<AllAnouncement> {
)),
...(cards
.map(
(e) => _anounceCard(e.title, e.date),
(e) => anounceCard(e),
)
.toList()),
],
@ -130,25 +119,14 @@ class _AllAnouncementState extends State<AllAnouncement> {
@override
Widget build(BuildContext context) {
final AnouncementProvider _anouncementProvider=Provider.of<AnouncementProvider>(context);
return AkuScaffold(
title: '全部公告',
body: ListView(
padding: EdgeInsets.only(left: 32.w, right: 32.w),
children: [
_anouncementList('2020-10-22', [
AnouncementCardModel(
'关于国庆放假的通知和安排',
'2020-10-22 10:00',
),
AnouncementCardModel(
'关于绿化组人员调动通知',
'2020-10-22 11:00',
),
]),
_anouncementList('2020-10-20', [
AnouncementCardModel('关于中秋放假通知与工作安排', '2020-10-22 10:00'),
AnouncementCardModel('疫情期间对大家的表扬和鼓励', '2020-10-22 11:00'),
]),
_anouncementList('2020-10-22', _anouncementProvider.anouncementCardModels.sublist(0,2)),
_anouncementList('2020-10-20', _anouncementProvider.anouncementCardModels.sublist(2,2)),
],
),
);

@ -1,4 +1,5 @@
import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/provider/anouncement_provider.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/style/app_style.dart';
@ -15,6 +16,7 @@ import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and
import 'package:aku_community_manager/ui/tool_pages/scan_page.dart';
import 'package:aku_ui/aku_ui.dart';
import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -120,9 +122,11 @@ class _HomePageState extends State<HomePage> {
));
}
int _currentIndicator = 0;
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
final _anouncementProvider = Provider.of<AnouncementProvider>(context);
ScreenUtil.init(context,
designSize: Size(750, 1334), allowFontScaling: true);
return AnnotatedRegion<SystemUiOverlayStyle>(
@ -380,8 +384,46 @@ class _HomePageState extends State<HomePage> {
color: Color(0xFFFFFFFF),
//
width: double.infinity,
height: 172.w,
//TODO listview
height: 200.w,
child: Column(
children: [
CarouselSlider(
items: _anouncementProvider.anouncementCardModels
.map((e) => AllAnouncementState.anounceCard(e))
.toList(),
options: CarouselOptions(
viewportFraction: 1.0,
aspectRatio: 686 / 172,
autoPlay: true,
onPageChanged: (index, _) {
setState(() {
_currentIndicator = index;
});
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children:
_anouncementProvider.anouncementCardModels.map((e) {
int index =
_anouncementProvider.anouncementCardModels.indexOf(e);
return Container(
width: 8.w,
height: 8.w,
margin: EdgeInsets.symmetric(
vertical: 10.w, horizontal: 2.w),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _currentIndicator == index
? Color.fromRGBO(0, 0, 0, 0.9)
: Color.fromRGBO(0, 0, 0, 0.4),
),
);
}).toList(),
),
],
),
),
SizedBox(height: 16.w),
//

Loading…
Cancel
Save