82 lines
3.2 KiB
Dart
82 lines
3.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:rogapp/model/destination.dart';
|
|
import 'package:rogapp/utils/database_helper.dart';
|
|
|
|
class HistoryPage extends StatefulWidget {
|
|
const HistoryPage({super.key});
|
|
|
|
@override
|
|
State<HistoryPage> createState() => _HistoryPageState();
|
|
}
|
|
|
|
class _HistoryPageState extends State<HistoryPage> {
|
|
DatabaseHelper db = DatabaseHelper.instance;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("History"),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
FutureBuilder(
|
|
future: db.getDestinations(),
|
|
builder: (BuildContext context,
|
|
AsyncSnapshot<List<Destination>> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text(
|
|
'${snapshot.error} occurred',
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
);
|
|
} else if (snapshot.hasData) {
|
|
final dests = snapshot.data;
|
|
if (dests!.length > 0) {
|
|
print("----- history -----");
|
|
return Container(
|
|
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!} ----");
|
|
return ListTile(
|
|
title: Text(dests[index].name ?? ""),
|
|
subtitle:
|
|
Text(dests[index].address ?? ""),
|
|
leading: dests[index].checkin_image != null
|
|
? Container(width: 100, height: 100, child: Image.file(File(dests[index].checkin_image!)))
|
|
: Container(),
|
|
trailing: ElevatedButton(
|
|
child: Text(dests[index].cp.toString()),
|
|
style: ElevatedButton.styleFrom(shape: CircleBorder()),
|
|
onPressed: () {
|
|
|
|
},),
|
|
);
|
|
}));
|
|
} else {
|
|
return Center(child: Text("No checkin yet"));
|
|
}
|
|
}
|
|
} else if (snapshot.connectionState ==
|
|
ConnectionState.waiting) {
|
|
return Center(
|
|
child: CircularProgressIndicator(),
|
|
);
|
|
}
|
|
return Container();
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|