initial pages for admin users

This commit is contained in:
2023-08-30 19:45:31 -03:00
parent ee6e881fbf
commit a2eb8d6877
4 changed files with 195 additions and 10 deletions
+97 -10
View File
@@ -1,20 +1,107 @@
import 'package:flutter/material.dart';
import 'package:pcastlivetv/components/nc_base_page.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';
class AdminPage extends StatelessWidget {
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) {
return const NcBasePage(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Admin Page"),
],
),
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,
),
),
),
),
];
});
// }
}
}