update info

This commit is contained in:
Phuoc Nguyen
2025-11-20 10:12:24 +07:00
parent 54cb7d0fdd
commit 0708ed7d6f
17 changed files with 2144 additions and 161 deletions

View File

@@ -8,14 +8,20 @@
/// - Logout button
library;
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:worker/core/constants/ui_constants.dart';
import 'package:worker/core/database/hive_initializer.dart';
import 'package:worker/core/database/models/enums.dart';
import 'package:worker/core/router/app_router.dart';
import 'package:worker/core/theme/colors.dart';
import 'package:worker/features/account/domain/entities/user_info.dart'
as domain;
import 'package:worker/features/account/presentation/providers/user_info_provider.dart'
hide UserInfo;
import 'package:worker/features/account/presentation/widgets/account_menu_item.dart';
import 'package:worker/features/auth/presentation/providers/auth_provider.dart';
@@ -27,30 +33,98 @@ class AccountPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return Scaffold(
backgroundColor: const Color(0xFFF4F6F8),
body: SafeArea(
child: SingleChildScrollView(
child: Column(
spacing: AppSpacing.md,
children: [
// Simple Header
_buildHeader(),
child: userInfoAsync.when(
loading: () => const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(color: AppColors.primaryBlue),
SizedBox(height: AppSpacing.md),
Text(
'Đang tải thông tin...',
style: TextStyle(
fontSize: 14,
color: AppColors.grey500,
),
),
],
),
),
error: (error, stack) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const FaIcon(
FontAwesomeIcons.circleExclamation,
size: 64,
color: AppColors.danger,
),
const SizedBox(height: AppSpacing.lg),
const Text(
'Không thể tải thông tin tài khoản',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center,
),
const SizedBox(height: AppSpacing.md),
Text(
error.toString(),
style: const TextStyle(
fontSize: 14,
color: AppColors.grey500,
),
textAlign: TextAlign.center,
),
const SizedBox(height: AppSpacing.lg),
ElevatedButton.icon(
onPressed: () =>
ref.read(userInfoProvider.notifier).refresh(),
icon:
const FaIcon(FontAwesomeIcons.arrowsRotate, size: 16),
label: const Text('Thử lại'),
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.primaryBlue,
foregroundColor: AppColors.white,
),
),
],
),
),
data: (userInfo) => RefreshIndicator(
onRefresh: () async {
await ref.read(userInfoProvider.notifier).refresh();
},
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
spacing: AppSpacing.md,
children: [
// Simple Header
_buildHeader(),
// User Profile Card
_buildProfileCard(context),
// User Profile Card with API data
_buildProfileCard(context, userInfo),
// Account Menu Section
_buildAccountMenu(context),
// Account Menu Section
_buildAccountMenu(context),
// Support Section
_buildSupportSection(context),
// Support Section
_buildSupportSection(context),
// Logout Button
_buildLogoutButton(context, ref),
// Logout Button
_buildLogoutButton(context, ref),
const SizedBox(height: AppSpacing.lg),
],
const SizedBox(height: AppSpacing.lg),
],
),
),
),
),
),
@@ -84,7 +158,10 @@ class AccountPage extends ConsumerWidget {
}
/// Build user profile card with avatar and info
Widget _buildProfileCard(BuildContext context) {
Widget _buildProfileCard(
BuildContext context,
domain.UserInfo userInfo,
) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
padding: const EdgeInsets.all(AppSpacing.md),
@@ -101,54 +178,109 @@ class AccountPage extends ConsumerWidget {
),
child: Row(
children: [
// Avatar with gradient background
Container(
width: 80,
height: 80,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFF005B9A), Color(0xFF38B6FF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: const Center(
child: Text(
'LQ',
style: TextStyle(
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.w700,
// Avatar with API data or gradient fallback
userInfo.avatarUrl != null
? ClipOval(
child: CachedNetworkImage(
imageUrl: userInfo.avatarUrl!,
width: 80,
height: 80,
fit: BoxFit.cover,
placeholder: (context, url) => Container(
width: 80,
height: 80,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFF005B9A), Color(0xFF38B6FF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: const Center(
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
),
),
errorWidget: (context, url, error) => Container(
width: 80,
height: 80,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFF005B9A), Color(0xFF38B6FF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Center(
child: Text(
userInfo.initials,
style: const TextStyle(
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.w700,
),
),
),
),
),
)
: Container(
width: 80,
height: 80,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFF005B9A), Color(0xFF38B6FF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Center(
child: Text(
userInfo.initials,
style: const TextStyle(
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.w700,
),
),
),
),
),
),
),
const SizedBox(width: AppSpacing.md),
// User info
// User info from API
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.xs,
children: [
const Text(
'La Nguyen Quynh',
style: TextStyle(
Text(
userInfo.fullName,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColors.grey900,
),
),
const SizedBox(height: 4),
const Text(
'Kiến trúc sư · Hạng Diamond',
style: TextStyle(fontSize: 13, color: AppColors.grey500),
),
const SizedBox(height: 4),
const Text(
'0983 441 099',
style: TextStyle(fontSize: 13, color: AppColors.primaryBlue),
Text(
'${_getRoleDisplayName(userInfo.role)} · Hạng ${userInfo.tierDisplayName}',
style: const TextStyle(
fontSize: 13,
color: AppColors.grey500,
),
),
if (userInfo.phoneNumber != null)
Text(
userInfo.phoneNumber!,
style: const TextStyle(
fontSize: 13,
color: AppColors.primaryBlue,
),
),
],
),
),
@@ -472,4 +604,18 @@ class AccountPage extends ConsumerWidget {
}
}
}
/// Get Vietnamese display name for user role
String _getRoleDisplayName(UserRole role) {
switch (role) {
case UserRole.customer:
return 'Khách hàng';
case UserRole.distributor:
return 'Đại lý phân phối';
case UserRole.admin:
return 'Quản trị viên';
case UserRole.staff:
return 'Nhân viên';
}
}
}

View File

@@ -18,6 +18,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:image_picker/image_picker.dart';
import 'package:worker/core/constants/ui_constants.dart';
import 'package:worker/core/theme/colors.dart';
import 'package:worker/features/account/presentation/providers/user_info_provider.dart' hide UserInfo;
/// Profile Edit Page
///
@@ -27,47 +28,128 @@ class ProfileEditPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
// Watch user info from API
final userInfoAsync = ref.watch(userInfoProvider);
// Form key for validation
final formKey = useMemoized(() => GlobalKey<FormState>());
// Image picker
final selectedImage = useState<File?>(null);
// Form controllers
final nameController = useTextEditingController(text: 'Hoàng Minh Hiệp');
final phoneController = useTextEditingController(text: '0347302911');
final emailController = useTextEditingController(
text: 'hoanghiep@example.com',
);
final birthDateController = useTextEditingController(text: '15/03/1985');
final idNumberController = useTextEditingController(text: '123456789012');
final taxIdController = useTextEditingController(text: '0359837618');
final companyController = useTextEditingController(
text: 'Công ty TNHH Xây dựng ABC',
);
final addressController = useTextEditingController(
text: '123 Man Thiện, Thủ Đức, Hồ Chí Minh',
);
final experienceController = useTextEditingController(text: '10');
// Dropdown values
final selectedGender = useState<String>('male');
final selectedPosition = useState<String>('contractor');
// Has unsaved changes
final hasChanges = useState<bool>(false);
return PopScope(
canPop: !hasChanges.value,
onPopInvokedWithResult: (didPop, result) async {
if (didPop) return;
return userInfoAsync.when(
loading: () => Scaffold(
backgroundColor: const Color(0xFFF4F6F8),
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
title: const Text(
'Thông tin cá nhân',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
centerTitle: false,
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(color: AppColors.primaryBlue),
SizedBox(height: AppSpacing.md),
Text(
'Đang tải thông tin...',
style: TextStyle(
fontSize: 14,
color: AppColors.grey500,
),
),
],
),
),
),
error: (error, stack) => Scaffold(
backgroundColor: const Color(0xFFF4F6F8),
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const FaIcon(FontAwesomeIcons.arrowLeft, color: Colors.black, size: 20),
onPressed: () => context.pop(),
),
title: const Text(
'Thông tin cá nhân',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
centerTitle: false,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const FaIcon(
FontAwesomeIcons.circleExclamation,
size: 64,
color: AppColors.danger,
),
const SizedBox(height: AppSpacing.lg),
const Text(
'Không thể tải thông tin người dùng',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.md),
ElevatedButton.icon(
onPressed: () => ref.read(userInfoProvider.notifier).refresh(),
icon: const FaIcon(FontAwesomeIcons.arrowsRotate, size: 16),
label: const Text('Thử lại'),
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.primaryBlue,
foregroundColor: AppColors.white,
),
),
],
),
),
),
data: (userInfo) {
// Form controllers populated with user data
final nameController = useTextEditingController(text: userInfo.fullName);
final phoneController = useTextEditingController(text: userInfo.phoneNumber ?? '');
final emailController = useTextEditingController(text: userInfo.email ?? '');
final birthDateController = useTextEditingController(text: ''); // TODO: Add birthdate to API
final idNumberController = useTextEditingController(text: userInfo.cccd ?? '');
final taxIdController = useTextEditingController(text: userInfo.taxId ?? '');
final companyController = useTextEditingController(text: userInfo.companyName ?? '');
final addressController = useTextEditingController(text: userInfo.address ?? '');
final experienceController = useTextEditingController(text: ''); // TODO: Add experience to API
final shouldPop = await _showUnsavedChangesDialog(context);
if (shouldPop == true && context.mounted) {
Navigator.of(context).pop();
}
},
child: Scaffold(
// Dropdown values
final selectedGender = useState<String>('male'); // TODO: Add gender to API
final selectedPosition = useState<String>('contractor'); // TODO: Map from userInfo.role
return PopScope(
canPop: !hasChanges.value,
onPopInvokedWithResult: (didPop, result) async {
if (didPop) return;
final shouldPop = await _showUnsavedChangesDialog(context);
if (shouldPop == true && context.mounted) {
Navigator.of(context).pop();
}
},
child: Scaffold(
backgroundColor: const Color(0xFFF4F6F8),
appBar: AppBar(
backgroundColor: Colors.white,
@@ -107,7 +189,12 @@ class ProfileEditPage extends HookConsumerWidget {
const SizedBox(height: AppSpacing.md),
// Profile Avatar Section
_buildAvatarSection(context, selectedImage),
_buildAvatarSection(
context,
selectedImage,
userInfo.initials,
userInfo.avatarUrl,
),
const SizedBox(height: AppSpacing.md),
@@ -276,7 +363,9 @@ class ProfileEditPage extends HookConsumerWidget {
),
),
),
),
),
);
},
);
}
@@ -284,70 +373,83 @@ class ProfileEditPage extends HookConsumerWidget {
Widget _buildAvatarSection(
BuildContext context,
ValueNotifier<File?> selectedImage,
String initials,
String? avatarUrl,
) {
return Center(
child: Stack(
children: [
// Avatar
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.primaryBlue,
image: selectedImage.value != null
? DecorationImage(
image: FileImage(selectedImage.value!),
fit: BoxFit.cover,
return Padding(
padding: const EdgeInsets.symmetric(vertical: AppSpacing.sm),
child: Center(
child: Stack(
clipBehavior: Clip.none,
children: [
// Avatar
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.primaryBlue,
image: selectedImage.value != null
? DecorationImage(
image: FileImage(selectedImage.value!),
fit: BoxFit.cover,
)
: avatarUrl != null
? DecorationImage(
image: NetworkImage(avatarUrl),
fit: BoxFit.cover,
)
: null,
),
child: selectedImage.value == null && avatarUrl == null
? Center(
child: Text(
initials,
style: const TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
)
: null,
),
child: selectedImage.value == null
? const Center(
child: Text(
'HMH',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
)
: null,
),
// Edit Button
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onTap: () async {
await _pickImage(context, selectedImage);
},
child: Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: AppColors.primaryBlue,
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 2),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 4,
offset: const Offset(0, 2),
// Edit Button
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onTap: () async {
await _pickImage(context, selectedImage);
},
child: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: AppColors.primaryBlue,
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 3),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.15),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: const Center(
child: FaIcon(
FontAwesomeIcons.camera,
size: 16,
color: Colors.white,
),
],
),
child: const FaIcon(
FontAwesomeIcons.camera,
size: 14,
color: Colors.white,
),
),
),
),
),
],
],
),
),
);
}
@@ -473,7 +575,18 @@ class ProfileEditPage extends HookConsumerWidget {
horizontal: 16,
vertical: 12,
),
suffixIcon: const FaIcon(FontAwesomeIcons.calendar, size: 18),
suffixIcon: const Padding(
padding: EdgeInsets.only(right: 12),
child: FaIcon(
FontAwesomeIcons.calendar,
size: 20,
color: AppColors.grey500,
),
),
suffixIconConstraints: const BoxConstraints(
minWidth: 48,
minHeight: 48,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppRadius.input),
borderSide: const BorderSide(color: Color(0xFFE2E8F0)),
@@ -517,6 +630,14 @@ class ProfileEditPage extends HookConsumerWidget {
DropdownButtonFormField<String>(
initialValue: value,
onChanged: onChanged,
icon: const Padding(
padding: EdgeInsets.only(right: 12),
child: FaIcon(
FontAwesomeIcons.chevronDown,
size: 16,
color: AppColors.grey500,
),
),
decoration: InputDecoration(
filled: true,
fillColor: const Color(0xFFF8FAFC),

View File

@@ -0,0 +1,200 @@
/// Provider: User Info Provider
///
/// Manages the state of user information using Riverpod.
/// Fetches data from API and provides it to the UI.
library;
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:worker/core/network/dio_client.dart';
import 'package:worker/features/account/data/datasources/user_info_remote_datasource.dart';
import 'package:worker/features/account/data/repositories/user_info_repository_impl.dart';
import 'package:worker/features/account/domain/entities/user_info.dart'
as domain;
import 'package:worker/features/account/domain/repositories/user_info_repository.dart';
import 'package:worker/features/account/domain/usecases/get_user_info.dart';
part 'user_info_provider.g.dart';
// ============================================================================
// DATA SOURCE PROVIDERS
// ============================================================================
/// User Info Remote Data Source Provider
@riverpod
Future<UserInfoRemoteDataSource> userInfoRemoteDataSource(Ref ref) async {
final dioClient = await ref.watch(dioClientProvider.future);
return UserInfoRemoteDataSource(dioClient);
}
// ============================================================================
// REPOSITORY PROVIDERS
// ============================================================================
/// User Info Repository Provider
@riverpod
Future<UserInfoRepository> userInfoRepository(Ref ref) async {
final remoteDataSource = await ref.watch(
userInfoRemoteDataSourceProvider.future,
);
return UserInfoRepositoryImpl(remoteDataSource: remoteDataSource);
}
// ============================================================================
// USE CASE PROVIDERS
// ============================================================================
/// Get User Info Use Case Provider
@riverpod
Future<GetUserInfo> getUserInfoUseCase(Ref ref) async {
final repository = await ref.watch(userInfoRepositoryProvider.future);
return GetUserInfo(repository);
}
// ============================================================================
// STATE PROVIDERS
// ============================================================================
/// User Info Provider
///
/// Fetches and manages user information state.
/// Automatically loads user info on initialization.
/// Provides refresh functionality for manual updates.
///
/// Usage:
/// ```dart
/// // In a widget
/// final userInfoAsync = ref.watch(userInfoProvider);
///
/// userInfoAsync.when(
/// data: (userInfo) => Text(userInfo.fullName),
/// loading: () => CircularProgressIndicator(),
/// error: (error, stack) => ErrorWidget(error),
/// );
///
/// // To refresh
/// ref.read(userInfoProvider.notifier).refresh();
/// ```
@riverpod
class UserInfo extends _$UserInfo {
@override
Future<domain.UserInfo> build() async {
// Fetch user info on initialization
final useCase = await ref.watch(getUserInfoUseCaseProvider.future);
return await useCase();
}
/// Refresh user information
///
/// Forces a fresh fetch from the API.
/// Updates the state with new data.
///
/// Usage:
/// ```dart
/// await ref.read(userInfoProvider.notifier).refresh();
/// ```
Future<void> refresh() async {
// Set loading state
state = const AsyncValue.loading();
// Fetch fresh data
state = await AsyncValue.guard(() async {
final useCase = await ref.read(getUserInfoUseCaseProvider.future);
return await useCase.refresh();
});
}
/// Update user info locally
///
/// Updates the cached state without fetching from API.
/// Useful after local profile updates.
///
/// Usage:
/// ```dart
/// ref.read(userInfoProvider.notifier).updateLocal(updatedUserInfo);
/// ```
void updateLocal(domain.UserInfo updatedInfo) {
state = AsyncValue.data(updatedInfo);
}
/// Clear user info
///
/// Resets the state to loading.
/// Useful on logout or session expiry.
void clear() {
state = const AsyncValue.loading();
}
}
// ============================================================================
// COMPUTED PROVIDERS
// ============================================================================
/// User Display Name Provider
///
/// Provides the user's display name (full name).
/// Returns null if user info is not loaded.
@riverpod
String? userDisplayName(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.fullName;
}
/// User Loyalty Tier Provider
///
/// Provides the user's current loyalty tier.
/// Returns null if user info is not loaded.
@riverpod
String? userLoyaltyTier(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.tierDisplayName;
}
/// User Total Points Provider
///
/// Provides the user's total loyalty points.
/// Returns 0 if user info is not loaded.
@riverpod
int userTotalPoints(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.totalPoints ?? 0;
}
/// User Available Points Provider
///
/// Provides the user's available points for redemption.
/// Returns 0 if user info is not loaded.
@riverpod
int userAvailablePoints(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.availablePoints ?? 0;
}
/// User Avatar URL Provider
///
/// Provides the user's avatar URL.
/// Returns null if user info is not loaded or no avatar set.
@riverpod
String? userAvatarUrl(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.avatarUrl;
}
/// User Has Company Info Provider
///
/// Checks if the user has company information.
/// Returns false if user info is not loaded.
@riverpod
bool userHasCompanyInfo(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.hasCompanyInfo ?? false;
}
/// User Is Active Provider
///
/// Checks if the user's account is active.
/// Returns false if user info is not loaded.
@riverpod
bool userIsActive(Ref ref) {
final userInfoAsync = ref.watch(userInfoProvider);
return userInfoAsync.value?.isActive ?? false;
}

View File

@@ -0,0 +1,660 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_info_provider.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
/// User Info Remote Data Source Provider
@ProviderFor(userInfoRemoteDataSource)
const userInfoRemoteDataSourceProvider = UserInfoRemoteDataSourceProvider._();
/// User Info Remote Data Source Provider
final class UserInfoRemoteDataSourceProvider
extends
$FunctionalProvider<
AsyncValue<UserInfoRemoteDataSource>,
UserInfoRemoteDataSource,
FutureOr<UserInfoRemoteDataSource>
>
with
$FutureModifier<UserInfoRemoteDataSource>,
$FutureProvider<UserInfoRemoteDataSource> {
/// User Info Remote Data Source Provider
const UserInfoRemoteDataSourceProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userInfoRemoteDataSourceProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userInfoRemoteDataSourceHash();
@$internal
@override
$FutureProviderElement<UserInfoRemoteDataSource> $createElement(
$ProviderPointer pointer,
) => $FutureProviderElement(pointer);
@override
FutureOr<UserInfoRemoteDataSource> create(Ref ref) {
return userInfoRemoteDataSource(ref);
}
}
String _$userInfoRemoteDataSourceHash() =>
r'0005ce1362403c422b0f0c264a532d6e65f8d21f';
/// User Info Repository Provider
@ProviderFor(userInfoRepository)
const userInfoRepositoryProvider = UserInfoRepositoryProvider._();
/// User Info Repository Provider
final class UserInfoRepositoryProvider
extends
$FunctionalProvider<
AsyncValue<UserInfoRepository>,
UserInfoRepository,
FutureOr<UserInfoRepository>
>
with
$FutureModifier<UserInfoRepository>,
$FutureProvider<UserInfoRepository> {
/// User Info Repository Provider
const UserInfoRepositoryProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userInfoRepositoryProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userInfoRepositoryHash();
@$internal
@override
$FutureProviderElement<UserInfoRepository> $createElement(
$ProviderPointer pointer,
) => $FutureProviderElement(pointer);
@override
FutureOr<UserInfoRepository> create(Ref ref) {
return userInfoRepository(ref);
}
}
String _$userInfoRepositoryHash() =>
r'9dbce126973e282b60cf2437fca1c2c3c3073c0b';
/// Get User Info Use Case Provider
@ProviderFor(getUserInfoUseCase)
const getUserInfoUseCaseProvider = GetUserInfoUseCaseProvider._();
/// Get User Info Use Case Provider
final class GetUserInfoUseCaseProvider
extends
$FunctionalProvider<
AsyncValue<GetUserInfo>,
GetUserInfo,
FutureOr<GetUserInfo>
>
with $FutureModifier<GetUserInfo>, $FutureProvider<GetUserInfo> {
/// Get User Info Use Case Provider
const GetUserInfoUseCaseProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'getUserInfoUseCaseProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$getUserInfoUseCaseHash();
@$internal
@override
$FutureProviderElement<GetUserInfo> $createElement(
$ProviderPointer pointer,
) => $FutureProviderElement(pointer);
@override
FutureOr<GetUserInfo> create(Ref ref) {
return getUserInfoUseCase(ref);
}
}
String _$getUserInfoUseCaseHash() =>
r'4da4fa45015bf29b2e8d3fcaf8019eccc470a3c9';
/// User Info Provider
///
/// Fetches and manages user information state.
/// Automatically loads user info on initialization.
/// Provides refresh functionality for manual updates.
///
/// Usage:
/// ```dart
/// // In a widget
/// final userInfoAsync = ref.watch(userInfoProvider);
///
/// userInfoAsync.when(
/// data: (userInfo) => Text(userInfo.fullName),
/// loading: () => CircularProgressIndicator(),
/// error: (error, stack) => ErrorWidget(error),
/// );
///
/// // To refresh
/// ref.read(userInfoProvider.notifier).refresh();
/// ```
@ProviderFor(UserInfo)
const userInfoProvider = UserInfoProvider._();
/// User Info Provider
///
/// Fetches and manages user information state.
/// Automatically loads user info on initialization.
/// Provides refresh functionality for manual updates.
///
/// Usage:
/// ```dart
/// // In a widget
/// final userInfoAsync = ref.watch(userInfoProvider);
///
/// userInfoAsync.when(
/// data: (userInfo) => Text(userInfo.fullName),
/// loading: () => CircularProgressIndicator(),
/// error: (error, stack) => ErrorWidget(error),
/// );
///
/// // To refresh
/// ref.read(userInfoProvider.notifier).refresh();
/// ```
final class UserInfoProvider
extends $AsyncNotifierProvider<UserInfo, domain.UserInfo> {
/// User Info Provider
///
/// Fetches and manages user information state.
/// Automatically loads user info on initialization.
/// Provides refresh functionality for manual updates.
///
/// Usage:
/// ```dart
/// // In a widget
/// final userInfoAsync = ref.watch(userInfoProvider);
///
/// userInfoAsync.when(
/// data: (userInfo) => Text(userInfo.fullName),
/// loading: () => CircularProgressIndicator(),
/// error: (error, stack) => ErrorWidget(error),
/// );
///
/// // To refresh
/// ref.read(userInfoProvider.notifier).refresh();
/// ```
const UserInfoProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userInfoProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userInfoHash();
@$internal
@override
UserInfo create() => UserInfo();
}
String _$userInfoHash() => r'74fe20082e7acbb23f9606bd01fdf43fd4c5a893';
/// User Info Provider
///
/// Fetches and manages user information state.
/// Automatically loads user info on initialization.
/// Provides refresh functionality for manual updates.
///
/// Usage:
/// ```dart
/// // In a widget
/// final userInfoAsync = ref.watch(userInfoProvider);
///
/// userInfoAsync.when(
/// data: (userInfo) => Text(userInfo.fullName),
/// loading: () => CircularProgressIndicator(),
/// error: (error, stack) => ErrorWidget(error),
/// );
///
/// // To refresh
/// ref.read(userInfoProvider.notifier).refresh();
/// ```
abstract class _$UserInfo extends $AsyncNotifier<domain.UserInfo> {
FutureOr<domain.UserInfo> build();
@$mustCallSuper
@override
void runBuild() {
final created = build();
final ref = this.ref as $Ref<AsyncValue<domain.UserInfo>, domain.UserInfo>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<AsyncValue<domain.UserInfo>, domain.UserInfo>,
AsyncValue<domain.UserInfo>,
Object?,
Object?
>;
element.handleValue(ref, created);
}
}
/// User Display Name Provider
///
/// Provides the user's display name (full name).
/// Returns null if user info is not loaded.
@ProviderFor(userDisplayName)
const userDisplayNameProvider = UserDisplayNameProvider._();
/// User Display Name Provider
///
/// Provides the user's display name (full name).
/// Returns null if user info is not loaded.
final class UserDisplayNameProvider
extends $FunctionalProvider<String?, String?, String?>
with $Provider<String?> {
/// User Display Name Provider
///
/// Provides the user's display name (full name).
/// Returns null if user info is not loaded.
const UserDisplayNameProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userDisplayNameProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userDisplayNameHash();
@$internal
@override
$ProviderElement<String?> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
String? create(Ref ref) {
return userDisplayName(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(String? value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<String?>(value),
);
}
}
String _$userDisplayNameHash() => r'610fca82de075602e72988dfbe9a847733dfb9ee';
/// User Loyalty Tier Provider
///
/// Provides the user's current loyalty tier.
/// Returns null if user info is not loaded.
@ProviderFor(userLoyaltyTier)
const userLoyaltyTierProvider = UserLoyaltyTierProvider._();
/// User Loyalty Tier Provider
///
/// Provides the user's current loyalty tier.
/// Returns null if user info is not loaded.
final class UserLoyaltyTierProvider
extends $FunctionalProvider<String?, String?, String?>
with $Provider<String?> {
/// User Loyalty Tier Provider
///
/// Provides the user's current loyalty tier.
/// Returns null if user info is not loaded.
const UserLoyaltyTierProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userLoyaltyTierProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userLoyaltyTierHash();
@$internal
@override
$ProviderElement<String?> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
String? create(Ref ref) {
return userLoyaltyTier(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(String? value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<String?>(value),
);
}
}
String _$userLoyaltyTierHash() => r'92d69295f4d8e53611bb42e447f71fc3fe3a8514';
/// User Total Points Provider
///
/// Provides the user's total loyalty points.
/// Returns 0 if user info is not loaded.
@ProviderFor(userTotalPoints)
const userTotalPointsProvider = UserTotalPointsProvider._();
/// User Total Points Provider
///
/// Provides the user's total loyalty points.
/// Returns 0 if user info is not loaded.
final class UserTotalPointsProvider extends $FunctionalProvider<int, int, int>
with $Provider<int> {
/// User Total Points Provider
///
/// Provides the user's total loyalty points.
/// Returns 0 if user info is not loaded.
const UserTotalPointsProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userTotalPointsProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userTotalPointsHash();
@$internal
@override
$ProviderElement<int> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
int create(Ref ref) {
return userTotalPoints(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(int value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<int>(value),
);
}
}
String _$userTotalPointsHash() => r'9d35a12e7294dc85a5cc754dbd0fb253327195ce';
/// User Available Points Provider
///
/// Provides the user's available points for redemption.
/// Returns 0 if user info is not loaded.
@ProviderFor(userAvailablePoints)
const userAvailablePointsProvider = UserAvailablePointsProvider._();
/// User Available Points Provider
///
/// Provides the user's available points for redemption.
/// Returns 0 if user info is not loaded.
final class UserAvailablePointsProvider
extends $FunctionalProvider<int, int, int>
with $Provider<int> {
/// User Available Points Provider
///
/// Provides the user's available points for redemption.
/// Returns 0 if user info is not loaded.
const UserAvailablePointsProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userAvailablePointsProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userAvailablePointsHash();
@$internal
@override
$ProviderElement<int> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
int create(Ref ref) {
return userAvailablePoints(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(int value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<int>(value),
);
}
}
String _$userAvailablePointsHash() =>
r'dd3f4952b95c11ccfcbac36622b068cdf8be953a';
/// User Avatar URL Provider
///
/// Provides the user's avatar URL.
/// Returns null if user info is not loaded or no avatar set.
@ProviderFor(userAvatarUrl)
const userAvatarUrlProvider = UserAvatarUrlProvider._();
/// User Avatar URL Provider
///
/// Provides the user's avatar URL.
/// Returns null if user info is not loaded or no avatar set.
final class UserAvatarUrlProvider
extends $FunctionalProvider<String?, String?, String?>
with $Provider<String?> {
/// User Avatar URL Provider
///
/// Provides the user's avatar URL.
/// Returns null if user info is not loaded or no avatar set.
const UserAvatarUrlProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userAvatarUrlProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userAvatarUrlHash();
@$internal
@override
$ProviderElement<String?> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
String? create(Ref ref) {
return userAvatarUrl(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(String? value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<String?>(value),
);
}
}
String _$userAvatarUrlHash() => r'0059015a6651c8794b96aadf6db6196a769d411c';
/// User Has Company Info Provider
///
/// Checks if the user has company information.
/// Returns false if user info is not loaded.
@ProviderFor(userHasCompanyInfo)
const userHasCompanyInfoProvider = UserHasCompanyInfoProvider._();
/// User Has Company Info Provider
///
/// Checks if the user has company information.
/// Returns false if user info is not loaded.
final class UserHasCompanyInfoProvider
extends $FunctionalProvider<bool, bool, bool>
with $Provider<bool> {
/// User Has Company Info Provider
///
/// Checks if the user has company information.
/// Returns false if user info is not loaded.
const UserHasCompanyInfoProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userHasCompanyInfoProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userHasCompanyInfoHash();
@$internal
@override
$ProviderElement<bool> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
bool create(Ref ref) {
return userHasCompanyInfo(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(bool value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<bool>(value),
);
}
}
String _$userHasCompanyInfoHash() =>
r'fae2791285977a58e8358832b4a3772f99409c8a';
/// User Is Active Provider
///
/// Checks if the user's account is active.
/// Returns false if user info is not loaded.
@ProviderFor(userIsActive)
const userIsActiveProvider = UserIsActiveProvider._();
/// User Is Active Provider
///
/// Checks if the user's account is active.
/// Returns false if user info is not loaded.
final class UserIsActiveProvider extends $FunctionalProvider<bool, bool, bool>
with $Provider<bool> {
/// User Is Active Provider
///
/// Checks if the user's account is active.
/// Returns false if user info is not loaded.
const UserIsActiveProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userIsActiveProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userIsActiveHash();
@$internal
@override
$ProviderElement<bool> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
bool create(Ref ref) {
return userIsActive(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(bool value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<bool>(value),
);
}
}
String _$userIsActiveHash() => r'2965221f0518bf7831ab679297f749d1674cb65d';