초기 커밋
This commit is contained in:
166
lib/features/user/presentation/screens/user_home_screen.dart
Normal file
166
lib/features/user/presentation/screens/user_home_screen.dart
Normal file
@@ -0,0 +1,166 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
import '../../../../core/utils/extensions.dart';
|
||||
import '../../../../shared/providers/auth_provider.dart';
|
||||
|
||||
class UserHomeScreen extends ConsumerWidget {
|
||||
const UserHomeScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authStateProvider);
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 환영 메시지
|
||||
authState.when(
|
||||
data: (user) => Text(
|
||||
'안녕하세요, ${user?.name ?? '사용자'}님!',
|
||||
style: context.textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
loading: () => const SizedBox.shrink(),
|
||||
error: (_, __) => const SizedBox.shrink(),
|
||||
),
|
||||
const Gap(8),
|
||||
Text(
|
||||
'오늘의 요약을 확인하세요',
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: context.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
// 요약 카드 그리드
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final crossAxisCount = context.isDesktop
|
||||
? 4
|
||||
: context.isTablet
|
||||
? 2
|
||||
: 1;
|
||||
return GridView.count(
|
||||
crossAxisCount: crossAxisCount,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 1.8,
|
||||
children: const [
|
||||
_SummaryCard(
|
||||
title: '진행중 작업',
|
||||
value: '12',
|
||||
icon: Icons.pending_actions,
|
||||
color: Colors.blue,
|
||||
),
|
||||
_SummaryCard(
|
||||
title: '완료된 작업',
|
||||
value: '48',
|
||||
icon: Icons.check_circle_outline,
|
||||
color: Colors.green,
|
||||
),
|
||||
_SummaryCard(
|
||||
title: '알림',
|
||||
value: '3',
|
||||
icon: Icons.notifications_outlined,
|
||||
color: Colors.orange,
|
||||
),
|
||||
_SummaryCard(
|
||||
title: '메시지',
|
||||
value: '7',
|
||||
icon: Icons.mail_outlined,
|
||||
color: Colors.purple,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
// 최근 활동
|
||||
Text(
|
||||
'최근 활동',
|
||||
style: context.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Card(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: 5,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
context.colorScheme.primaryContainer,
|
||||
child: Icon(
|
||||
Icons.task_alt,
|
||||
color: context.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
title: Text('활동 항목 ${index + 1}'),
|
||||
subtitle: Text('${index + 1}시간 전'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SummaryCard extends StatelessWidget {
|
||||
const _SummaryCard({
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Icon(icon, color: color, size: 24),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
172
lib/features/user/presentation/screens/user_profile_screen.dart
Normal file
172
lib/features/user/presentation/screens/user_profile_screen.dart
Normal file
@@ -0,0 +1,172 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
import '../../../../core/utils/extensions.dart';
|
||||
import '../../../../shared/providers/auth_provider.dart';
|
||||
|
||||
class UserProfileScreen extends ConsumerWidget {
|
||||
const UserProfileScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authStateProvider);
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'프로필',
|
||||
style: context.textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
// 프로필 카드
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: authState.when(
|
||||
data: (user) => Column(
|
||||
children: [
|
||||
// 아바타
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor:
|
||||
context.colorScheme.primaryContainer,
|
||||
child: Text(
|
||||
(user?.name ?? 'U').substring(0, 1).toUpperCase(),
|
||||
style: context.textTheme.headlineLarge?.copyWith(
|
||||
color: context.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Text(
|
||||
user?.name ?? '사용자',
|
||||
style: context.textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
user?.email ?? '',
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: context.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
Chip(
|
||||
label: Text(
|
||||
user?.role.value.toUpperCase() ?? 'USER',
|
||||
),
|
||||
backgroundColor:
|
||||
context.colorScheme.secondaryContainer,
|
||||
),
|
||||
const Gap(32),
|
||||
const Divider(),
|
||||
const Gap(16),
|
||||
|
||||
// 프로필 정보 목록
|
||||
_ProfileInfoTile(
|
||||
icon: Icons.person_outlined,
|
||||
label: '이름',
|
||||
value: user?.name ?? '-',
|
||||
),
|
||||
_ProfileInfoTile(
|
||||
icon: Icons.email_outlined,
|
||||
label: '이메일',
|
||||
value: user?.email ?? '-',
|
||||
),
|
||||
_ProfileInfoTile(
|
||||
icon: Icons.shield_outlined,
|
||||
label: '역할',
|
||||
value: user?.role.value ?? '-',
|
||||
),
|
||||
_ProfileInfoTile(
|
||||
icon: Icons.calendar_today_outlined,
|
||||
label: '가입일',
|
||||
value: user?.createdAt?.toString().split(' ').first ??
|
||||
'-',
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
// 프로필 수정 버튼
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton.icon(
|
||||
onPressed: () {
|
||||
// TODO: 프로필 수정 기능
|
||||
},
|
||||
icon: const Icon(Icons.edit),
|
||||
label: const Text('프로필 수정'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, _) => Center(
|
||||
child: Text('오류: $error'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ProfileInfoTile extends StatelessWidget {
|
||||
const _ProfileInfoTile({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const Gap(12),
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user