Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed pro mode remarks #191

Merged
merged 1 commit into from
Mar 17, 2020
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
9 changes: 1 addition & 8 deletions lib/redux/actions/pro_mode_wallet_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:fusecash/models/pro/token.dart';
import 'package:fusecash/models/transactions/transfer.dart';
import 'package:fusecash/redux/state/store.dart';
import 'package:fusecash/services.dart';
import 'package:fusecash/utils/addresses.dart';
import 'package:redux_thunk/redux_thunk.dart';
import 'package:redux/redux.dart';
import 'package:wallet_core/wallet_core.dart' as wallet_core;
Expand Down Expand Up @@ -73,7 +72,6 @@ ThunkAction startListenToTransferEvents() {
return (Store store) async {
new Timer.periodic(Duration(seconds: 5), (Timer timer) async {
store.dispatch(getAccountTokens());
// store.dispatch(getForeignTransfersEvents(timer));
});
store.dispatch(new StartListenToTransferEventsSuccess());
};
Expand All @@ -84,13 +82,8 @@ ThunkAction getAccountTokens() {
final logger = await AppFactory().getLogger('action');

try {
wallet_core.Web3 web3 = store.state.proWalletState.web3;
if (web3 == null) {
throw "Web3 is empty";
}

String walletAddress = store.state.userState.walletAddress;
dynamic response = await graph.getAccountTokens(walletAddress, daiTokenAddress);
dynamic response = await graph.getAccountTokens(walletAddress);
List<dynamic> accounts = List<dynamic>.from(response);
if (accounts.isNotEmpty) {
Map<String, dynamic> accountsBalances = Map<String, dynamic>.from(accounts[0]);
Expand Down
104 changes: 71 additions & 33 deletions lib/screens/cash_home/dai_explained.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_segment/flutter_segment.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fusecash/generated/i18n.dart';
import 'package:fusecash/models/app_state.dart';
import 'package:fusecash/models/community.dart';
import 'package:fusecash/screens/cash_home/webview_page.dart';
import 'package:fusecash/screens/routes.gr.dart';
import 'package:fusecash/screens/send/send_amount_arguments.dart';
import 'package:fusecash/widgets/activate_pro_mode.dart';
import 'package:fusecash/widgets/bottombar.dart';
import 'package:fusecash/widgets/main_scaffold.dart';
import 'package:flushbar/flushbar.dart';
import 'package:redux/redux.dart';

class DaiExplainedScreen extends StatefulWidget {
@override
Expand Down Expand Up @@ -244,40 +250,55 @@ class _DaiExplainedScreenState extends State<DaiExplainedScreen> {
],
),
),
InkWell(
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return ActivateProModeDialog();
});
Segment.track(eventName: "Wallet: Withdraw DAI clicked");
},
child: Align(
alignment: Alignment.centerLeft,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Withdraw DAI',
style: TextStyle(
fontSize: 16,
color:
Theme.of(context).textTheme.headline.color,
fontWeight: FontWeight.bold),
),
SizedBox(
width: 5,
),
Image.asset(
'assets/images/arrow_black.png',
width: 15,
height: 12,
new StoreConnector<AppState, _DaiPointsViewModel>(
converter: _DaiPointsViewModel.fromStore,
builder: (_, vm) {
return InkWell(
onTap: () {
if (vm.isProModeActivate) {
Router.navigator.pushNamed(Router.sendAmountScreen,
arguments: SendAmountArguments(
sendType: SendType.FUSE_ADDRESS,
accountAddress:
vm.daiPointsHomeBridgeAddress));
} else {
showDialog(
context: context,
builder: (BuildContext context) {
return ActivateProModeDialog();
});
Segment.track(eventName: "Wallet: Withdraw DAI clicked");
}
},
child: Align(
alignment: Alignment.centerLeft,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Withdraw DAI',
style: TextStyle(
fontSize: 16,
color: Theme.of(context)
.textTheme
.headline
.color,
fontWeight: FontWeight.bold),
),
SizedBox(
width: 5,
),
Image.asset(
'assets/images/arrow_black.png',
width: 15,
height: 12,
),
],
),
],
),
),
),
);
},
)
],
),
Expand Down Expand Up @@ -320,3 +341,20 @@ class _DaiExplainedScreenState extends State<DaiExplainedScreen> {
]);
}
}

