105 lines
3.0 KiB
Dart
105 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import '../../features/auth/presentation/bloc/auth_bloc.dart';
|
|
import '../../features/auth/presentation/bloc/auth_state.dart';
|
|
import '../../features/auth/presentation/pages/login_page.dart';
|
|
import '../../features/settings/presentation/pages/settings_page.dart';
|
|
import '../router/chats_placeholder.dart';
|
|
|
|
class MainScreen extends StatefulWidget {
|
|
static const String routeName = '/main';
|
|
|
|
const MainScreen({super.key});
|
|
|
|
@override
|
|
State<MainScreen> createState() => _MainScreenState();
|
|
}
|
|
|
|
class _MainScreenState extends State<MainScreen> {
|
|
int _currentIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _currentIndex,
|
|
children: const [
|
|
ChatsTab(),
|
|
ContactsTab(),
|
|
SettingsTab(),
|
|
],
|
|
),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: _currentIndex,
|
|
onTap: (index) => setState(() => _currentIndex = index),
|
|
type: BottomNavigationBarType.fixed,
|
|
items: const [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.chat_bubble_outline),
|
|
activeIcon: Icon(Icons.chat_bubble),
|
|
label: 'Чаты',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.contacts_outlined),
|
|
activeIcon: Icon(Icons.contacts),
|
|
label: 'Контакты',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.settings_outlined),
|
|
activeIcon: Icon(Icons.settings),
|
|
label: 'Настройки',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatsTab extends StatelessWidget {
|
|
const ChatsTab({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const ChatsPage();
|
|
}
|
|
}
|
|
|
|
class ContactsTab extends StatelessWidget {
|
|
const ContactsTab({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(Icons.contacts_outlined, size: 64, color: Colors.grey),
|
|
SizedBox(height: 16),
|
|
Text('Контакты', style: TextStyle(fontSize: 18)),
|
|
SizedBox(height: 8),
|
|
Text('Функция в разработке', style: TextStyle(color: Colors.grey)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SettingsTab extends StatelessWidget {
|
|
const SettingsTab({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, authState) {
|
|
return authState.when(
|
|
initial: () => const Center(child: CircularProgressIndicator()),
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
authenticated: (_) => const SettingsPage(),
|
|
unauthenticated: () => const LoginPage(),
|
|
error: (_) => const LoginPage(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|