Seperated list on dashboard
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:briessenchecker/services/scaffold_messenger.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../services/profile_provider.dart';
|
||||||
|
|
||||||
class DashboardPage extends StatefulWidget {
|
class DashboardPage extends StatefulWidget {
|
||||||
const DashboardPage({super.key});
|
const DashboardPage({super.key});
|
||||||
|
|
||||||
@@ -19,6 +21,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
Future<List<Checklist>> checklistFuture = DbHelper.fetchChecklist;
|
Future<List<Checklist>> checklistFuture = DbHelper.fetchChecklist;
|
||||||
late List<Checklist> checklists;
|
late List<Checklist> checklists;
|
||||||
late ChecklistProvider checklistProvider;
|
late ChecklistProvider checklistProvider;
|
||||||
|
late ProfileProvider profileProvider;
|
||||||
late Stream<List<Map<String, dynamic>>> clChangeStream;
|
late Stream<List<Map<String, dynamic>>> clChangeStream;
|
||||||
|
|
||||||
int? _selectedChecklistIndex;
|
int? _selectedChecklistIndex;
|
||||||
@@ -56,7 +59,16 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
Checklist cl = list.elementAt(index);
|
Checklist cl = list.elementAt(index);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(cl.title == '' ? 'Unnamed ${cl.id}' : cl.title),
|
title: Text(cl.title == '' ? 'Unnamed ${cl.id}' : cl.title),
|
||||||
subtitle: Text(cl.description),
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(cl.description),
|
||||||
|
Text(
|
||||||
|
profileProvider.getProfileById(cl.ownerId)?.username ?? '',
|
||||||
|
style: const TextStyle(color: Colors.grey),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
onTap: () => _onListEntryTapped(cl, index),
|
onTap: () => _onListEntryTapped(cl, index),
|
||||||
onLongPress: () => _onLongPress(index),
|
onLongPress: () => _onLongPress(index),
|
||||||
selected: _selectedChecklistIndex == index,
|
selected: _selectedChecklistIndex == index,
|
||||||
@@ -102,6 +114,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
checklistProvider = Provider.of<ChecklistProvider>(context, listen: true);
|
checklistProvider = Provider.of<ChecklistProvider>(context, listen: true);
|
||||||
|
profileProvider = Provider.of<ProfileProvider>(context, listen: false);
|
||||||
clChangeStream = DbHelper.checklistChangeEventStream;
|
clChangeStream = DbHelper.checklistChangeEventStream;
|
||||||
clChangeStream.listen(_onClChanged);
|
clChangeStream.listen(_onClChanged);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -133,9 +146,16 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
checklists = DbHelper.resToChecklistList(snapshot.data!);
|
checklists = DbHelper.resToChecklistList(snapshot.data!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.separated(
|
||||||
itemCount: checklists.length,
|
itemCount: checklists.length,
|
||||||
itemBuilder: (context, index) => _listBuilder(context, index, checklists),
|
itemBuilder: (context, index) =>
|
||||||
);
|
_listBuilder(context, index, checklists),
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return const Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15.0),
|
||||||
|
child: Divider(),
|
||||||
|
));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user