Side menu now shows everything that stored in db
And it's clickable Tracking ability soon
This commit is contained in:
parent
ff04c27edb
commit
ae14e1789c
|
@ -75,7 +75,6 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
//teto = TetrioService();
|
|
||||||
teto.open();
|
teto.open();
|
||||||
_scrollController = ScrollController();
|
_scrollController = ScrollController();
|
||||||
_tabController = TabController(length: 4, vsync: this);
|
_tabController = TabController(length: 4, vsync: this);
|
||||||
|
@ -88,7 +87,6 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_tabController.dispose();
|
_tabController.dispose();
|
||||||
_scrollController.dispose();
|
_scrollController.dispose();
|
||||||
//db.close();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
developer.log("Main view disposed", name: "main_view");
|
developer.log("Main view disposed", name: "main_view");
|
||||||
}
|
}
|
||||||
|
@ -105,20 +103,6 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// _scrollListener() {
|
|
||||||
// if (fixedScroll) {
|
|
||||||
// _scrollController.jumpTo(0);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _smoothScrollToTop() {
|
|
||||||
// _scrollController.animateTo(
|
|
||||||
// 0,
|
|
||||||
// duration: const Duration(microseconds: 300),
|
|
||||||
// curve: Curves.ease,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -257,45 +241,80 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NavDrawer extends StatelessWidget {
|
class NavDrawer extends StatefulWidget {
|
||||||
final Function changePlayer;
|
final Function changePlayer;
|
||||||
|
|
||||||
const NavDrawer(this.changePlayer, {super.key});
|
const NavDrawer(this.changePlayer, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NavDrawer> createState() => _NavDrawerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NavDrawerState extends State<NavDrawer> {
|
||||||
|
late ScrollController _scrollController;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_scrollController = ScrollController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
child: StreamBuilder(
|
||||||
padding: EdgeInsets.zero,
|
stream: teto.allPlayers,
|
||||||
children: <Widget>[
|
builder: (context, snapshot) {
|
||||||
const DrawerHeader(
|
switch (snapshot.connectionState) {
|
||||||
child: Text(
|
case ConnectionState.none:
|
||||||
'Players you track',
|
return Center(child: Text('none case of StreamBuilder'));
|
||||||
style: TextStyle(color: Colors.white, fontSize: 25),
|
case ConnectionState.waiting:
|
||||||
)),
|
case ConnectionState.active:
|
||||||
ListTile(
|
final allPlayers = (snapshot.data != null) ? snapshot.data as Map<String, List<TetrioPlayer>> : <String, List<TetrioPlayer>>{};
|
||||||
leading: const Icon(Icons.home),
|
List<String> keys = allPlayers.keys.toList();
|
||||||
title: Text(prefs.getString("player") ?? "dan63047"),
|
return NestedScrollView(
|
||||||
onTap: () {
|
headerSliverBuilder: (context, value) {
|
||||||
developer.log("Navigator changed player", name: "main_view");
|
return [
|
||||||
changePlayer(prefs.getString("player") ?? "dan63047");
|
const SliverToBoxAdapter(
|
||||||
Navigator.of(context).pop();
|
child: DrawerHeader(
|
||||||
},
|
child: Text(
|
||||||
),
|
'Players you track',
|
||||||
StreamBuilder(
|
style: TextStyle(color: Colors.white, fontSize: 25),
|
||||||
stream: teto.allPlayers,
|
))),
|
||||||
builder: (context, snapshot) {
|
SliverToBoxAdapter(
|
||||||
switch (snapshot.connectionState) {
|
child: ListTile(
|
||||||
case ConnectionState.none:
|
leading: const Icon(Icons.home),
|
||||||
return Center(child: Text('none case of StreamBuilder'));
|
title: Text(prefs.getString("player") ?? "dan63047"),
|
||||||
case ConnectionState.waiting:
|
onTap: () {
|
||||||
case ConnectionState.active:
|
developer.log("Navigator changed player", name: "main_view");
|
||||||
return Center(child: Text('${snapshot.data}'));
|
widget.changePlayer(prefs.getString("player") ?? "dan63047");
|
||||||
case ConnectionState.done:
|
Navigator.of(context).pop();
|
||||||
return Center(child: Text('done case of StreamBuilder'));
|
},
|
||||||
}
|
),
|
||||||
},
|
)
|
||||||
)
|
];
|
||||||
],
|
},
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: allPlayers.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(allPlayers[keys[index]]?.last.username as String),
|
||||||
|
onTap: () {
|
||||||
|
developer.log("Navigator changed player", name: "main_view");
|
||||||
|
widget.changePlayer(keys[index]);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
case ConnectionState.done:
|
||||||
|
return Center(child: Text('done case of StreamBuilder'));
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue