ponshu-room-lite/lib/widgets/gamification/level_title_card.dart

121 lines
4.1 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../providers/theme_provider.dart';
import 'package:google_fonts/google_fonts.dart';
class LevelTitleCard extends ConsumerWidget {
const LevelTitleCard({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final userProfile = ref.watch(userProfileProvider);
final totalExp = userProfile.totalExp;
final level = userProfile.level;
final title = userProfile.title;
final progress = userProfile.nextLevelProgress;
final expToNext = userProfile.expToNextLevel;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
border: Border.all(
color: Theme.of(context).dividerColor.withValues(alpha: 0.1),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'現在の称号',
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
title,
style: GoogleFonts.zenOldMincho(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Theme.of(context).primaryColor,
),
),
],
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Theme.of(context).primaryColor.withValues(alpha: 0.3)),
),
child: Text(
'Lv.$level',
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 16,
color: Theme.of(context).primaryColor,
),
),
),
],
),
const SizedBox(height: 20),
// Progress Bar
ClipRRect(
borderRadius: BorderRadius.circular(4),
child: LinearProgressIndicator(
value: progress,
minHeight: 8,
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
),
),
const SizedBox(height: 8),
// EXP Text
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Total EXP: $totalExp',
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
Text(
expToNext > 0 ? '次のレベルまで: ${expToNext}exp' : 'Max Level',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
);
}
}