Skip to content

Commit

Permalink
ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii-Borodenko committed Nov 26, 2024
1 parent ffa380e commit 17f70fe
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/src/screens/unspent_coins/unspent_coins_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class UnspentCoinsListPage extends BasePage {
final UnspentCoinsListViewModel unspentCoinsListViewModel;

Future<void> handleOnPopInvoked(BuildContext context) async {
if (unspentCoinsListViewModel.items.isEmpty) {
final hasChanged = unspentCoinsListViewModel.hasAdjustableFieldChanged;
if (unspentCoinsListViewModel.items.isEmpty || !hasChanged) {
Navigator.of(context).pop();
} else {
unspentCoinsListViewModel.isDisposing = true;
Expand Down Expand Up @@ -98,7 +99,6 @@ class UnspentCoinsListFormState extends State<UnspentCoinsListForm> {
context: context,
builder: (BuildContext context) {
return AlertWithNoAction(
alertTitle: '',
alertContent: 'Updating, please wait…',
alertBarrierDismissible: false,
);
Expand Down Expand Up @@ -153,7 +153,7 @@ class UnspentCoinsListFormState extends State<UnspentCoinsListForm> {
SizedBox(height: 15),
Expanded(
child: unspentCoinsListViewModel.items.isEmpty
? Center(child: Text('No unspent coins available\ntry to reconnect'))
? Center(child: Text('No unspent coins available\ntry to reconnect',textAlign: TextAlign.center))
: ListView.separated(
itemCount: unspentCoinsListViewModel.items.length,
separatorBuilder: (_, __) => SizedBox(height: 15),
Expand Down
8 changes: 4 additions & 4 deletions lib/src/widgets/alert_with_no_action.dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';

class AlertWithNoAction extends BaseAlertDialog {
AlertWithNoAction({
required this.alertTitle,
this.alertTitle,
required this.alertContent,
this.alertBarrierDismissible = true,
Key? key,
});

final String alertTitle;
final String? alertTitle;
final String alertContent;
final bool alertBarrierDismissible;

@override
String get titleText => alertTitle;
String? get titleText => alertTitle;

@override
String get contentText => alertContent;
Expand All @@ -26,5 +26,5 @@ class AlertWithNoAction extends BaseAlertDialog {
bool get isBottomDividerExists => false;

@override
Widget actionButtons(BuildContext context) => Container(height: 60);
Widget actionButtons(BuildContext context) => Container();
}
7 changes: 4 additions & 3 deletions lib/src/widgets/base_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
class BaseAlertDialog extends StatelessWidget {
String? get headerText => '';

String get titleText => '';
String? get titleText => '';

String get contentText => '';

Expand Down Expand Up @@ -43,7 +43,7 @@ class BaseAlertDialog extends StatelessWidget {

Widget title(BuildContext context) {
return Text(
titleText,
titleText!,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
Expand Down Expand Up @@ -191,10 +191,11 @@ class BaseAlertDialog extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
if (headerText?.isNotEmpty ?? false) headerTitle(context),
titleText != null ?
Padding(
padding: EdgeInsets.fromLTRB(24, 20, 24, 0),
child: title(context),
),
) : SizedBox(height: 16),
isDividerExists
? Padding(
padding: EdgeInsets.only(top: 16, bottom: 8),
Expand Down
32 changes: 30 additions & 2 deletions lib/view_model/unspent_coins/unspent_coins_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ abstract class UnspentCoinsListViewModelBase with Store {
required Box<UnspentCoinsInfo> unspentCoinsInfo,
this.coinTypeToSpendFrom = UnspentCoinType.any,
}) : _unspentCoinsInfo = unspentCoinsInfo,
items = ObservableList<UnspentCoinsItem>();
items = ObservableList<UnspentCoinsItem>(),
_originalState = {};

final WalletBase wallet;
final Box<UnspentCoinsInfo> _unspentCoinsInfo;
Expand All @@ -32,13 +33,40 @@ abstract class UnspentCoinsListViewModelBase with Store {
@observable
ObservableList<UnspentCoinsItem> items;

final Map<String, Map<String, dynamic>> _originalState;

@observable
bool isDisposing = false;

@computed
bool get isAllSelected => items.every((element) => element.isFrozen || element.isSending);

Future<void> initialSetup() async => await _updateUnspents();
Future<void> initialSetup() async {
await _updateUnspents();
_storeOriginalState();
}

void _storeOriginalState() {
_originalState.clear();
for (final item in items) {
_originalState[item.hash] = {
'isFrozen': item.isFrozen,
'note': item.note,
'isSending': item.isSending,
};
}
}

bool _hasAdjustableFieldChanged(UnspentCoinsItem item) {
final original = _originalState[item.hash];
if (original == null) return false;
return original['isFrozen'] != item.isFrozen ||
original['note'] != item.note ||
original['isSending'] != item.isSending;
}

bool get hasAdjustableFieldChanged => items.any(_hasAdjustableFieldChanged);


Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
try {
Expand Down

0 comments on commit 17f70fe

Please sign in to comment.