Skip to content

Commit

Permalink
make homepage reflect lsp state
Browse files Browse the repository at this point in the history
  • Loading branch information
ubbabeck committed Aug 18, 2023
1 parent 6da042d commit 7388c8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions lib/routes/home/widgets/status_text.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/bloc/account/account_bloc.dart';
import 'package:c_breez/bloc/account/account_state.dart';
import 'package:c_breez/bloc/ext/block_builder_extensions.dart';
import 'package:c_breez/bloc/lsp/lsp_bloc.dart';
import 'package:c_breez/bloc/lsp/lsp_state.dart';
import 'package:c_breez/theme/theme_provider.dart';
import 'package:c_breez/utils/min_font_size.dart';
import 'package:c_breez/widgets/loading_animated_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class StatusText extends StatelessWidget {
final String? message;
Expand All @@ -23,14 +29,20 @@ class StatusText extends StatelessWidget {
final texts = context.texts();
final themeData = Theme.of(context);

return AutoSizeText(
texts.status_text_ready,
style: themeData.textTheme.bodyMedium?.copyWith(
color: themeData.isLightTheme ? BreezColors.grey[600] : themeData.colorScheme.onSecondary,
),
textAlign: TextAlign.center,
minFontSize: MinFontSize(context).minFontSize,
stepGranularity: 0.1,
return BlocBuilder2<AccountBloc, AccountState, LSPBloc, LspState?>(
builder: (context, accountState, lspState) {
return AutoSizeText(
(lspState != null && lspState.isChannelOpeningAvailiable && accountState.maxInboundLiquidity <= 0)
? texts.status_text_ready
: texts.lsp_error_cannot_open_channel,
style: themeData.textTheme.bodyMedium?.copyWith(
color: themeData.isLightTheme ? BreezColors.grey[600] : themeData.colorScheme.onSecondary,
),
textAlign: TextAlign.center,
minFontSize: MinFontSize(context).minFontSize,
stepGranularity: 0.1,
);
},
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/payment_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PaymentValidator {
} on PaymentExcededLiqudityChannelCreationNotPossibleError catch (e) {
return texts.lnurl_fetch_invoice_error_max(currency.format(e.limitSat));
} on NoChannelCreationZeroLiqudityError {
return "You cannot receive funds, channel creation not possible.";
return texts.lsp_error_cannot_open_channel;
} catch (e) {
_log.v("Got Generic error", ex: e);
return texts.invoice_payment_validator_error_unknown(
Expand Down

0 comments on commit 7388c8d

Please sign in to comment.