2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/view_model/rescan_view_model.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
|
|
|
|
class RescanPage extends BasePage {
|
2020-09-21 11:50:26 +00:00
|
|
|
RescanPage(this._rescanViewModel)
|
|
|
|
: _blockchainHeightWidgetKey = GlobalKey<BlockchainHeightState>();
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
String get title => S.current.rescan;
|
2020-09-21 11:50:26 +00:00
|
|
|
final GlobalKey<BlockchainHeightState> _blockchainHeightWidgetKey;
|
|
|
|
final RescanViewModel _rescanViewModel;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
|
|
|
return Padding(
|
2020-05-29 15:10:11 +00:00
|
|
|
padding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
2020-01-04 19:31:52 +00:00
|
|
|
child:
|
|
|
|
Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
2020-11-12 19:03:57 +00:00
|
|
|
BlockchainHeightWidget(key: _blockchainHeightWidgetKey,
|
|
|
|
onHeightOrDateEntered: (value) =>
|
|
|
|
_rescanViewModel.isButtonEnabled = value),
|
2020-01-04 19:31:52 +00:00
|
|
|
Observer(
|
|
|
|
builder: (_) => LoadingPrimaryButton(
|
2020-09-21 11:50:26 +00:00
|
|
|
isLoading:
|
|
|
|
_rescanViewModel.state == RescanWalletState.rescaning,
|
|
|
|
text: S.of(context).rescan,
|
|
|
|
onPressed: () async {
|
|
|
|
await _rescanViewModel.rescanCurrentWallet(
|
|
|
|
restoreHeight:
|
2022-10-12 17:09:57 +00:00
|
|
|
_blockchainHeightWidgetKey.currentState!.height);
|
2020-09-21 11:50:26 +00:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2023-08-17 15:28:31 +00:00
|
|
|
color: Theme.of(context).primaryColor,
|
2020-09-21 11:50:26 +00:00
|
|
|
textColor: Colors.white,
|
2020-11-12 19:03:57 +00:00
|
|
|
isDisabled: !_rescanViewModel.isButtonEnabled,
|
2020-09-21 11:50:26 +00:00
|
|
|
))
|
2020-01-04 19:31:52 +00:00
|
|
|
]),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|