475 lines
14 KiB
Dart
475 lines
14 KiB
Dart
import 'package:environmental_protection/common/user_information.dart';
|
|
import 'package:environmental_protection/icon/material_design_icons.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView(
|
|
padding: const EdgeInsetsDirectional.all(10),
|
|
children: const [
|
|
Advantage(),
|
|
Notifications(),
|
|
Applications(),
|
|
Activities(),
|
|
Dynamics(),
|
|
Reminders()
|
|
],
|
|
);
|
|
}
|
|
}
|
|
class Advantage extends StatefulWidget {
|
|
const Advantage({super.key});
|
|
|
|
@override
|
|
State<Advantage> createState() => _AdvantageState();
|
|
}
|
|
|
|
class _AdvantageState extends State<Advantage> {
|
|
List<String> urls = [
|
|
"/profile/upload/2021/11/27/12qw.jpg",
|
|
"/profile/upload/2021/11/27/34qw.jpg",
|
|
"/profile/upload/2021/11/27/56qw.jpg",
|
|
"/profile/upload/2021/11/27/78qw.jpg",
|
|
"/profile/upload/2023/12/28/5a48fd02-4232-4b1d-8ce3-3420d2447c5e.jpg"
|
|
];
|
|
int _index = 0;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<Widget> container = [];
|
|
double width = 10;
|
|
double height = 10;
|
|
for(var i = 0;i < urls.length; i++){
|
|
var c = Container(width: width, height: height, decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.grey), margin: const EdgeInsetsDirectional.all(2));
|
|
if (i == _index){
|
|
c = Container(width: width, height: height, decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.blue), margin: const EdgeInsetsDirectional.all(2));
|
|
}
|
|
container.add(c);
|
|
}
|
|
return Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 200,
|
|
child: PageView(
|
|
scrollDirection: Axis.horizontal,
|
|
children: urls.map((e) => Image(image: NetworkImage("http://124.93.196.45:10091/Neusoft/community$e"))).toList(),
|
|
onPageChanged: (index) {
|
|
setState(() {
|
|
_index = index;
|
|
});
|
|
},
|
|
)
|
|
),
|
|
Container(
|
|
margin: const EdgeInsetsDirectional.only(top: 10),
|
|
child: Flex(
|
|
direction: Axis.horizontal,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: container,
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Notifications extends StatefulWidget {
|
|
const Notifications({super.key});
|
|
|
|
@override
|
|
State<Notifications> createState() => _NotificationsState();
|
|
}
|
|
|
|
class _NotificationsState extends State<Notifications> {
|
|
GlobalInformation? global;
|
|
final String _notifiction = "通知";
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: [
|
|
const Icon(MaterialDesign.sms, color: Colors.blue),
|
|
Text(_notifiction)
|
|
],
|
|
);
|
|
}
|
|
}
|
|
class Application extends StatelessWidget {
|
|
final IconData icon;
|
|
final String title;
|
|
const Application({super.key, required this.icon, required this.title});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: 60,
|
|
height: 60,
|
|
decoration: BoxDecoration(border: Border.all(color: Colors.blue), borderRadius: BorderRadius.circular(10)),
|
|
alignment: Alignment.center,
|
|
margin: const EdgeInsetsDirectional.all(10),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Icon(icon),
|
|
Text(title)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class Applications extends StatefulWidget {
|
|
const Applications({super.key});
|
|
|
|
@override
|
|
State<Applications> createState() => _ApplicationsState();
|
|
}
|
|
|
|
class _ApplicationsState extends State<Applications> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 200,
|
|
child: GridView(
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
|
children: const [
|
|
Application(icon: MaterialDesign.exit_to_app, title: "开门"),
|
|
Application(icon: MaterialDesign.home, title: "我的房屋"),
|
|
Application(icon: MaterialDesign.directions_car, title: "我的车位",),
|
|
Application(icon: Icons.account_balance_wallet, title: "物业缴费",),
|
|
Application(icon: MaterialDesign.crop_free, title: "扫码取件",),
|
|
Application(icon: MaterialDesign.sms, title: "社区公告",),
|
|
Application(icon: MaterialDesign.call, title: "社区电话",),
|
|
Application(icon: MaterialDesign.email, title: "投诉建议",)
|
|
]
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
class Activity extends StatelessWidget {
|
|
final String title;
|
|
final double kmDistance;
|
|
const Activity({super.key, required this.title, required this.kmDistance});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: 200,
|
|
height: 50,
|
|
padding: const EdgeInsetsDirectional.all(5),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: const Color.fromARGB(50, 0, 0, 100),
|
|
width: 1
|
|
),
|
|
borderRadius: BorderRadius.circular(10)
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const SizedBox(
|
|
width: 80,
|
|
height: 50,
|
|
child: Placeholder()
|
|
),
|
|
SizedBox(
|
|
width: 100,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
margin: const EdgeInsetsDirectional.only(start: 10, top: 10),
|
|
child: Text(
|
|
title,
|
|
softWrap: true,
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: const EdgeInsetsDirectional.only(start: 10, top: 5),
|
|
child: Text(
|
|
"距您$kmDistance km",
|
|
style: const TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 10,
|
|
),
|
|
textAlign: TextAlign.left,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class Activities extends StatefulWidget {
|
|
const Activities({super.key});
|
|
|
|
@override
|
|
State<Activities> createState() => _ActivitiesState();
|
|
}
|
|
|
|
|
|
class ShowMoreContainer extends StatelessWidget {
|
|
final String title;
|
|
final Widget child;
|
|
final bool showMore;
|
|
const ShowMoreContainer({super.key, required this.title, required this.child, required this.showMore});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var titleWidget = [
|
|
Positioned(
|
|
left: 0,
|
|
top: 0,
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 20
|
|
),
|
|
)
|
|
),
|
|
];
|
|
if (showMore) {
|
|
titleWidget.add(Positioned(
|
|
right: 0,
|
|
top: 0,
|
|
child: InkWell(
|
|
onTap: (){},
|
|
child: const Row(
|
|
children: [
|
|
Text("查看更多"),
|
|
Icon(MaterialDesign.keyboard_arrow_right)
|
|
]
|
|
)
|
|
)
|
|
));
|
|
}
|
|
return Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 30,
|
|
child: Stack(
|
|
children: titleWidget,
|
|
)
|
|
),
|
|
Container(
|
|
margin: const EdgeInsetsDirectional.only(top: 10),
|
|
child: child,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class _ActivitiesState extends State<Activities> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ShowMoreContainer(
|
|
title: "社区活动",
|
|
showMore: true,
|
|
child: SizedBox(
|
|
height: 100,
|
|
child: ListView(
|
|
scrollDirection: Axis.horizontal,
|
|
children: const [
|
|
Activity(title: "红星社区地毯清洗活动", kmDistance: 3.6),
|
|
Activity(title: "红星社区地毯清洗活动", kmDistance: 3.6),
|
|
Activity(title: "红星社区地毯清洗活动", kmDistance: 3.6),
|
|
Activity(title: "红星社区地毯清洗活动", kmDistance: 3.6)
|
|
],
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
class Dynamic extends StatelessWidget {
|
|
final String title;
|
|
final String source;
|
|
final int commentCount;
|
|
final DateTime sendTime;
|
|
const Dynamic({super.key, required this.title, required this.source, required this.commentCount, required this.sendTime});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var beforeTime = DateTime.now().difference(sendTime);
|
|
var hour = beforeTime.inHours;
|
|
var time = "$hour 小时前";
|
|
if (hour > 24){
|
|
time = "1 天前";
|
|
}
|
|
return SizedBox(
|
|
width: 500,
|
|
height: 150,
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
left: 0,
|
|
top: 10,
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
width: 170,
|
|
child: Text(
|
|
title,
|
|
softWrap: true,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.w900
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
"$source $commentCount评论 $time",
|
|
style: const TextStyle(
|
|
color: Colors.grey
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
const Positioned(
|
|
right: 0,
|
|
top: 0,
|
|
child: SizedBox(
|
|
width: 200,
|
|
height: 100,
|
|
child: Placeholder(),
|
|
)
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class Dynamics extends StatefulWidget {
|
|
const Dynamics({super.key});
|
|
|
|
@override
|
|
State<Dynamics> createState() => _DynamicsState();
|
|
}
|
|
|
|
class _DynamicsState extends State<Dynamics> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ShowMoreContainer(
|
|
title: "社区动态",
|
|
showMore: true,
|
|
child: SizedBox(
|
|
height: 300,
|
|
child: ListView(
|
|
children: [
|
|
Dynamic(title: "内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例", source: "内容来源", commentCount: 15, sendTime: DateTime.now().subtract(Duration(hours: 1))),
|
|
Dynamic(title: "内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例", source: "内容来源", commentCount: 15, sendTime: DateTime.now().subtract(Duration(hours: 1))),
|
|
Dynamic(title: "内容标题示例内容标题示例内容标题示例内容标题示例内容标题示const 例内容标题示例内容标题示例内容标题示例内容标题示例内容标题示例", source: "内容来源", commentCount: 15, sendTime: DateTime.now().subtract(Duration(hours: 1)))
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
}
|
|
class Reminder extends StatelessWidget {
|
|
final String message;
|
|
const Reminder({super.key, required this.message});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
margin: const EdgeInsetsDirectional.only(top: 10),
|
|
child: Row(
|
|
children: [
|
|
const SizedBox(
|
|
width: 50,
|
|
height: 50,
|
|
child: Placeholder(),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsetsDirectional.only(start: 10),
|
|
child: Flex(
|
|
direction: Axis.vertical,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text(
|
|
"认证申请进度提醒",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 300,
|
|
child: Text(
|
|
message,
|
|
style: const TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 12,
|
|
overflow: TextOverflow.ellipsis
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 5,
|
|
height: 5,
|
|
decoration: const BoxDecoration(
|
|
color: Colors.red,
|
|
shape: BoxShape.circle
|
|
),
|
|
),
|
|
const Icon(Icons.keyboard_arrow_right, color: Colors.grey)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class Reminders extends StatefulWidget {
|
|
const Reminders({super.key});
|
|
|
|
@override
|
|
State<Reminders> createState() => _RemindersState();
|
|
}
|
|
|
|
class _RemindersState extends State<Reminders> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ShowMoreContainer(
|
|
title: "认证提醒",
|
|
showMore: false,
|
|
child: SizedBox(
|
|
height: 300,
|
|
child: ListView(
|
|
children: const [
|
|
Reminder(message: "认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看"),
|
|
Reminder(message: "认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看认证已通过,查看")
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
}
|