style: apply dart format tall style and fix curly braces lints
This commit is contained in:
@@ -7,5 +7,8 @@ abstract class HiPayRemoteDatasource {
|
||||
Future<bool> getProcessCard(String url);
|
||||
Future<List<PaymentCardModel>> getTopupCards();
|
||||
Future<void> deleteTopupCard(String topupCardId);
|
||||
Future<PayinResponseModel> payin({required String topupCardId, required double amount});
|
||||
Future<PayinResponseModel> payin({
|
||||
required String topupCardId,
|
||||
required double amount,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ class HiPayRepositoryImpl implements HiPayRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PayinResponseEntity> payin({required String topupCardId, required double amount}) async {
|
||||
Future<PayinResponseEntity> payin({
|
||||
required String topupCardId,
|
||||
required double amount,
|
||||
}) async {
|
||||
final model = await _remote.payin(topupCardId: topupCardId, amount: amount);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@@ -7,5 +7,8 @@ abstract class HiPayRepository {
|
||||
Future<bool> getProcessCard(String url);
|
||||
Future<List<PaymentCardEntity>> getTopupCards();
|
||||
Future<void> deleteTopupCard(String topupCardId);
|
||||
Future<PayinResponseEntity> payin({required String topupCardId, required double amount});
|
||||
Future<PayinResponseEntity> payin({
|
||||
required String topupCardId,
|
||||
required double amount,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ import 'package:payments/src/core/domain/entities/payin_response_entity.dart';
|
||||
import 'package:payments/src/core/domain/repositories/hipay_repository.dart';
|
||||
|
||||
abstract class PayinUseCase {
|
||||
Future<PayinResponseEntity> call({required String topupCardId, required double amount});
|
||||
Future<PayinResponseEntity> call({
|
||||
required String topupCardId,
|
||||
required double amount,
|
||||
});
|
||||
}
|
||||
|
||||
class PayinUseCaseImpl implements PayinUseCase {
|
||||
@@ -10,7 +13,10 @@ class PayinUseCaseImpl implements PayinUseCase {
|
||||
final HiPayRepository _repository;
|
||||
|
||||
@override
|
||||
Future<PayinResponseEntity> call({required String topupCardId, required double amount}) {
|
||||
Future<PayinResponseEntity> call({
|
||||
required String topupCardId,
|
||||
required double amount,
|
||||
}) {
|
||||
return _repository.payin(topupCardId: topupCardId, amount: amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ class _PayinBottomSheetState extends ConsumerState<PayinBottomSheet> {
|
||||
Future<void> _addCard() async {
|
||||
final result = await Navigator.of(context).push<HiPayResult>(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => HiPayWebViewScreen(navigationContract: widget.navigation),
|
||||
builder: (_) =>
|
||||
HiPayWebViewScreen(navigationContract: widget.navigation),
|
||||
),
|
||||
);
|
||||
if (result == HiPayResult.success && mounted) {
|
||||
@@ -51,8 +52,13 @@ class _PayinBottomSheetState extends ConsumerState<PayinBottomSheet> {
|
||||
if (next.success && !(prev?.success ?? false)) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
if (next.errorMessage.isNotEmpty && next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
showTopSnackbar(context, message: context.translate(I18n.payinError), type: MessageType.error);
|
||||
if (next.errorMessage.isNotEmpty &&
|
||||
next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.payinError),
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,7 +91,12 @@ class _PayinBottomSheetState extends ConsumerState<PayinBottomSheet> {
|
||||
else if (viewState.cards.isEmpty)
|
||||
_buildNoCards(context, theme)
|
||||
else
|
||||
_buildCardList(context, theme, viewState.cards, viewState.selectedCard),
|
||||
_buildCardList(
|
||||
context,
|
||||
theme,
|
||||
viewState.cards,
|
||||
viewState.selectedCard,
|
||||
),
|
||||
if (viewState.cards.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
TextButton(
|
||||
@@ -94,8 +105,11 @@ class _PayinBottomSheetState extends ConsumerState<PayinBottomSheet> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
PrimaryButton(
|
||||
onPressed: viewState.selectedCard != null && !viewState.isProcessing
|
||||
? () => ref.read(payinViewModelProvider.notifier).executePayin(widget.amount)
|
||||
onPressed:
|
||||
viewState.selectedCard != null && !viewState.isProcessing
|
||||
? () => ref
|
||||
.read(payinViewModelProvider.notifier)
|
||||
.executePayin(widget.amount)
|
||||
: null,
|
||||
text: viewState.isProcessing
|
||||
? context.translate(I18n.payinProcessing)
|
||||
@@ -166,10 +180,14 @@ class _PayinBottomSheetState extends ConsumerState<PayinBottomSheet> {
|
||||
style: TextStyle(color: theme.getColorFor(ThemeCode.textPrimary)),
|
||||
),
|
||||
trailing: isSelected
|
||||
? Icon(Icons.check_circle, color: theme.getColorFor(ThemeCode.buttonPrimary))
|
||||
? Icon(
|
||||
Icons.check_circle,
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
)
|
||||
: null,
|
||||
selected: isSelected,
|
||||
onTap: () => ref.read(payinViewModelProvider.notifier).selectCard(card),
|
||||
onTap: () =>
|
||||
ref.read(payinViewModelProvider.notifier).selectCard(card),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -4,7 +4,9 @@ import 'package:payments/src/features/payin/presentation/payin_view_state.dart';
|
||||
import 'package:payments/src/features/payin/providers/payin_providers.dart';
|
||||
|
||||
final payinViewModelProvider =
|
||||
NotifierProvider.autoDispose<PayinViewModel, PayinViewState>(PayinViewModel.new);
|
||||
NotifierProvider.autoDispose<PayinViewModel, PayinViewState>(
|
||||
PayinViewModel.new,
|
||||
);
|
||||
|
||||
class PayinViewModel extends Notifier<PayinViewState> {
|
||||
@override
|
||||
@@ -17,7 +19,9 @@ class PayinViewModel extends Notifier<PayinViewState> {
|
||||
try {
|
||||
final allCards = await ref.read(getPaymentCardsUseCaseProvider).call();
|
||||
if (!ref.mounted) return;
|
||||
final cards = allCards.where((c) => c.status.toLowerCase() == 'validated').toList();
|
||||
final cards = allCards
|
||||
.where((c) => c.status.toLowerCase() == 'validated')
|
||||
.toList();
|
||||
state = state.copyWith(isLoadingCards: false, cards: cards);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
@@ -35,10 +39,9 @@ class PayinViewModel extends Notifier<PayinViewState> {
|
||||
|
||||
state = state.copyWith(isProcessing: true, errorMessage: '');
|
||||
try {
|
||||
await ref.read(payinUseCaseProvider).call(
|
||||
topupCardId: card.topupCardId,
|
||||
amount: amount,
|
||||
);
|
||||
await ref
|
||||
.read(payinUseCaseProvider)
|
||||
.call(topupCardId: card.topupCardId, amount: amount);
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isProcessing: false, success: true);
|
||||
} catch (e) {
|
||||
|
||||
@@ -7,6 +7,7 @@ final payinUseCaseProvider = Provider.autoDispose<PayinUseCase>((ref) {
|
||||
return PayinUseCaseImpl(ref.read(hipayRepositoryProvider));
|
||||
});
|
||||
|
||||
final getPaymentCardsUseCaseProvider = Provider.autoDispose<GetPaymentCardsUseCase>((ref) {
|
||||
return GetPaymentCardsUseCaseImpl(ref.read(hipayRepositoryProvider));
|
||||
});
|
||||
final getPaymentCardsUseCaseProvider =
|
||||
Provider.autoDispose<GetPaymentCardsUseCase>((ref) {
|
||||
return GetPaymentCardsUseCaseImpl(ref.read(hipayRepositoryProvider));
|
||||
});
|
||||
|
||||
@@ -3,7 +3,9 @@ import 'package:payments/src/core/providers/hipay_repository_provider.dart';
|
||||
import 'package:payments/src/features/topup_cards/domain/use_cases/topup_cards_use_case.dart';
|
||||
import 'package:payments/src/features/topup_cards/domain/use_cases/topup_cards_use_case_impl.dart';
|
||||
|
||||
final topupCardsUseCaseProvider = Provider.autoDispose<TopupCardsUseCase>((ref) {
|
||||
final topupCardsUseCaseProvider = Provider.autoDispose<TopupCardsUseCase>((
|
||||
ref,
|
||||
) {
|
||||
final repository = ref.read(hipayRepositoryProvider);
|
||||
return TopupCardsUseCaseImpl(repository);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user