♻️ Refactored and joined the Solar Network
This commit is contained in:
@ -12,8 +12,8 @@ class NameCard extends StatelessWidget {
|
||||
final void Function()? onCheck;
|
||||
|
||||
Future<CircleAvatar> _getAvatar() async {
|
||||
if (await AuthGuard().isAuthorized()) {
|
||||
final profiles = await AuthGuard().readProfiles();
|
||||
if (await authClient.isAuthorized()) {
|
||||
final profiles = await authClient.readProfiles();
|
||||
return CircleAvatar(backgroundImage: NetworkImage(profiles["picture"]));
|
||||
} else {
|
||||
return const CircleAvatar(child: Icon(Icons.account_circle));
|
||||
@ -21,8 +21,8 @@ class NameCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<Column> _getDescribe() async {
|
||||
if (await AuthGuard().isAuthorized()) {
|
||||
final profiles = await AuthGuard().readProfiles();
|
||||
if (await authClient.isAuthorized()) {
|
||||
final profiles = await authClient.readProfiles();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -59,7 +59,7 @@ class NameCard extends StatelessWidget {
|
||||
child: InkWell(
|
||||
splashColor: Colors.indigo.withAlpha(30),
|
||||
onTap: () async {
|
||||
if (await AuthGuard().isAuthorized() && onCheck != null) {
|
||||
if (await authClient.isAuthorized() && onCheck != null) {
|
||||
onCheck!();
|
||||
} else if (onLogin != null) {
|
||||
onLogin!();
|
||||
|
38
lib/widgets/navigation.dart
Normal file
38
lib/widgets/navigation.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:solaragent/router.dart';
|
||||
|
||||
class AgentNavigation extends StatefulWidget {
|
||||
const AgentNavigation({super.key});
|
||||
|
||||
static const List<(String, NavigationDestination)> destinations = [
|
||||
('/', NavigationDestination(icon: Icon(Icons.home), label: 'Home')),
|
||||
('/notifications', NavigationDestination(icon: Icon(Icons.notifications), label: 'Notifications')),
|
||||
('/account', NavigationDestination(icon: Icon(Icons.account_circle), label: 'Account')),
|
||||
];
|
||||
|
||||
@override
|
||||
State<AgentNavigation> createState() => _AgentNavigationState();
|
||||
}
|
||||
|
||||
class _AgentNavigationState extends State<AgentNavigation> {
|
||||
int currentPage = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigationBar(
|
||||
selectedIndex: currentPage,
|
||||
destinations: AgentNavigation.destinations
|
||||
.map(((String, NavigationDestination) e) => e.$2)
|
||||
.toList(),
|
||||
onDestinationSelected: (index) {
|
||||
router.go(AgentNavigation.destinations[index].$1);
|
||||
setState(() => currentPage = index);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user