optimized
This commit is contained in:
@ -18,7 +18,7 @@ class _HistoryPageState extends State<HistoryPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("通過履歴"),
|
||||
title: const Text("通過履歴"),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
@ -32,37 +32,45 @@ class _HistoryPageState extends State<HistoryPage> {
|
||||
return Center(
|
||||
child: Text(
|
||||
'${snapshot.error} occurred',
|
||||
style: TextStyle(fontSize: 18),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.hasData) {
|
||||
final dests = snapshot.data;
|
||||
if (dests!.length > 0) {
|
||||
print("----- history -----");
|
||||
return Container(
|
||||
if (dests!.isNotEmpty) {
|
||||
//print("----- history -----");
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: ListView.builder(
|
||||
itemCount: dests.length,
|
||||
itemBuilder: (ctx, index) {
|
||||
print("--- photo ${dests[index].checkin_image!} ----");
|
||||
//print("--- photo ${dests[index].checkin_image!} ----");
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CustomWidget(title: dests[index].name!,
|
||||
subtitle: "${dests[index].sub_loc_id} : ${dests[index].name}",
|
||||
image1: dests[index].checkin_image != null ? Image.file(File(dests[index].checkin_image!)) : null,
|
||||
image2: dests[index].buypoint_image != null ? Image.file(File(dests[index].buypoint_image!)) : null,
|
||||
),
|
||||
child: CustomWidget(
|
||||
title: dests[index].name!,
|
||||
subtitle:
|
||||
"${dests[index].sub_loc_id} : ${dests[index].name}",
|
||||
image1: dests[index].checkin_image != null
|
||||
? Image.file(
|
||||
File(dests[index].checkin_image!))
|
||||
: null,
|
||||
image2:
|
||||
dests[index].buypoint_image != null
|
||||
? Image.file(File(
|
||||
dests[index].buypoint_image!))
|
||||
: null,
|
||||
),
|
||||
);
|
||||
|
||||
}));
|
||||
} else {
|
||||
return Center(child: Text("No checkin yet"));
|
||||
return const Center(child: Text("No checkin yet"));
|
||||
}
|
||||
}
|
||||
} else if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return Center(
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
@ -81,7 +89,8 @@ class CustomWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
|
||||
CustomWidget({
|
||||
const CustomWidget({
|
||||
super.key,
|
||||
this.image1,
|
||||
this.image2,
|
||||
required this.title,
|
||||
@ -93,30 +102,44 @@ class CustomWidget extends StatelessWidget {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 104, // 50 (width of each image) + 2 (space between images) + 2*1 (padding on both sides)
|
||||
SizedBox(
|
||||
width:
|
||||
104, // 50 (width of each image) + 2 (space between images) + 2*1 (padding on both sides)
|
||||
child: Row(
|
||||
children: [
|
||||
if (image1 != null) SizedBox(width: 50, height: 100, child: image1,),
|
||||
if (image1 != null && image2 != null) SizedBox(width: 2),
|
||||
if (image2 != null) SizedBox(width: 50, height: 100, child: image2,),
|
||||
if (image1 != null)
|
||||
SizedBox(
|
||||
width: 50,
|
||||
height: 100,
|
||||
child: image1,
|
||||
),
|
||||
if (image1 != null && image2 != null) const SizedBox(width: 2),
|
||||
if (image2 != null)
|
||||
SizedBox(
|
||||
width: 50,
|
||||
height: 100,
|
||||
child: image2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
maxLines: null, // Allows the text to wrap onto an unlimited number of lines
|
||||
style:
|
||||
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
maxLines:
|
||||
null, // Allows the text to wrap onto an unlimited number of lines
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 16),
|
||||
maxLines: null, // Allows the text to wrap onto an unlimited number of lines
|
||||
style: const TextStyle(fontSize: 16),
|
||||
maxLines:
|
||||
null, // Allows the text to wrap onto an unlimited number of lines
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user