diff --git a/lib/components/nc_user_info.dart b/lib/components/nc_user_info.dart new file mode 100644 index 0000000..f2c71f8 --- /dev/null +++ b/lib/components/nc_user_info.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:pcastlivetv/stores/login_store.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class NcUserInfo extends StatelessWidget { + const NcUserInfo({super.key}); + + @override + Widget build(BuildContext context) { + LoginStore store = VxState.store as LoginStore; + + return Card( + child: Container( + padding: const EdgeInsets.all(10), + child: Row( + children: [ + const SizedBox(width: 10), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + store.userName!, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + Text( + store.userType! == 'A' + ? 'Administrador' + : store.userType! == 'R' + ? 'Revendedor' + : 'User', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w300, + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/admin_page.dart b/lib/pages/admin_page.dart index b47ab6f..5432957 100644 --- a/lib/pages/admin_page.dart +++ b/lib/pages/admin_page.dart @@ -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 createState() => AdminPageState(); +} + +class AdminPageState extends State { + LoginStore store = VxState.store as LoginStore; + + int _selectedIndex = 0; + List items = []; + List 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, + ), + ), + ), + ), + ]; + }); + // } + } } diff --git a/lib/views/admin/servers_view.dart b/lib/views/admin/servers_view.dart new file mode 100644 index 0000000..e6012d9 --- /dev/null +++ b/lib/views/admin/servers_view.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +class ServersView extends StatefulWidget { + const ServersView({super.key}); + + @override + State createState() => _ServersViewState(); +} + +class _ServersViewState extends State { + @override + Widget build(BuildContext context) { + return Container( + color: const Color.fromRGBO(166, 0, 249, 1), + child: const Center( + child: Text( + 'Servers', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + ); + } +} diff --git a/lib/views/admin/users_view.dart b/lib/views/admin/users_view.dart new file mode 100644 index 0000000..8ba2756 --- /dev/null +++ b/lib/views/admin/users_view.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +class UsersView extends StatefulWidget { + const UsersView({super.key}); + + @override + State createState() => _UsersViewState(); +} + +class _UsersViewState extends State { + @override + Widget build(BuildContext context) { + return Container( + color: const Color.fromRGBO(166, 0, 249, 1), + child: const Center( + child: Text( + 'Users', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + ); + } +}