Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,399 changes: 699 additions & 700 deletions assets/translations/en.json

Large diffs are not rendered by default.

26 changes: 10 additions & 16 deletions lib/bloc/withdraw_form/withdraw_form_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,30 +369,24 @@ class WithdrawFormBloc extends Bloc<WithdrawFormEvent, WithdrawFormState> {
WithdrawFormIbcChannelChanged event,
Emitter<WithdrawFormState> emit,
) {
final ibcChannelError = _validateIbcChannel(event.channel);
if (event.channel.isEmpty) {
emit(
state.copyWith(
ibcChannel: () => event.channel,
ibcChannelError: () => TextError(error: LocaleKeys.enterIbcChannel.tr()),
),
);
return;
}

emit(
state.copyWith(
ibcChannel: () => event.channel,
ibcChannelError: () => ibcChannelError,
ibcChannelError: () => null,
),
);
}

/// Validate format: channel-{number}
TextError? _validateIbcChannel(String channel) {
if (channel.isEmpty) {
return TextError(error: 'Channel ID is required');
}

final channelRegex = RegExp(r'^channel-\d+$');
if (!channelRegex.hasMatch(channel)) {
return TextError(error: 'Invalid format. Use: channel-<number>');
}

return null;
}

Future<void> _onPreviewSubmitted(
WithdrawFormPreviewSubmitted event,
Emitter<WithdrawFormState> emit,
Expand Down
2 changes: 1 addition & 1 deletion lib/bloc/withdraw_form/withdraw_form_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class WithdrawFormState extends Equatable {
memo: memo,
ibcTransfer: isIbcTransfer ? true : null,
ibcSourceChannel:
ibcChannel?.isNotEmpty == true ? ibcChannel!.trim() : null,
ibcChannel?.isNotEmpty == true ? int.tryParse(ibcChannel!.trim()) : null,
isMax: isMaxAmount,
);
}
Expand Down
135 changes: 46 additions & 89 deletions lib/generated/codegen_loader.g.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
import 'package:web_dex/generated/codegen_loader.g.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:decimal/decimal.dart';
Expand Down Expand Up @@ -579,68 +580,24 @@ class IbcTransferField extends StatelessWidget {
}
}

class IbcChannelField extends StatefulWidget {
class IbcChannelField extends StatelessWidget {
const IbcChannelField({super.key});

@override
State<IbcChannelField> createState() => _IbcChannelFieldState();
}

class _IbcChannelFieldState extends State<IbcChannelField> {
late final TextEditingController _controller;

@override
void initState() {
super.initState();
_controller = TextEditingController();
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocConsumer<WithdrawFormBloc, WithdrawFormState>(
listenWhen: (previous, current) =>
previous.ibcChannel != current.ibcChannel &&
current.ibcChannel != _controller.text,
listener: (context, state) {
// Only update controller if the bloc state differs from current text
// This prevents the cursor from jumping when user is typing
if (state.ibcChannel != _controller.text) {
_controller.text = state.ibcChannel ?? '';
}
},
buildWhen: (previous, current) =>
previous.ibcChannelError != current.ibcChannelError,
return BlocBuilder<WithdrawFormBloc, WithdrawFormState>(
builder: (context, state) {
return UiTextFormField(
key: const Key('withdraw-ibc-channel-input'),
controller: _controller,
labelText: LocaleKeys.ibcChannel.tr(),
hintText: LocaleKeys.ibcChannelHint.tr(),
errorText: state.ibcChannelError?.message,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (value) {
context
.read<WithdrawFormBloc>()
.add(WithdrawFormIbcChannelChanged(value ?? ''));
},
validator: (value) {
if (value?.isEmpty ?? true) {
return LocaleKeys.ibcChannelRequired.tr();
}

// Validate format: channel-<number>
final channelRegex = RegExp(r'^channel-\d+$');
if (!channelRegex.hasMatch(value!)) {
return LocaleKeys.ibcChannelInvalidFormat.tr();
}

return null;
},
);
},
);
Expand Down
6 changes: 3 additions & 3 deletions packages/komodo_ui_kit/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ packages:
description:
path: "packages/komodo_defi_rpc_methods"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -104,7 +104,7 @@ packages:
description:
path: "packages/komodo_defi_types"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -113,7 +113,7 @@ packages:
description:
path: "packages/komodo_ui"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ packages:
description:
path: "packages/komodo_cex_market_data"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.0.1"
Expand All @@ -665,7 +665,7 @@ packages:
description:
path: "packages/komodo_coin_updates"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "1.0.0"
Expand All @@ -674,7 +674,7 @@ packages:
description:
path: "packages/komodo_coins"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -683,7 +683,7 @@ packages:
description:
path: "packages/komodo_defi_framework"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0"
Expand All @@ -692,7 +692,7 @@ packages:
description:
path: "packages/komodo_defi_local_auth"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -701,7 +701,7 @@ packages:
description:
path: "packages/komodo_defi_rpc_methods"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -710,7 +710,7 @@ packages:
description:
path: "packages/komodo_defi_sdk"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -719,7 +719,7 @@ packages:
description:
path: "packages/komodo_defi_types"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -735,7 +735,7 @@ packages:
description:
path: "packages/komodo_ui"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -751,7 +751,7 @@ packages:
description:
path: "packages/komodo_wallet_build_transformer"
ref: dev
resolved-ref: a44acf31e94fa4973ba59940abeceaf1f38839ec
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand Down
Loading