POLISHING STUFF and Smarter AI, and alot i mean.. ALOT OF BUG FIX AND OPTIMIZE
This commit is contained in:
@@ -8,6 +8,10 @@ import '../../app/injection_container.dart';
|
||||
import '../../core/errors/friendly_error.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../../core/storage/secure_storage.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../core/theme/app_decorations.dart';
|
||||
import '../../core/theme/app_text_styles.dart';
|
||||
import '../../shared/widgets/animations/animations.dart';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UserPairingScreen
|
||||
@@ -27,37 +31,11 @@ class UserPairingScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _UserPairingScreenState extends State<UserPairingScreen> {
|
||||
String? _uniqueId;
|
||||
String? _pairingCode;
|
||||
DateTime? _pairingCodeExpiresAt;
|
||||
int? _pairingCodeSeconds;
|
||||
bool _regenerating = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUniqueId();
|
||||
}
|
||||
|
||||
Future<void> _loadUniqueId() async {
|
||||
var value = await sl<SecureStorage>().getUniqueUserId();
|
||||
if (value == null || value.isEmpty) {
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
final res = await sl<ApiClient>()
|
||||
.dio
|
||||
.get('/user/profile')
|
||||
.timeout(const Duration(seconds: 5));
|
||||
final data = res.data['data'];
|
||||
if (data is Map) value = data['uniqueUserId']?.toString();
|
||||
},
|
||||
onError: (_) {},
|
||||
fallback: 'Profil belum bisa dimuat.',
|
||||
);
|
||||
}
|
||||
if (mounted) setState(() => _uniqueId = value);
|
||||
}
|
||||
|
||||
Future<void> _regeneratePairingCode() async {
|
||||
setState(() => _regenerating = true);
|
||||
await runFriendlyAction(
|
||||
@@ -90,7 +68,7 @@ class _UserPairingScreenState extends State<UserPairingScreen> {
|
||||
return _Page(
|
||||
title: 'Pairing',
|
||||
subtitle: 'Bagikan pairing code sementara ini ke Guardian.',
|
||||
child: Column(
|
||||
child: StaggerWrapper(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (_pairingCode == null || _pairingCode!.isEmpty)
|
||||
@@ -118,11 +96,6 @@ class _UserPairingScreenState extends State<UserPairingScreen> {
|
||||
: const Icon(Icons.autorenew),
|
||||
label: Text(_regenerating ? 'Generating...' : 'Generate New Code'),
|
||||
),
|
||||
if (_uniqueId != null && _uniqueId!.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text('Account ID: $_uniqueId',
|
||||
style: const TextStyle(color: Color(0xFF64748B), fontSize: 12)),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
_PairingStatusCard(allowUserResponse: true),
|
||||
],
|
||||
@@ -348,26 +321,20 @@ class _PairingStatusCardState extends State<_PairingStatusCard> {
|
||||
final cardColor = _active
|
||||
? const Color(0xFFF0FDF4)
|
||||
: pending
|
||||
? const Color(0xFFEFF6FF)
|
||||
? AppColors.softBlueBg
|
||||
: const Color(0xFFFFFBEB);
|
||||
final accent = _active
|
||||
? const Color(0xFF059669)
|
||||
: pending
|
||||
? const Color(0xFF2563EB)
|
||||
? AppColors.primaryBlue
|
||||
: const Color(0xFFD97706);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
color: cardColor,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: accent.withValues(alpha: 0.28)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: accent.withValues(alpha: 0.10),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 12),
|
||||
),
|
||||
],
|
||||
boxShadow: AppDecorations.cardShadow,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -393,7 +360,7 @@ class _PairingStatusCardState extends State<_PairingStatusCard> {
|
||||
Expanded(
|
||||
child: Text(_status,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF0F172A),
|
||||
color: AppColors.textDark,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.25)),
|
||||
),
|
||||
@@ -465,7 +432,7 @@ class _Page extends StatelessWidget {
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFF8FAFC), Color(0xFFEFF6FF)],
|
||||
colors: [AppColors.softBlueBg, Colors.white],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -486,15 +453,9 @@ class _Page extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF0F172A),
|
||||
gradient: AppDecorations.blueGradient,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF0F172A).withValues(alpha: 0.18),
|
||||
blurRadius: 28,
|
||||
offset: const Offset(0, 14),
|
||||
),
|
||||
],
|
||||
boxShadow: AppDecorations.cardShadow,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -516,13 +477,11 @@ class _Page extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
)),
|
||||
style: AppTextStyles.heading.copyWith(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
)),
|
||||
if (subtitle != null)
|
||||
Text(subtitle!,
|
||||
style: const TextStyle(
|
||||
@@ -535,7 +494,7 @@ class _Page extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(child: child),
|
||||
Expanded(child: FadeSlideWrapper(child: child)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -561,15 +520,8 @@ class _InfoCard extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
border: Border.all(color: const Color(0xFFDDEAFE)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.10),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 12),
|
||||
),
|
||||
],
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: AppDecorations.cardShadow,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -577,10 +529,10 @@ class _InfoCard extends StatelessWidget {
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEFF6FF),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
color: AppColors.softBlueBg,
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
child: Icon(icon, color: const Color(0xFF2563EB)),
|
||||
child: Icon(icon, color: AppColors.primaryBlue),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
@@ -589,19 +541,19 @@ class _InfoCard extends StatelessWidget {
|
||||
children: [
|
||||
Text(title,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF64748B), fontWeight: FontWeight.w700)),
|
||||
color: AppColors.muted, fontWeight: FontWeight.w700)),
|
||||
SelectableText(value,
|
||||
style: const TextStyle(
|
||||
fontSize: 25,
|
||||
height: 1.1,
|
||||
letterSpacing: 1.2,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Color(0xFF0F172A))),
|
||||
color: AppColors.textDark)),
|
||||
if (helper != null) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(helper!,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF64748B), fontSize: 12)),
|
||||
color: AppColors.muted, fontSize: 12)),
|
||||
],
|
||||
])),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user