refactor of usecases

This commit is contained in:
2026-02-23 17:18:50 +05:30
parent 56666ece30
commit 13f8003bda
37 changed files with 1563 additions and 105 deletions

View File

@@ -7,6 +7,7 @@ import 'domain/usecases/get_payment_history_usecase.dart';
import 'data/repositories/payments_repository_impl.dart';
import 'presentation/blocs/payments/payments_bloc.dart';
import 'presentation/pages/payments_page.dart';
import 'presentation/pages/early_pay_page.dart';
class StaffPaymentsModule extends Module {
@override
@@ -28,5 +29,9 @@ class StaffPaymentsModule extends Module {
StaffPaths.childRoute(StaffPaths.payments, StaffPaths.payments),
child: (BuildContext context) => const PaymentsPage(),
);
r.child(
'/early-pay',
child: (BuildContext context) => const EarlyPayPage(),
);
}
}

View File

@@ -0,0 +1,110 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:core_localization/core_localization.dart';
class EarlyPayPage extends StatelessWidget {
const EarlyPayPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(context.t.staff_payments.early_pay.title),
elevation: 0,
backgroundColor: UiColors.white,
foregroundColor: UiColors.primary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(UiConstants.space5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: const EdgeInsets.all(UiConstants.space6),
decoration: BoxDecoration(
color: UiColors.primary.withValues(alpha: 0.05),
borderRadius: UiConstants.radius2xl,
border: Border.all(color: UiColors.primary.withValues(alpha: 0.1)),
),
child: Column(
children: [
Text(
context.t.staff_payments.early_pay.available_label,
style: UiTypography.body2m.textSecondary,
),
const SizedBox(height: 8),
Text(
'\$340.00',
style: UiTypography.secondaryDisplay1b.primary,
),
],
),
),
const SizedBox(height: 32),
Text(
context.t.staff_payments.early_pay.select_amount,
style: UiTypography.headline4m.textPrimary,
),
const SizedBox(height: 16),
UiTextField(
hintText: context.t.staff_payments.early_pay.hint_amount,
keyboardType: TextInputType.number,
prefixIcon: UiIcons.chart, // Currency icon if available
),
const SizedBox(height: 32),
Text(
context.t.staff_payments.early_pay.deposit_to,
style: UiTypography.body2b.textPrimary,
),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: UiColors.white,
borderRadius: UiConstants.radiusLg,
border: Border.all(color: UiColors.separatorPrimary),
),
child: Row(
children: [
const Icon(UiIcons.bank, size: 24, color: UiColors.primary),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Chase Bank', style: UiTypography.body2b.textPrimary),
Text('Ending in 4321', style: UiTypography.footnote2r.textSecondary),
],
),
),
const Icon(UiIcons.chevronRight, size: 18, color: UiColors.iconSecondary),
],
),
),
const SizedBox(height: 40),
UiButton.primary(
text: context.t.staff_payments.early_pay.confirm_button,
fullWidth: true,
onPressed: () {
UiSnackbar.show(
context,
message: context.t.staff_payments.early_pay.success_message,
type: UiSnackbarType.success,
);
Navigator.pop(context);
},
),
const SizedBox(height: 16),
Center(
child: Text(
context.t.staff_payments.early_pay.fee_notice,
style: UiTypography.footnote2r.textSecondary,
textAlign: TextAlign.center,
),
),
],
),
),
);
}
}

View File

@@ -1,4 +1,5 @@
import 'package:design_system/design_system.dart';
import 'package:krow_core/core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';
@@ -178,7 +179,7 @@ class _PaymentsPageState extends State<PaymentsPage> {
PendingPayCard(
amount: state.summary.pendingEarnings,
onCashOut: () {
Modular.to.pushNamed('/early-pay');
Modular.to.pushNamed('${StaffPaths.payments}early-pay');
},
),
const SizedBox(height: UiConstants.space6),

View File

@@ -120,8 +120,17 @@ class EarningsGraph extends StatelessWidget {
}
List<FlSpot> _generateSpots(List<StaffPayment> data) {
if (data.isEmpty) return [];
// If only one data point, add a dummy point at the start to create a horizontal line
if (data.length == 1) {
return [
FlSpot(0, data[0].amount),
FlSpot(1, data[0].amount),
];
}
// Generate spots based on index in the list for simplicity in this demo
// Real implementation would map to actual dates on X-axis
return List<FlSpot>.generate(data.length, (int index) {
return FlSpot(index.toDouble(), data[index].amount);
});

View File

@@ -60,6 +60,15 @@ class PendingPayCard extends StatelessWidget {
),
],
),
UiButton.secondary(
text: 'Early Pay',
onPressed: onCashOut,
size: UiButtonSize.small,
style: OutlinedButton.styleFrom(
backgroundColor: UiColors.white,
foregroundColor: UiColors.primary,
),
),
],
),
);