parent
43cf9c0282
commit
7f94576967
@ -0,0 +1,16 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'news_category_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class NewsCategoryModel {
|
||||
final int id;
|
||||
final String name;
|
||||
NewsCategoryModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory NewsCategoryModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$NewsCategoryModelFromJson(json);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'news_category_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
NewsCategoryModel _$NewsCategoryModelFromJson(Map<String, dynamic> json) {
|
||||
return NewsCategoryModel(
|
||||
id: json['id'] as int,
|
||||
name: json['name'] as String,
|
||||
);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
import 'package:flustars/flustars.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:aku_community/model/common/img_model.dart';
|
||||
|
||||
part 'news_item_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class NewsItemModel {
|
||||
final int id;
|
||||
final String title;
|
||||
final String createDate;
|
||||
final List<ImgModel> imgList;
|
||||
DateTime? get create => DateUtil.getDateTime(createDate);
|
||||
NewsItemModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.createDate,
|
||||
required this.imgList,
|
||||
});
|
||||
|
||||
factory NewsItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$NewsItemModelFromJson(json);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'news_item_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
NewsItemModel _$NewsItemModelFromJson(Map<String, dynamic> json) {
|
||||
return NewsItemModel(
|
||||
id: json['id'] as int,
|
||||
title: json['title'] as String,
|
||||
createDate: json['createDate'] as String,
|
||||
imgList: (json['imgList'] as List<dynamic>)
|
||||
.map((e) => ImgModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
@ -1,25 +1,45 @@
|
||||
import 'package:aku_community/constants/api.dart';
|
||||
import 'package:aku_community/models/news/news_category_model.dart';
|
||||
import 'package:aku_community/models/news/news_item_model.dart';
|
||||
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:aku_community/ui/home/public_infomation/public_infomation_card.dart';
|
||||
import 'package:aku_community/utils/headers.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
|
||||
class PublicInfomationView extends StatefulWidget {
|
||||
PublicInfomationView({Key? key}) : super(key: key);
|
||||
final NewsCategoryModel model;
|
||||
PublicInfomationView({Key? key, required this.model}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PublicInfomationViewState createState() => _PublicInfomationViewState();
|
||||
}
|
||||
|
||||
class _PublicInfomationViewState extends State<PublicInfomationView> {
|
||||
class _PublicInfomationViewState extends State<PublicInfomationView>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
EasyRefreshController _refreshController = EasyRefreshController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 24.w),
|
||||
itemBuilder: (context, index) {
|
||||
return PublicInfomationCard();
|
||||
super.build(context);
|
||||
return BeeListView(
|
||||
path: API.news.list,
|
||||
controller: _refreshController,
|
||||
convert: (model) =>
|
||||
model.tableList!.map((e) => NewsItemModel.fromJson(e)).toList(),
|
||||
builder: (items) {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 24.w),
|
||||
itemBuilder: (context, index) {
|
||||
return PublicInfomationCard(model: items[index]);
|
||||
},
|
||||
separatorBuilder: (_, __) => 24.hb,
|
||||
itemCount: items.length,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) => 24.hb,
|
||||
itemCount: 100,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
Loading…
Reference in new issue