simple dashboard
This commit is contained in:
12
lib/assets/example_data.dart
Normal file
12
lib/assets/example_data.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:briessenchecker/models/checklist.dart';
|
||||||
|
|
||||||
|
List<Checklist> checklists = [
|
||||||
|
Checklist(
|
||||||
|
1,
|
||||||
|
'trsienaeistnraie',
|
||||||
|
'Test1',
|
||||||
|
'tiersntiersntsrien',
|
||||||
|
DateTime.now(),
|
||||||
|
List.empty(),
|
||||||
|
)
|
||||||
|
];
|
||||||
@@ -1,13 +1,46 @@
|
|||||||
|
import 'package:briessenchecker/models/checklist.dart';
|
||||||
|
import 'package:briessenchecker/services/dbhelper.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class DashboardPage extends StatelessWidget {
|
class DashboardPage extends StatefulWidget {
|
||||||
const DashboardPage({super.key});
|
const DashboardPage({super.key});
|
||||||
static const routeName = '/dashboard';
|
static const routeName = '/dashboard';
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DashboardPage> createState() => _DashboardPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DashboardPageState extends State<DashboardPage> {
|
||||||
|
final Future<List<Checklist>> checklistFuture = DbHelper.fetchChecklist;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Text('Dash'),
|
body: FutureBuilder(
|
||||||
|
future: checklistFuture,
|
||||||
|
builder: _futureBuilder,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _futureBuilder(
|
||||||
|
BuildContext context, AsyncSnapshot<List<Checklist>> snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: snapshot.data!.length,
|
||||||
|
itemBuilder: (context, index) =>
|
||||||
|
_listBuilder(context, index, snapshot.data!),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _listBuilder(BuildContext context, int index, List<Checklist> list) {
|
||||||
|
Checklist cl = list.elementAt(index);
|
||||||
|
return ListTile(
|
||||||
|
title: Text(cl.title),
|
||||||
|
subtitle: Text(cl.description),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
import '../assets/example_data.dart' as ed;
|
||||||
|
import '../models/checklist.dart';
|
||||||
|
|
||||||
class DbHelper {
|
class DbHelper {
|
||||||
static late final SupabaseClient _client;
|
static late final SupabaseClient _client;
|
||||||
@@ -20,6 +22,12 @@ class DbHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<List<Checklist>> get fetchChecklist async {
|
||||||
|
//TODO replace example data
|
||||||
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
|
return ed.checklists;
|
||||||
|
}
|
||||||
|
|
||||||
static Stream<AuthState> get authChangeEventStream =>
|
static Stream<AuthState> get authChangeEventStream =>
|
||||||
_client.auth.onAuthStateChange;
|
_client.auth.onAuthStateChange;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user