pcastlivetv/lib/pages/admin_page.dart

108 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pcastlivetv/components/nc_user_info.dart';
import 'package:pcastlivetv/views/admin/servers_view.dart';
import 'package:pcastlivetv/views/admin/users_view.dart';
import 'package:velocity_x/velocity_x.dart';
import '../stores/login_store.dart';
class AdminPage extends StatefulWidget {
const AdminPage({super.key});
@override
State<StatefulWidget> createState() => AdminPageState();
}
class AdminPageState extends State<AdminPage> {
LoginStore store = VxState.store as LoginStore;
int _selectedIndex = 0;
List<NavigationRailDestination> items = [];
List<Widget> views = [];
@override
Widget build(BuildContext context) {
VxState.watch(context, on: [AuthLogged]);
getViews();
getItems();
return Scaffold(
body: Row(
children: [
NavigationRail(
selectedIndex: _selectedIndex,
elevation: 20,
extended: true,
selectedIconTheme: const IconThemeData(color: Colors.white, size: 32),
unselectedIconTheme: const IconThemeData(color: Colors.white, size: 32),
backgroundColor: Colors.grey[600],
labelType: NavigationRailLabelType.none,
useIndicator: false,
selectedLabelTextStyle: const TextStyle(color: Colors.white),
unselectedLabelTextStyle: const TextStyle(color: Colors.white),
leading: const NcUserInfo(),
destinations: items,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
),
Expanded(
child: views[_selectedIndex],
),
],
),
);
}
getItems() {
// if (store.isLogged) {
setState(() {
items = [
const NavigationRailDestination(icon: Icon(Icons.computer, color: Colors.white), label: Text('Servers')),
const NavigationRailDestination(icon: Icon(Icons.verified_user, color: Colors.white), label: Text('Users')),
const NavigationRailDestination(icon: Icon(Icons.settings, color: Colors.white), label: Text('Settings')),
const NavigationRailDestination(icon: Icon(Icons.logout, color: Colors.white), label: Text('Logout')),
];
});
// }
}
getViews() {
// if (store.isLogged) {
setState(() {
views = [
const ServersView(),
const UsersView(),
Container(
color: const Color.fromRGBO(166, 0, 249, 1),
child: const Center(
child: Text(
'Settings',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
),
),
Container(
color: const Color.fromRGBO(166, 0, 249, 1),
child: const Center(
child: Text(
'Logout',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
),
),
];
});
// }
}
}