feat: adding loading
fix: change ui
This commit is contained in:
parent
991f871a17
commit
ed176aa297
@ -9,13 +9,6 @@ import 'package:environmental_protection/views/social.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
main() async {
|
||||
var global = GlobalInformation.getInstance();
|
||||
var response = await global.requester.post(resolve("api/login"), body: jsonEncode({
|
||||
'username': 'WUvFG3gY',
|
||||
'password': 'ZogPgBF6'
|
||||
}));
|
||||
// print(response.body);
|
||||
global.token = jsonDecode(response.body)['token'];
|
||||
runApp(const DigitalLife());
|
||||
}
|
||||
class DigitalLife extends StatelessWidget {
|
||||
@ -36,6 +29,7 @@ class RouterView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RouterViewState extends State<RouterView> {
|
||||
bool _isLogin = false;
|
||||
int _pageIndex = 0;
|
||||
final List<Widget> _pages = [
|
||||
const HomePage(),
|
||||
@ -46,8 +40,28 @@ class _RouterViewState extends State<RouterView> {
|
||||
];
|
||||
final String _name = "红星海五期";
|
||||
GlobalInformation? _globalInformation;
|
||||
void _login() async {
|
||||
var global = GlobalInformation.getInstance();
|
||||
var response = await global.requester.post(resolve("api/login"), body: jsonEncode({
|
||||
'username': 'WUvFG3gY',
|
||||
'password': 'ZogPgBF6'
|
||||
}));
|
||||
// print(response.body);
|
||||
global.token = jsonDecode(response.body)['token'];
|
||||
setState(() {
|
||||
_isLogin = true;
|
||||
});
|
||||
}
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_login();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_isLogin) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
_globalInformation ??= GlobalInformation.getInstance(super.setState);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
@ -89,9 +89,7 @@ class _AdvantageState extends State<Advantage> {
|
||||
child: PageView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: urls
|
||||
.map((e) => Image(
|
||||
image: NetworkImage(
|
||||
"http://124.93.196.45:10091/Neusoft/community$e")))
|
||||
.map((e) => Image.network("http://124.93.196.45:10091/Neusoft/community$e"))
|
||||
.toList(),
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
@ -122,6 +120,7 @@ class Notifications extends StatefulWidget {
|
||||
|
||||
class _NotificationsState extends State<Notifications> {
|
||||
String _notification = "通知";
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -137,12 +136,16 @@ class _NotificationsState extends State<Notifications> {
|
||||
final data = jsonDecode(response.body);
|
||||
setState(() {
|
||||
_notification = data['rows'][0]['noticeTitle'];
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(MaterialDesign.sms, color: Colors.blue),
|
||||
@ -280,6 +283,7 @@ class Activities extends StatefulWidget {
|
||||
|
||||
class _ActivitiesState extends State<Activities> {
|
||||
List<Map<String, dynamic>> _activities = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -302,6 +306,7 @@ class _ActivitiesState extends State<Activities> {
|
||||
"http://124.93.196.45:10091/Neusoft/community${activity['cover']}",
|
||||
})
|
||||
.toList();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -311,7 +316,7 @@ class _ActivitiesState extends State<Activities> {
|
||||
return ShowMoreContainer(
|
||||
title: "社区活动",
|
||||
showMore: true,
|
||||
child: SizedBox(
|
||||
child: _isLoading ? const Center(child: CircularProgressIndicator()) : SizedBox(
|
||||
height: 100,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@ -402,6 +407,7 @@ class Dynamics extends StatefulWidget {
|
||||
|
||||
class _DynamicsState extends State<Dynamics> {
|
||||
List<Map<String, dynamic>> _dynamics = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -425,6 +431,7 @@ class _DynamicsState extends State<Dynamics> {
|
||||
"http://124.93.196.45:10091/Neusoft/community${dynamic['cover']}",
|
||||
})
|
||||
.toList();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -434,7 +441,7 @@ class _DynamicsState extends State<Dynamics> {
|
||||
return ShowMoreContainer(
|
||||
title: "社区动态",
|
||||
showMore: true,
|
||||
child: Column(
|
||||
child: _isLoading ? const Center(child: CircularProgressIndicator()) : Column(
|
||||
children: _dynamics.map((dynamic) {
|
||||
return Dynamic(
|
||||
title: dynamic['title'],
|
||||
@ -444,7 +451,7 @@ class _DynamicsState extends State<Dynamics> {
|
||||
imageUrl: dynamic['imageUrl'],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -520,6 +527,7 @@ class Reminders extends StatefulWidget {
|
||||
|
||||
class _RemindersState extends State<Reminders> {
|
||||
final List<Map<String, dynamic>> _reminders = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -535,6 +543,7 @@ class _RemindersState extends State<Reminders> {
|
||||
final data = jsonDecode(response.body);
|
||||
setState(() {
|
||||
data['data'].forEach((e) => _reminders.add(e));
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -544,7 +553,7 @@ class _RemindersState extends State<Reminders> {
|
||||
return ShowMoreContainer(
|
||||
title: "认证提醒",
|
||||
showMore: false,
|
||||
child: SizedBox(
|
||||
child: _isLoading ? const Center(child: CircularProgressIndicator()) : SizedBox(
|
||||
height: 300,
|
||||
child: ListView.builder(
|
||||
itemCount: _reminders.length,
|
||||
|
@ -110,6 +110,7 @@ class _MePageState extends State<MePage> {
|
||||
var personsCard = persons.map((e){return PersonCard(name: e['name'], phone: e['telephone'], endDate: e['endDate'] == null ? null : DateTime.parse(e['endDate']), id: e['id'], fetchFunction: _fetchFamilyData, type: e['memberType'] == "1" ? "家属" : "租户");}).toList();
|
||||
List<Widget> items = [];
|
||||
items.addAll(personsCard);
|
||||
items.add(const SizedBox(height: 20));
|
||||
items.add(Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: (){
|
||||
@ -133,10 +134,31 @@ class _MePageState extends State<MePage> {
|
||||
));
|
||||
return FullPageStruct(
|
||||
title: '家庭成员管理',
|
||||
color: Colors.lightBlue,
|
||||
child: ListView(
|
||||
children: items,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
top: 0,
|
||||
child: Flex(
|
||||
direction: Axis.vertical,
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadiusDirectional.only(bottomStart: Radius.circular(10), bottomEnd: Radius.circular(10)),
|
||||
color: Colors.blue
|
||||
),
|
||||
height: 100,
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
top: 50,
|
||||
child: ListView(
|
||||
children: items,
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -224,85 +246,101 @@ class _AddFamilyPersonState extends State<AddFamilyPerson> {
|
||||
title: "新增家庭成员",
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '选择房屋'),
|
||||
value: _selectedHouseId,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedHouseId = value;
|
||||
});
|
||||
},
|
||||
items: _houseList.map((house) {
|
||||
return DropdownMenuItem(
|
||||
value: house['id'].toString(),
|
||||
child: Text(house['address'] ?? '未知地址'),
|
||||
);
|
||||
}).toList(),
|
||||
validator: (value) =>
|
||||
value == null ? '请选择房屋' : null,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '姓名'),
|
||||
onSaved: (value) => _name = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入姓名'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '性别'),
|
||||
value: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "0", child: Text('男')),
|
||||
DropdownMenuItem(value: "1", child: Text('女')),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
top: 0,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '选择房屋'),
|
||||
value: _selectedHouseId,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedHouseId = value;
|
||||
});
|
||||
},
|
||||
items: _houseList.map((house) {
|
||||
return DropdownMenuItem(
|
||||
value: house['id'].toString(),
|
||||
child: Text(house['address'] ?? '未知地址'),
|
||||
);
|
||||
}).toList(),
|
||||
validator: (value) =>
|
||||
value == null ? '请选择房屋' : null,
|
||||
),
|
||||
const Divider(),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '姓名'),
|
||||
onSaved: (value) => _name = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入姓名'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '性别'),
|
||||
value: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "0", child: Text('男')),
|
||||
DropdownMenuItem(value: "1", child: Text('女')),
|
||||
],
|
||||
validator: (value) => value == null ? '请选择性别' : null,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '手机号'),
|
||||
keyboardType: TextInputType.phone,
|
||||
onSaved: (value) => _phone = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入手机号'
|
||||
: null,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '身份证号'),
|
||||
onSaved: (value) => _idCard = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入身份证号'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '住户类型'),
|
||||
value: _memberType,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_memberType = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "1", child: Text('业主')),
|
||||
DropdownMenuItem(value: "2", child: Text('租户')),
|
||||
],
|
||||
validator: (value) =>
|
||||
value == null ? '请选择住户类型' : null,
|
||||
),
|
||||
],
|
||||
validator: (value) => value == null ? '请选择性别' : null,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '手机号'),
|
||||
keyboardType: TextInputType.phone,
|
||||
onSaved: (value) => _phone = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入手机号'
|
||||
: null,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: '身份证号'),
|
||||
onSaved: (value) => _idCard = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入身份证号'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '住户类型'),
|
||||
value: _memberType,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_memberType = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "1", child: Text('业主')),
|
||||
DropdownMenuItem(value: "2", child: Text('租户')),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
bottom: 0,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: _submit,
|
||||
child: const Text('保存'),
|
||||
)
|
||||
],
|
||||
validator: (value) =>
|
||||
value == null ? '请选择住户类型' : null,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _submit,
|
||||
child: const Text('保存'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -441,100 +479,116 @@ class _FamilyPersonInformationState extends State<FamilyPersonInformation> {
|
||||
title: "家庭成员详情",
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '选择房屋'),
|
||||
value: _selectedHouseId,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedHouseId = value;
|
||||
});
|
||||
},
|
||||
items: _houseList.map((house) {
|
||||
return DropdownMenuItem(
|
||||
value: house['id'].toString(),
|
||||
child: Text(house['address'] ?? '未知地址'),
|
||||
);
|
||||
}).toList(),
|
||||
validator: (value) =>
|
||||
value == null ? '请选择房屋' : null,
|
||||
),
|
||||
TextFormField(
|
||||
initialValue: _name,
|
||||
decoration: const InputDecoration(labelText: '姓名'),
|
||||
onSaved: (value) => _name = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入姓名'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '性别'),
|
||||
value: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "0", child: Text('男')),
|
||||
DropdownMenuItem(value: "1", child: Text('女')),
|
||||
],
|
||||
validator: (value) => value == null ? '请选择性别' : null,
|
||||
),
|
||||
TextFormField(
|
||||
initialValue: _phone,
|
||||
decoration: const InputDecoration(labelText: '手机号'),
|
||||
keyboardType: TextInputType.phone,
|
||||
onSaved: (value) => _phone = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入手机号'
|
||||
: null,
|
||||
),
|
||||
TextFormField(
|
||||
initialValue: _idCard,
|
||||
decoration: const InputDecoration(labelText: '身份证号'),
|
||||
onSaved: (value) => _idCard = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入身份证号'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '住户类型'),
|
||||
value: _memberType,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_memberType = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "1", child: Text('业主')),
|
||||
DropdownMenuItem(value: "2", child: Text('租户')),
|
||||
],
|
||||
validator: (value) =>
|
||||
value == null ? '请选择住户类型' : null,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
top: 0,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
OutlinedButton(
|
||||
onPressed: _deleteMember,
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.red,
|
||||
),
|
||||
child: const Text('删除家庭成员'),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '选择房屋'),
|
||||
value: _selectedHouseId,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedHouseId = value;
|
||||
});
|
||||
},
|
||||
items: _houseList.map((house) {
|
||||
return DropdownMenuItem(
|
||||
value: house['id'].toString(),
|
||||
child: Text(house['address'] ?? '未知地址'),
|
||||
);
|
||||
}).toList(),
|
||||
validator: (value) =>
|
||||
value == null ? '请选择房屋' : null,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _submit,
|
||||
child: const Text('保存'),
|
||||
const Divider(),
|
||||
TextFormField(
|
||||
initialValue: _name,
|
||||
decoration: const InputDecoration(labelText: '姓名'),
|
||||
onSaved: (value) => _name = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入姓名'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '性别'),
|
||||
value: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "0", child: Text('男')),
|
||||
DropdownMenuItem(value: "1", child: Text('女')),
|
||||
],
|
||||
validator: (value) => value == null ? '请选择性别' : null,
|
||||
),
|
||||
TextFormField(
|
||||
initialValue: _phone,
|
||||
decoration: const InputDecoration(labelText: '手机号'),
|
||||
keyboardType: TextInputType.phone,
|
||||
onSaved: (value) => _phone = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入手机号'
|
||||
: null,
|
||||
),
|
||||
TextFormField(
|
||||
initialValue: _idCard,
|
||||
decoration: const InputDecoration(labelText: '身份证号'),
|
||||
onSaved: (value) => _idCard = value,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? '请输入身份证号'
|
||||
: null,
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(labelText: '住户类型'),
|
||||
value: _memberType,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_memberType = value;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(value: "1", child: Text('业主')),
|
||||
DropdownMenuItem(value: "2", child: Text('租户')),
|
||||
],
|
||||
validator: (value) =>
|
||||
value == null ? '请选择住户类型' : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
bottom: 0,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
onPressed: _deleteMember,
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.red,
|
||||
),
|
||||
child: const Text('删除家庭成员'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _submit,
|
||||
child: const Text('保存'),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ class SocialPage extends StatefulWidget {
|
||||
|
||||
class _SocialPageState extends State<SocialPage> {
|
||||
List<Map<String, dynamic>> posts = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -91,6 +92,7 @@ class _SocialPageState extends State<SocialPage> {
|
||||
final data = json.decode(response.body);
|
||||
setState(() {
|
||||
posts = List<Map<String, dynamic>>.from(data['rows']);
|
||||
_isLoading = false;
|
||||
});
|
||||
} else {
|
||||
throw Exception('Failed to load posts');
|
||||
@ -103,13 +105,12 @@ class _SocialPageState extends State<SocialPage> {
|
||||
appBar: AppBar(
|
||||
title: const Text("友邻社交"),
|
||||
),
|
||||
body: GridView.builder(
|
||||
body: _isLoading ? const Center(child: CircularProgressIndicator()) : GridView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 0.75,
|
||||
crossAxisSpacing: 10.0,
|
||||
mainAxisSpacing: 10.0,
|
||||
),
|
||||
itemCount: posts.length,
|
||||
itemBuilder: (context, index) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user