class _DaiPointsViewModel {
final bool isProModeActivate;
final String daiPointsHomeBridgeAddress;
_DaiPointsViewModel({this.isProModeActivate, this.daiPointsHomeBridgeAddress});

static _DaiPointsViewModel fromStore(Store<AppState> store) {
String communityAddres =
DotEnv().env['DEFAULT_COMMUNITY_CONTRACT_ADDRESS'].toLowerCase();
Community community =
store.state.cashWalletState.communities[communityAddres];
return _DaiPointsViewModel(
daiPointsHomeBridgeAddress: community.homeBridgeAddress,
isProModeActivate: store.state.userState.isProModeActivated,
);
}
}
11 changes: 7 additions & 4 deletions lib/screens/pro_mode/pro_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class _DrawerWidgetState extends State<DrawerWidget> {
return Column(
children: <Widget>[
Expanded(
flex: 5,
child: ListView(
padding: EdgeInsets.all(10),
children: <Widget>[
Expand All @@ -263,10 +264,12 @@ class _DrawerWidgetState extends State<DrawerWidget> {
],
),
),
Padding(
child: switchToCashMode(viewModel),
padding: EdgeInsets.all(20),
),
Flexible(
flex: 1,
child: Padding(
child: switchToCashMode(viewModel),
padding: EdgeInsets.all(20),
)),
],
);
},
Expand Down
57 changes: 34 additions & 23 deletions lib/screens/pro_mode/pro_transactios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fusecash/generated/i18n.dart';
import 'package:fusecash/models/pro/token.dart';
import 'package:fusecash/models/pro/views/pro_wallet.dart';
import 'package:fusecash/utils/addresses.dart';

class ProTransactios extends StatelessWidget {
ProTransactios({this.viewModel});
Expand Down Expand Up @@ -98,30 +99,40 @@ class _TokenRow extends StatelessWidget {
children: <Widget>[
new RichText(
text: new TextSpan(children: <TextSpan>[
new TextSpan(
text:
'\$' + token.amount.toStringAsFixed(3),
style: new TextStyle(
// color: deduceColor(transfer),
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary)),
// new TextSpan(
// text: " ${token.symbol}",
// style: new TextStyle(
// // color: deduceColor(transfer),
// fontSize: 10.0,
// fontWeight: FontWeight.normal,
// color: Theme.of(context).primaryColor)),
token.address.contains(daiTokenAddress)
? new TextSpan(
text: '\$' +
token.amount.toStringAsFixed(2),
style: new TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.colorScheme
.secondary))
: new TextSpan(
text: token.amount.toStringAsFixed(2) +
' ' +
token.symbol,
style: new TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.colorScheme
.secondary)),
])),
Positioned(
bottom: -20,
child: Padding(
child: Text(token.amount.toStringAsFixed(3) + ' ' + token.symbol,
style: TextStyle(
color: Color(0xFF8D8D8D),
fontSize: 10)),
padding: EdgeInsets.only(top: 10)))
token.address.contains(daiTokenAddress)
? Positioned(
bottom: -20,
child: Padding(
child: Text(
token.amount.toStringAsFixed(2) +
' ' +
token.symbol,
style: TextStyle(
color: Color(0xFF8D8D8D),
fontSize: 10)),
padding: EdgeInsets.only(top: 10)))
: SizedBox.shrink()
],
)
],
Expand Down
69 changes: 37 additions & 32 deletions lib/screens/send/receive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:qr_flutter/qr_flutter.dart';
import 'package:share/share.dart';

class ReceiveScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
return new StoreConnector<AppState, ReceiveModel>(
Expand All @@ -26,52 +25,58 @@ class ReceiveScreen extends StatelessWidget {
withPadding: false,
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * 0.7,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.only(
left: 20.0, right: 20.0, bottom: 20.0, top: 20.0),
left: 20.0, right: 20.0, bottom: 20.0, top: 20),
child: Text(I18n.of(context).scan_to_receive,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontSize: 16,
fontWeight: FontWeight.normal)),
),
Center(
child: Container(
width: 200,
child: new QrImage(
data: 'fuse:${viewModel.walletAddress}',
)),
),
const SizedBox(height: 20.0),
Container(
width: 220,
child: new Text(formatAddress(viewModel.walletAddress),
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 16,
fontWeight: FontWeight.normal)),
),
const SizedBox(height: 20.0),
Container(
width: 250,
child: Opacity(
opacity: 0.5,
child: Center(
child: CopyToClipboard(
textColor: Color(0xFF0091ff),
content: viewModel.walletAddress,
Column(
children: <Widget>[
Center(
child: Container(
width: 200,
child: new QrImage(
data: 'fuse:${viewModel.walletAddress}',
)),
),
const SizedBox(height: 20.0),
Container(
width: 220,
child: new Text(
formatAddress(viewModel.walletAddress),
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 16,
fontWeight: FontWeight.normal)),
),
const SizedBox(height: 20.0),
Container(
width: 250,
child: Opacity(
opacity: 0.5,
child: Center(
child: CopyToClipboard(
textColor: Color(0xFF0091ff),
content: viewModel.walletAddress,
),
),
),
),
),
],
),
const SizedBox(height: 30.0),
// const SizedBox(height: 30.0),
Center(
child: PrimaryButton(
fontSize: 15,
Expand Down
Loading