|
|
@@ -1,11 +1,11 @@
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
+import 'package:physigo/Services/logged_in_user.dart';
|
|
|
import 'Services/AuthService.dart';
|
|
|
|
|
|
class CurrentUser extends StatefulWidget {
|
|
|
- const CurrentUser( {
|
|
|
- required this.name, Key? key}):super(key: key);
|
|
|
+ const CurrentUser({required this.name, Key? key}) : super(key: key);
|
|
|
final String name;
|
|
|
@override
|
|
|
State<CurrentUser> createState() => _CurrentUserState();
|
|
|
@@ -13,20 +13,19 @@ class CurrentUser extends StatefulWidget {
|
|
|
|
|
|
class _CurrentUserState extends State<CurrentUser> {
|
|
|
final AuthenticationServices _auth = AuthenticationServices();
|
|
|
- late dynamic user = _auth.getCurrentUser();
|
|
|
+ late Future<LoggedInUser?> user = AuthenticationServices.getCurrentUser();
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return FutureBuilder<dynamic>(
|
|
|
+ return FutureBuilder<LoggedInUser?>(
|
|
|
future: user,
|
|
|
builder: (context, snapshot) {
|
|
|
- if(snapshot.connectionState == ConnectionState.waiting){
|
|
|
+ if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
return const Text('Wait a moment');
|
|
|
- }
|
|
|
- else if(snapshot.connectionState == ConnectionState.done) {
|
|
|
- dynamic user2 = snapshot.data.docs[0];
|
|
|
+ } else if (snapshot.connectionState == ConnectionState.done) {
|
|
|
+ LoggedInUser user2 = snapshot.data!;
|
|
|
// DatabaseManager manager = DatabaseManager(widget.name);
|
|
|
- Stream<int> place = _auth.getPlace(user2);
|
|
|
+ Stream<int> place = AuthenticationServices.getPlace(user2);
|
|
|
return Row(
|
|
|
children: [
|
|
|
SizedBox(
|
|
|
@@ -36,29 +35,28 @@ class _CurrentUserState extends State<CurrentUser> {
|
|
|
SizedBox(
|
|
|
height: 100,
|
|
|
width: 50,
|
|
|
- child: StreamBuilder(
|
|
|
- stream: place,
|
|
|
- builder: (context, snapshot){
|
|
|
- return Text(
|
|
|
- "${snapshot.data}");
|
|
|
- },
|
|
|
- ),
|
|
|
+ child: StreamBuilder(
|
|
|
+ stream: place,
|
|
|
+ builder: (context, snapshot) {
|
|
|
+ return Text("${snapshot.data}");
|
|
|
+ },
|
|
|
+ ),
|
|
|
),
|
|
|
SizedBox(
|
|
|
height: 100,
|
|
|
width: 135,
|
|
|
- child: Text(user2["shared_id"]),
|
|
|
+ child: Text(user2.sharedId),
|
|
|
),
|
|
|
SizedBox(
|
|
|
height: 100,
|
|
|
width: 60,
|
|
|
- child: Text(user2["name"]),
|
|
|
- ),
|
|
|
- SizedBox(
|
|
|
- height: 100,
|
|
|
- width: 50,
|
|
|
- child: Text("${user2[widget.name]}"),
|
|
|
+ child: Text(user2.name),
|
|
|
),
|
|
|
+ // SizedBox(
|
|
|
+ // height: 100,
|
|
|
+ // width: 50,
|
|
|
+ // child: Text("${user2[widget.name]}"),
|
|
|
+ // ),
|
|
|
],
|
|
|
);
|
|
|
}
|