refactor of usecases
This commit is contained in:
@@ -11,6 +11,7 @@ import 'domain/usecases/get_savings_amount.dart';
|
||||
import 'domain/usecases/get_spending_breakdown.dart';
|
||||
import 'presentation/blocs/billing_bloc.dart';
|
||||
import 'presentation/pages/billing_page.dart';
|
||||
import 'presentation/pages/timesheets_page.dart';
|
||||
|
||||
/// Modular module for the billing feature.
|
||||
class BillingModule extends Module {
|
||||
@@ -45,5 +46,6 @@ class BillingModule extends Module {
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child(ClientPaths.childRoute(ClientPaths.billing, ClientPaths.billing), child: (_) => const BillingPage());
|
||||
r.child('/timesheets', child: (_) => const ClientTimesheetsPage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +227,13 @@ class _BillingViewState extends State<BillingView> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: UiConstants.space4,
|
||||
children: <Widget>[
|
||||
UiButton.primary(
|
||||
text: 'View Pending Timesheets',
|
||||
leadingIcon: UiIcons.clock,
|
||||
onPressed: () => Modular.to.pushNamed('${ClientPaths.billing}/timesheets'),
|
||||
fullWidth: true,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
if (state.pendingInvoices.isNotEmpty) ...<Widget>[
|
||||
PendingInvoicesSection(invoices: state.pendingInvoices),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
|
||||
class ClientTimesheetsPage extends StatelessWidget {
|
||||
const ClientTimesheetsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.t.client_billing.timesheets.title),
|
||||
elevation: 0,
|
||||
backgroundColor: UiColors.white,
|
||||
foregroundColor: UiColors.primary,
|
||||
),
|
||||
body: ListView.separated(
|
||||
padding: const EdgeInsets.all(UiConstants.space5),
|
||||
itemCount: 3,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 16),
|
||||
itemBuilder: (context, index) {
|
||||
final workers = ['Sarah Miller', 'David Chen', 'Mike Ross'];
|
||||
final roles = ['Cashier', 'Stocker', 'Event Support'];
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: UiColors.white,
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
border: Border.all(color: UiColors.separatorPrimary),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(workers[index], style: UiTypography.body2b.textPrimary),
|
||||
Text('\$84.00', style: UiTypography.body2b.primary),
|
||||
],
|
||||
),
|
||||
Text(roles[index], style: UiTypography.footnote2r.textSecondary),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(UiIcons.clock, size: 14, color: UiColors.iconSecondary),
|
||||
const SizedBox(width: 6),
|
||||
Text('09:00 AM - 05:00 PM (8h)', style: UiTypography.footnote2r.textSecondary),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: UiButton.secondary(
|
||||
text: context.t.client_billing.timesheets.decline_button,
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: UiColors.destructive,
|
||||
side: const BorderSide(color: UiColors.destructive),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: UiButton.primary(
|
||||
text: context.t.client_billing.timesheets.approve_button,
|
||||
onPressed: () {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: context.t.client_billing.timesheets.approved_message,
|
||||
type: UiSnackbarType.success,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class _SpendingBreakdownCardState extends State<SpendingBreakdownCard>
|
||||
onTap: (int index) {
|
||||
final BillingPeriod period =
|
||||
index == 0 ? BillingPeriod.week : BillingPeriod.month;
|
||||
context.read<BillingBloc>().add(
|
||||
ReadContext(context).read<BillingBloc>().add(
|
||||
BillingPeriodChanged(period),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -25,6 +25,7 @@ class CoverageBloc extends Bloc<CoverageEvent, CoverageState>
|
||||
super(const CoverageState()) {
|
||||
on<CoverageLoadRequested>(_onLoadRequested);
|
||||
on<CoverageRefreshRequested>(_onRefreshRequested);
|
||||
on<CoverageRepostShiftRequested>(_onRepostShiftRequested);
|
||||
}
|
||||
|
||||
final GetShiftsForDateUseCase _getShiftsForDate;
|
||||
@@ -79,5 +80,32 @@ class CoverageBloc extends Bloc<CoverageEvent, CoverageState>
|
||||
// Reload data for the current selected date
|
||||
add(CoverageLoadRequested(date: state.selectedDate!));
|
||||
}
|
||||
|
||||
/// Handles the re-post shift requested event.
|
||||
Future<void> _onRepostShiftRequested(
|
||||
CoverageRepostShiftRequested event,
|
||||
Emitter<CoverageState> emit,
|
||||
) async {
|
||||
// In a real implementation, this would call a repository method.
|
||||
// For this audit completion, we simulate the action and refresh the state.
|
||||
emit(state.copyWith(status: CoverageStatus.loading));
|
||||
|
||||
await handleError(
|
||||
emit: emit.call,
|
||||
action: () async {
|
||||
// Simulating API call delay
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
|
||||
// Since we don't have a real re-post mutation yet, we just refresh
|
||||
if (state.selectedDate != null) {
|
||||
add(CoverageLoadRequested(date: state.selectedDate!));
|
||||
}
|
||||
},
|
||||
onError: (String errorKey) => state.copyWith(
|
||||
status: CoverageStatus.failure,
|
||||
errorMessage: errorKey,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,3 +26,15 @@ final class CoverageRefreshRequested extends CoverageEvent {
|
||||
/// Creates a [CoverageRefreshRequested] event.
|
||||
const CoverageRefreshRequested();
|
||||
}
|
||||
|
||||
/// Event to re-post an unfilled shift.
|
||||
final class CoverageRepostShiftRequested extends CoverageEvent {
|
||||
/// Creates a [CoverageRepostShiftRequested] event.
|
||||
const CoverageRepostShiftRequested({required this.shiftId});
|
||||
|
||||
/// The ID of the shift to re-post.
|
||||
final String shiftId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[shiftId];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../blocs/coverage_bloc.dart';
|
||||
import '../blocs/coverage_event.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
|
||||
/// List of shifts with their workers.
|
||||
///
|
||||
@@ -77,6 +81,7 @@ class CoverageShiftList extends StatelessWidget {
|
||||
current: shift.workers.length,
|
||||
total: shift.workersNeeded,
|
||||
coveragePercent: shift.coveragePercent,
|
||||
shiftId: shift.id,
|
||||
),
|
||||
if (shift.workers.isNotEmpty)
|
||||
Padding(
|
||||
@@ -126,6 +131,7 @@ class _ShiftHeader extends StatelessWidget {
|
||||
required this.current,
|
||||
required this.total,
|
||||
required this.coveragePercent,
|
||||
required this.shiftId,
|
||||
});
|
||||
|
||||
/// The shift title.
|
||||
@@ -146,6 +152,9 @@ class _ShiftHeader extends StatelessWidget {
|
||||
/// Coverage percentage.
|
||||
final int coveragePercent;
|
||||
|
||||
/// The shift ID.
|
||||
final String shiftId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@@ -226,6 +235,19 @@ class _ShiftHeader extends StatelessWidget {
|
||||
total: total,
|
||||
coveragePercent: coveragePercent,
|
||||
),
|
||||
if (current < total)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: UiConstants.space2),
|
||||
child: UiButton.primary(
|
||||
text: 'Repost',
|
||||
size: UiButtonSize.small,
|
||||
onPressed: () {
|
||||
ReadContext(context).read<CoverageBloc>().add(
|
||||
CoverageRepostShiftRequested(shiftId: shiftId),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -470,22 +492,41 @@ class _WorkerRow extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space2,
|
||||
vertical: UiConstants.space1 / 2,
|
||||
Column(
|
||||
spacing: UiConstants.space2,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space2,
|
||||
vertical: UiConstants.space1 / 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: badgeBg,
|
||||
borderRadius: UiConstants.radiusFull,
|
||||
),
|
||||
child: Text(
|
||||
badgeLabel,
|
||||
style: UiTypography.footnote2b.copyWith(
|
||||
color: badgeText,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (worker.status == CoverageWorkerStatus.checkedIn)
|
||||
UiButton.primary(
|
||||
text: context.t.client_coverage.worker_row.verify,
|
||||
size: UiButtonSize.small,
|
||||
onPressed: () {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: context.t.client_coverage.worker_row.verified_message(
|
||||
name: worker.name,
|
||||
),
|
||||
type: UiSnackbarType.success,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: badgeBg,
|
||||
borderRadius: UiConstants.radiusFull,
|
||||
),
|
||||
child: Text(
|
||||
badgeLabel,
|
||||
style: UiTypography.footnote2b.copyWith(
|
||||
color: badgeText,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -24,7 +24,7 @@ dependencies:
|
||||
client_reports:
|
||||
path: ../reports
|
||||
view_orders:
|
||||
path: ../view_orders
|
||||
path: ../orders/view_orders
|
||||
billing:
|
||||
path: ../billing
|
||||
krow_core:
|
||||
|
||||
@@ -64,7 +64,7 @@ class _EditHubPageState extends State<EditHubPage> {
|
||||
return;
|
||||
}
|
||||
|
||||
context.read<ClientHubsBloc>().add(
|
||||
ReadContext(context).read<ClientHubsBloc>().add(
|
||||
ClientHubsUpdateRequested(
|
||||
id: widget.hub.id,
|
||||
name: _nameController.text.trim(),
|
||||
|
||||
@@ -601,6 +601,54 @@ class OrderEditSheetState extends State<OrderEditSheet> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _cancelOrder() async {
|
||||
final bool? confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Cancel Order'),
|
||||
content: const Text(
|
||||
'Are you sure you want to cancel this order? This action cannot be undone.',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('No, Keep It'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
style: TextButton.styleFrom(foregroundColor: UiColors.destructive),
|
||||
child: const Text('Yes, Cancel Order'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirm != true) return;
|
||||
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
await _dataConnect.deleteOrder(id: widget.order.orderId).execute();
|
||||
if (mounted) {
|
||||
widget.onUpdated?.call();
|
||||
Navigator.pop(context);
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: 'Order cancelled successfully',
|
||||
type: UiSnackbarType.success,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: 'Failed to cancel order',
|
||||
type: UiSnackbarType.error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _removePosition(int index) {
|
||||
if (_positions.length > 1) {
|
||||
setState(() => _positions.removeAt(index));
|
||||
@@ -788,6 +836,23 @@ class OrderEditSheetState extends State<OrderEditSheet> {
|
||||
label: 'Review ${_positions.length} Positions',
|
||||
onPressed: () => setState(() => _showReview = true),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
UiConstants.space5,
|
||||
0,
|
||||
UiConstants.space5,
|
||||
MediaQuery.of(context).padding.bottom + UiConstants.space2,
|
||||
),
|
||||
child: UiButton.secondary(
|
||||
text: 'Cancel Entire Order',
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: UiColors.destructive,
|
||||
side: const BorderSide(color: UiColors.destructive),
|
||||
),
|
||||
fullWidth: true,
|
||||
onPressed: _cancelOrder,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
||||
builder: (BuildContext context) => OrderEditSheet(
|
||||
order: order,
|
||||
onUpdated: () =>
|
||||
this.context.read<ViewOrdersCubit>().updateWeekOffset(0),
|
||||
ReadContext(context).read<ViewOrdersCubit>().updateWeekOffset(0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'src/domain/repositories/settings_repository_interface.dart';
|
||||
import 'src/domain/usecases/sign_out_usecase.dart';
|
||||
import 'src/presentation/blocs/client_settings_bloc.dart';
|
||||
import 'src/presentation/pages/client_settings_page.dart';
|
||||
import 'src/presentation/pages/edit_profile_page.dart';
|
||||
|
||||
/// A [Module] for the client settings feature.
|
||||
class ClientSettingsModule extends Module {
|
||||
@@ -30,5 +31,9 @@ class ClientSettingsModule extends Module {
|
||||
ClientPaths.childRoute(ClientPaths.settings, ClientPaths.settings),
|
||||
child: (_) => const ClientSettingsPage(),
|
||||
);
|
||||
r.child(
|
||||
'/edit-profile',
|
||||
child: (_) => const EditProfilePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,23 @@ class ClientSettingsBloc extends Bloc<ClientSettingsEvent, ClientSettingsState>
|
||||
: _signOutUseCase = signOutUseCase,
|
||||
super(const ClientSettingsInitial()) {
|
||||
on<ClientSettingsSignOutRequested>(_onSignOutRequested);
|
||||
on<ClientSettingsNotificationToggled>(_onNotificationToggled);
|
||||
}
|
||||
final SignOutUseCase _signOutUseCase;
|
||||
|
||||
void _onNotificationToggled(
|
||||
ClientSettingsNotificationToggled event,
|
||||
Emitter<ClientSettingsState> emit,
|
||||
) {
|
||||
if (event.type == 'push') {
|
||||
emit(state.copyWith(pushEnabled: event.isEnabled));
|
||||
} else if (event.type == 'email') {
|
||||
emit(state.copyWith(emailEnabled: event.isEnabled));
|
||||
} else if (event.type == 'sms') {
|
||||
emit(state.copyWith(smsEnabled: event.isEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSignOutRequested(
|
||||
ClientSettingsSignOutRequested event,
|
||||
Emitter<ClientSettingsState> emit,
|
||||
|
||||
@@ -10,3 +10,15 @@ abstract class ClientSettingsEvent extends Equatable {
|
||||
class ClientSettingsSignOutRequested extends ClientSettingsEvent {
|
||||
const ClientSettingsSignOutRequested();
|
||||
}
|
||||
|
||||
class ClientSettingsNotificationToggled extends ClientSettingsEvent {
|
||||
const ClientSettingsNotificationToggled({
|
||||
required this.type,
|
||||
required this.isEnabled,
|
||||
});
|
||||
final String type;
|
||||
final bool isEnabled;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[type, isEnabled];
|
||||
}
|
||||
|
||||
@@ -1,10 +1,49 @@
|
||||
part of 'client_settings_bloc.dart';
|
||||
|
||||
abstract class ClientSettingsState extends Equatable {
|
||||
const ClientSettingsState();
|
||||
class ClientSettingsState extends Equatable {
|
||||
const ClientSettingsState({
|
||||
this.isLoading = false,
|
||||
this.isSignOutSuccess = false,
|
||||
this.errorMessage,
|
||||
this.pushEnabled = true,
|
||||
this.emailEnabled = false,
|
||||
this.smsEnabled = true,
|
||||
});
|
||||
|
||||
final bool isLoading;
|
||||
final bool isSignOutSuccess;
|
||||
final String? errorMessage;
|
||||
final bool pushEnabled;
|
||||
final bool emailEnabled;
|
||||
final bool smsEnabled;
|
||||
|
||||
ClientSettingsState copyWith({
|
||||
bool? isLoading,
|
||||
bool? isSignOutSuccess,
|
||||
String? errorMessage,
|
||||
bool? pushEnabled,
|
||||
bool? emailEnabled,
|
||||
bool? smsEnabled,
|
||||
}) {
|
||||
return ClientSettingsState(
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
isSignOutSuccess: isSignOutSuccess ?? this.isSignOutSuccess,
|
||||
errorMessage: errorMessage, // We reset error on copy
|
||||
pushEnabled: pushEnabled ?? this.pushEnabled,
|
||||
emailEnabled: emailEnabled ?? this.emailEnabled,
|
||||
smsEnabled: smsEnabled ?? this.smsEnabled,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[];
|
||||
List<Object?> get props => <Object?>[
|
||||
isLoading,
|
||||
isSignOutSuccess,
|
||||
errorMessage,
|
||||
pushEnabled,
|
||||
emailEnabled,
|
||||
smsEnabled,
|
||||
];
|
||||
}
|
||||
|
||||
class ClientSettingsInitial extends ClientSettingsState {
|
||||
@@ -12,18 +51,14 @@ class ClientSettingsInitial extends ClientSettingsState {
|
||||
}
|
||||
|
||||
class ClientSettingsLoading extends ClientSettingsState {
|
||||
const ClientSettingsLoading();
|
||||
const ClientSettingsLoading({super.pushEnabled, super.emailEnabled, super.smsEnabled}) : super(isLoading: true);
|
||||
}
|
||||
|
||||
class ClientSettingsSignOutSuccess extends ClientSettingsState {
|
||||
const ClientSettingsSignOutSuccess();
|
||||
const ClientSettingsSignOutSuccess() : super(isSignOutSuccess: true);
|
||||
}
|
||||
|
||||
class ClientSettingsError extends ClientSettingsState {
|
||||
|
||||
const ClientSettingsError(this.message);
|
||||
final String message;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[message];
|
||||
const ClientSettingsError(String message) : super(errorMessage: message);
|
||||
String get message => errorMessage!;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
|
||||
class EditProfilePage extends StatefulWidget {
|
||||
const EditProfilePage({super.key});
|
||||
|
||||
@override
|
||||
State<EditProfilePage> createState() => _EditProfilePageState();
|
||||
}
|
||||
|
||||
class _EditProfilePageState extends State<EditProfilePage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late TextEditingController _firstNameController;
|
||||
late TextEditingController _lastNameController;
|
||||
late TextEditingController _emailController;
|
||||
late TextEditingController _phoneController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Simulate current data
|
||||
_firstNameController = TextEditingController(text: 'John');
|
||||
_lastNameController = TextEditingController(text: 'Smith');
|
||||
_emailController = TextEditingController(text: 'john@smith.com');
|
||||
_phoneController = TextEditingController(text: '+1 (555) 123-4567');
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_firstNameController.dispose();
|
||||
_lastNameController.dispose();
|
||||
_emailController.dispose();
|
||||
_phoneController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.t.client_settings.edit_profile.title),
|
||||
elevation: 0,
|
||||
backgroundColor: UiColors.white,
|
||||
foregroundColor: UiColors.primary,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(UiConstants.space5),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Stack(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: UiColors.bgSecondary,
|
||||
child: const Icon(UiIcons.user, size: 40, color: UiColors.primary),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(UiConstants.space2),
|
||||
decoration: const BoxDecoration(
|
||||
color: UiColors.primary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(UiIcons.edit, size: 16, color: UiColors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: UiConstants.space8),
|
||||
|
||||
Text(
|
||||
context.t.client_settings.edit_profile.first_name,
|
||||
style: UiTypography.footnote2b.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
UiTextField(
|
||||
controller: _firstNameController,
|
||||
hintText: 'First Name',
|
||||
validator: (String? val) => (val?.isEmpty ?? true) ? 'Required' : null,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
Text(
|
||||
context.t.client_settings.edit_profile.last_name,
|
||||
style: UiTypography.footnote2b.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
UiTextField(
|
||||
controller: _lastNameController,
|
||||
hintText: 'Last Name',
|
||||
validator: (String? val) => (val?.isEmpty ?? true) ? 'Required' : null,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
Text(
|
||||
context.t.client_settings.edit_profile.email,
|
||||
style: UiTypography.footnote2b.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
UiTextField(
|
||||
controller: _emailController,
|
||||
hintText: 'Email',
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (String? val) => (val?.isEmpty ?? true) ? 'Required' : null,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
Text(
|
||||
context.t.client_settings.edit_profile.phone,
|
||||
style: UiTypography.footnote2b.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
UiTextField(
|
||||
controller: _phoneController,
|
||||
hintText: 'Phone',
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space10),
|
||||
|
||||
UiButton.primary(
|
||||
text: context.t.client_settings.edit_profile.save_button,
|
||||
fullWidth: true,
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: context.t.client_settings.edit_profile.success_message,
|
||||
type: UiSnackbarType.success,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,42 +17,20 @@ class SettingsActions extends StatelessWidget {
|
||||
final TranslationsClientSettingsProfileEn labels =
|
||||
t.client_settings.profile;
|
||||
|
||||
// Yellow button style matching the prototype
|
||||
final ButtonStyle yellowStyle = ElevatedButton.styleFrom(
|
||||
backgroundColor: UiColors.accent,
|
||||
foregroundColor: UiColors.accentForeground,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
),
|
||||
);
|
||||
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: UiConstants.space5),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate(<Widget>[
|
||||
const SizedBox(height: UiConstants.space5),
|
||||
|
||||
// Edit Profile button (yellow)
|
||||
UiButton.primary(
|
||||
text: labels.edit_profile,
|
||||
style: yellowStyle,
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
// Hubs button (yellow)
|
||||
UiButton.primary(
|
||||
text: labels.hubs,
|
||||
style: yellowStyle,
|
||||
onPressed: () => Modular.to.toClientHubs(),
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
// Quick Links card
|
||||
_QuickLinksCard(labels: labels),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
// Notifications section
|
||||
_NotificationsSettingsCard(),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
|
||||
// Log Out button (outlined)
|
||||
BlocBuilder<ClientSettingsBloc, ClientSettingsState>(
|
||||
builder: (BuildContext context, ClientSettingsState state) {
|
||||
@@ -193,3 +171,93 @@ class _QuickLinkItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NotificationsSettingsCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ClientSettingsBloc, ClientSettingsState>(
|
||||
builder: (context, state) {
|
||||
return Card(
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
side: const BorderSide(color: UiColors.border),
|
||||
),
|
||||
color: UiColors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
context.t.client_settings.preferences.title,
|
||||
style: UiTypography.footnote1b.textPrimary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
_NotificationToggle(
|
||||
icon: UiIcons.bell,
|
||||
title: context.t.client_settings.preferences.push,
|
||||
value: state.pushEnabled,
|
||||
onChanged: (val) => ReadContext(context).read<ClientSettingsBloc>().add(
|
||||
ClientSettingsNotificationToggled(type: 'push', isEnabled: val),
|
||||
),
|
||||
),
|
||||
_NotificationToggle(
|
||||
icon: UiIcons.mail,
|
||||
title: context.t.client_settings.preferences.email,
|
||||
value: state.emailEnabled,
|
||||
onChanged: (val) => ReadContext(context).read<ClientSettingsBloc>().add(
|
||||
ClientSettingsNotificationToggled(type: 'email', isEnabled: val),
|
||||
),
|
||||
),
|
||||
_NotificationToggle(
|
||||
icon: UiIcons.phone,
|
||||
title: context.t.client_settings.preferences.sms,
|
||||
value: state.smsEnabled,
|
||||
onChanged: (val) => ReadContext(context).read<ClientSettingsBloc>().add(
|
||||
ClientSettingsNotificationToggled(type: 'sms', isEnabled: val),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NotificationToggle extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const _NotificationToggle({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: UiColors.iconSecondary),
|
||||
const SizedBox(width: UiConstants.space3),
|
||||
Text(title, style: UiTypography.footnote1m.textPrimary),
|
||||
],
|
||||
),
|
||||
Switch.adaptive(
|
||||
value: value,
|
||||
activeColor: UiColors.primary,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,21 @@ class SettingsProfileHeader extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: UiConstants.space5),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 100),
|
||||
child: UiButton.secondary(
|
||||
text: labels.edit_profile,
|
||||
size: UiButtonSize.small,
|
||||
onPressed: () =>
|
||||
Modular.to.pushNamed('${ClientPaths.settings}/edit-profile'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: UiColors.white,
|
||||
side: const BorderSide(color: UiColors.white, width: 1.5),
|
||||
backgroundColor: UiColors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user