Load profile information on startup
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:moneymgr_mobile/services/api/api_client.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
|
||||
class ProfileScreen extends HookConsumerWidget {
|
||||
@ -8,7 +9,60 @@ class ProfileScreen extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final data = ref.watch(prefsProvider);
|
||||
final api = ref.watch(apiServiceProvider);
|
||||
if (data.value == null) return CircularProgressIndicator();
|
||||
return Text("dd\n\n\n${data.value!.serverConfig()}");
|
||||
|
||||
final profile = data.value?.authInfo();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Profile")),
|
||||
body: ListView(
|
||||
children: [
|
||||
ListEntry(
|
||||
title: "Server URL",
|
||||
value: api?.token.apiUrl,
|
||||
icon: Icons.link,
|
||||
),
|
||||
ListEntry(
|
||||
title: "Token ID",
|
||||
value: api?.token.tokenId.toString(),
|
||||
icon: Icons.key,
|
||||
),
|
||||
ListEntry(
|
||||
title: "User ID",
|
||||
value: profile?.id.toString(),
|
||||
icon: Icons.perm_contact_calendar_outlined,
|
||||
),
|
||||
ListEntry(
|
||||
title: "User name",
|
||||
value: profile?.name,
|
||||
icon: Icons.person,
|
||||
),
|
||||
ListEntry(title: "User mail", value: profile?.mail, icon: Icons.mail),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ListEntry extends StatelessWidget {
|
||||
final String title;
|
||||
final String? value;
|
||||
final IconData icon;
|
||||
|
||||
const ListEntry({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(title),
|
||||
subtitle: Text(value ?? ""),
|
||||
leading: Icon(icon),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user