feat: deploy infrastructure + disk/drive, calendar, presentation, workspaces, onboarding, demo user
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../providers/workspace_provider.dart';
|
||||
import '../../../providers/ideas_provider.dart';
|
||||
import '../../../widgets/loading_indicator.dart';
|
||||
import '../../../widgets/empty_state.dart';
|
||||
import '../../../models/workspace.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
|
||||
class WorkspaceDetailScreen extends ConsumerStatefulWidget {
|
||||
final String id;
|
||||
|
||||
const WorkspaceDetailScreen({super.key, required this.id});
|
||||
|
||||
@override
|
||||
ConsumerState<WorkspaceDetailScreen> createState() =>
|
||||
_WorkspaceDetailScreenState();
|
||||
}
|
||||
|
||||
class _WorkspaceDetailScreenState
|
||||
extends ConsumerState<WorkspaceDetailScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(() {
|
||||
ref.read(workspaceProvider.notifier).loadMembers(widget.id);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final wsState = ref.watch(workspaceProvider);
|
||||
final wsNotifier = ref.read(workspaceProvider.notifier);
|
||||
final workspace = wsState.workspaces.where((w) => w.id == widget.id).firstOrNull;
|
||||
|
||||
if (workspace == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const LoadingIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(workspace.name),
|
||||
actions: [
|
||||
if (workspace.isTeam)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.person_add),
|
||||
onPressed: () => _showAddMemberDialog(context, wsNotifier),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
if (workspace.description != null)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
color: VoIdeaColors.surface,
|
||||
child: Text(workspace.description!),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.people, size: 20, color: VoIdeaColors.muted),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Участники (${wsState.members.length})',
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: wsState.members.isEmpty
|
||||
? const EmptyState(
|
||||
icon: Icons.people_outline,
|
||||
title: 'Нет участников',
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: wsState.members.length,
|
||||
itemBuilder: (_, i) {
|
||||
final member = wsState.members[i];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
VoIdeaColors.primary.withOpacity(0.1),
|
||||
child: Text(
|
||||
member.userName.isNotEmpty
|
||||
? member.userName[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(
|
||||
color: VoIdeaColors.primary),
|
||||
),
|
||||
),
|
||||
title: Text(member.userName),
|
||||
subtitle: Text(member.userEmail,
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
trailing: Chip(
|
||||
label: Text(
|
||||
member.role,
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showAddMemberDialog(
|
||||
BuildContext context, WorkspaceNotifier notifier) {
|
||||
final emailController = TextEditingController();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Добавить участника'),
|
||||
content: TextField(
|
||||
controller: emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
hintText: 'email@example.com',
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Отмена'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (emailController.text.isNotEmpty) {
|
||||
notifier.addMember(widget.id, emailController.text.trim(), 'member');
|
||||
Navigator.pop(ctx);
|
||||
}
|
||||
},
|
||||
child: const Text('Добавить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../providers/workspace_provider.dart';
|
||||
import '../../../widgets/loading_indicator.dart';
|
||||
import '../../../widgets/empty_state.dart';
|
||||
import '../../../models/workspace.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
|
||||
class WorkspaceListScreen extends ConsumerStatefulWidget {
|
||||
const WorkspaceListScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<WorkspaceListScreen> createState() =>
|
||||
_WorkspaceListScreenState();
|
||||
}
|
||||
|
||||
class _WorkspaceListScreenState extends ConsumerState<WorkspaceListScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(
|
||||
() => ref.read(workspaceProvider.notifier).loadWorkspaces());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(workspaceProvider);
|
||||
final notifier = ref.read(workspaceProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Рабочие пространства'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => _showCreateDialog(context, notifier),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: state.isLoading
|
||||
? const LoadingIndicator()
|
||||
: state.workspaces.isEmpty
|
||||
? EmptyState(
|
||||
icon: Icons.workspaces_outline,
|
||||
title: 'Нет рабочих пространств',
|
||||
actionLabel: 'Создать',
|
||||
onAction: () =>
|
||||
_showCreateDialog(context, notifier),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: notifier.loadWorkspaces,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: state.workspaces.length,
|
||||
itemBuilder: (_, i) {
|
||||
final ws = state.workspaces[i];
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: ws.isTeam
|
||||
? VoIdeaColors.secondary.withOpacity(0.1)
|
||||
: VoIdeaColors.primary.withOpacity(0.1),
|
||||
child: Icon(
|
||||
ws.isTeam
|
||||
? Icons.groups
|
||||
: Icons.person,
|
||||
color: ws.isTeam
|
||||
? VoIdeaColors.secondary
|
||||
: VoIdeaColors.primary,
|
||||
),
|
||||
),
|
||||
title: Text(ws.name),
|
||||
subtitle: Text(
|
||||
'${ws.isTeam ? 'Командное' : 'Личное'} · ${ws.memberCount} участников',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
trailing: Chip(
|
||||
label: Text(
|
||||
ws.isPersonal ? 'Личное' : 'Команда',
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
await notifier.selectWorkspace(ws);
|
||||
if (mounted) context.pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showCreateDialog(
|
||||
BuildContext context, WorkspaceNotifier notifier) {
|
||||
final nameController = TextEditingController();
|
||||
final descController = TextEditingController();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Создать пространство'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: nameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Название',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: descController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Описание (необязательно)',
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Отмена'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
if (nameController.text.isNotEmpty) {
|
||||
await notifier.createWorkspace(CreateWorkspaceRequest(
|
||||
name: nameController.text.trim(),
|
||||
description: descController.text.trim(),
|
||||
));
|
||||
if (ctx.mounted) Navigator.pop(ctx);
|
||||
}
|
||||
},
|
||||
child: const Text('Создать'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user