mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
Merge pull request #1462 from cake-tech/CW-621-Open-external-sites-in-default-browser
Some checks are pending
Cache Dependencies / test (push) Waiting to run
Some checks are pending
Cache Dependencies / test (push) Waiting to run
CW-621 Open external sites in default browser
This commit is contained in:
commit
c5d3cbf66c
10 changed files with 194 additions and 34 deletions
|
@ -2,7 +2,6 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/anonpay_transaction_ro
|
||||||
import 'package:cake_wallet/src/screens/dashboard/widgets/order_row.dart';
|
import 'package:cake_wallet/src/screens/dashboard/widgets/order_row.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/placeholder_theme.dart';
|
import 'package:cake_wallet/themes/extensions/placeholder_theme.dart';
|
||||||
import 'package:cake_wallet/src/widgets/dashboard_card_widget.dart';
|
import 'package:cake_wallet/src/widgets/dashboard_card_widget.dart';
|
||||||
import 'package:cake_wallet/utils/device_info.dart';
|
|
||||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
|
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/order_list_item.dart';
|
import 'package:cake_wallet/view_model/dashboard/order_list_item.dart';
|
||||||
|
@ -53,11 +52,7 @@ class TransactionsPage extends StatelessWidget {
|
||||||
try {
|
try {
|
||||||
final uri = Uri.parse(
|
final uri = Uri.parse(
|
||||||
"https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/");
|
"https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/");
|
||||||
if (DeviceInfo.instance.isMobile) {
|
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
Navigator.of(context).pushNamed(Routes.webViewPage, arguments: ['', uri]);
|
|
||||||
} else {
|
|
||||||
launchUrl(uri);
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
},
|
},
|
||||||
title: S.of(context).syncing_wallet_alert_title,
|
title: S.of(context).syncing_wallet_alert_title,
|
||||||
|
|
|
@ -46,10 +46,6 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
bool _checked = false;
|
bool _checked = false;
|
||||||
String _fileText = '';
|
String _fileText = '';
|
||||||
|
|
||||||
Future<void> launchUrl(String url) async {
|
|
||||||
if (await canLaunch(url)) await launch(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future getFileLines() async {
|
Future getFileLines() async {
|
||||||
_fileText = await rootBundle.loadString(
|
_fileText = await rootBundle.loadString(
|
||||||
isMoneroOnly
|
isMoneroOnly
|
||||||
|
@ -152,7 +148,11 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => launchUrl(changenowUrl),
|
onTap: () async {
|
||||||
|
final uri = Uri.parse(changenowUrl);
|
||||||
|
if (await canLaunchUrl(uri))
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
changenowUrl,
|
changenowUrl,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
|
|
163
lib/src/screens/ionia/auth/ionia_create_account_page.dart
Normal file
163
lib/src/screens/ionia/auth/ionia_create_account_page.dart
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||||
|
import 'package:cake_wallet/core/email_validator.dart';
|
||||||
|
import 'package:cake_wallet/ionia/ionia_create_state.dart';
|
||||||
|
import 'package:cake_wallet/routes.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
|
import 'package:cake_wallet/typography.dart';
|
||||||
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
|
import 'package:cake_wallet/view_model/ionia/ionia_auth_view_model.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
class IoniaCreateAccountPage extends BasePage {
|
||||||
|
IoniaCreateAccountPage(this._authViewModel)
|
||||||
|
: _emailFocus = FocusNode(),
|
||||||
|
_emailController = TextEditingController(),
|
||||||
|
_formKey = GlobalKey<FormState>() {
|
||||||
|
_emailController.text = _authViewModel.email;
|
||||||
|
_emailController.addListener(() => _authViewModel.email = _emailController.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
final IoniaAuthViewModel _authViewModel;
|
||||||
|
|
||||||
|
final GlobalKey<FormState> _formKey;
|
||||||
|
|
||||||
|
final FocusNode _emailFocus;
|
||||||
|
final TextEditingController _emailController;
|
||||||
|
|
||||||
|
static const privacyPolicyUrl = 'https://ionia.docsend.com/view/jhjvdn7qq7k3ukwt';
|
||||||
|
static const termsAndConditionsUrl = 'https://ionia.docsend.com/view/uceirymz2ijacq5g';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget middle(BuildContext context) {
|
||||||
|
return Text(
|
||||||
|
S.current.sign_up,
|
||||||
|
style: textMediumSemiBold(
|
||||||
|
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget body(BuildContext context) {
|
||||||
|
reaction((_) => _authViewModel.createUserState, (IoniaCreateAccountState state) {
|
||||||
|
if (state is IoniaCreateStateFailure) {
|
||||||
|
_onCreateUserFailure(context, state.error);
|
||||||
|
}
|
||||||
|
if (state is IoniaCreateStateSuccess) {
|
||||||
|
_onCreateSuccessful(context, _authViewModel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ScrollableWithBottomSection(
|
||||||
|
contentPadding: EdgeInsets.all(24),
|
||||||
|
content: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: BaseTextFormField(
|
||||||
|
hintText: S.of(context).email_address,
|
||||||
|
focusNode: _emailFocus,
|
||||||
|
validator: EmailValidator(),
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
controller: _emailController,
|
||||||
|
onSubmit: (_) => _createAccount(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomSectionPadding: EdgeInsets.symmetric(vertical: 36, horizontal: 24),
|
||||||
|
bottomSection: Column(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
Observer(
|
||||||
|
builder: (_) => LoadingPrimaryButton(
|
||||||
|
text: S.of(context).create_account,
|
||||||
|
onPressed: _createAccount,
|
||||||
|
isLoading:
|
||||||
|
_authViewModel.createUserState is IoniaCreateStateLoading,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
textColor: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
text: S.of(context).agree_to,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Color(0xff7A93BA),
|
||||||
|
fontSize: 12,
|
||||||
|
fontFamily: 'Lato',
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: S.of(context).settings_terms_and_conditions,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () async {
|
||||||
|
final uri = Uri.parse(termsAndConditionsUrl);
|
||||||
|
if (await canLaunchUrl(uri))
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextSpan(text: ' ${S.of(context).and} '),
|
||||||
|
TextSpan(
|
||||||
|
text: S.of(context).privacy_policy,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () async {
|
||||||
|
final uri = Uri.parse(privacyPolicyUrl);
|
||||||
|
if (await canLaunchUrl(uri))
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
}),
|
||||||
|
TextSpan(text: ' ${S.of(context).by_cake_pay}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onCreateUserFailure(BuildContext context, String error) {
|
||||||
|
showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertWithOneAction(
|
||||||
|
alertTitle: S.current.create_account,
|
||||||
|
alertContent: error,
|
||||||
|
buttonText: S.of(context).ok,
|
||||||
|
buttonAction: () => Navigator.of(context).pop());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onCreateSuccessful(BuildContext context, IoniaAuthViewModel authViewModel) => Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
Routes.ioniaVerifyIoniaOtpPage,
|
||||||
|
arguments: [authViewModel.email, false],
|
||||||
|
);
|
||||||
|
|
||||||
|
void _createAccount() async {
|
||||||
|
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await _authViewModel.createUser(_emailController.text);
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,8 @@ class SettingsLinkProviderCell extends StandardListRow {
|
||||||
|
|
||||||
static void _launchUrl(String url) async {
|
static void _launchUrl(String url) async {
|
||||||
try {
|
try {
|
||||||
await launch(url, forceSafariVC: false);
|
final uri = Uri.parse(url);
|
||||||
|
if (await canLaunchUrl(uri)) await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,27 +161,26 @@ class YatPopup extends StatelessWidget {
|
||||||
onClose: onClose,
|
onClose: onClose,
|
||||||
onGet: () {
|
onGet: () {
|
||||||
var createNewYatUrl = YatLink.startFlowUrl;
|
var createNewYatUrl = YatLink.startFlowUrl;
|
||||||
final createNewYatUrlParameters = dashboardViewModel.
|
final createNewYatUrlParameters =
|
||||||
yatStore.defineQueryParameters();
|
dashboardViewModel.yatStore.defineQueryParameters();
|
||||||
|
|
||||||
if (createNewYatUrlParameters.isNotEmpty) {
|
if (createNewYatUrlParameters.isNotEmpty) {
|
||||||
createNewYatUrl += '?sub1=' + createNewYatUrlParameters;
|
createNewYatUrl += '?sub1=' + createNewYatUrlParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(createNewYatUrl, forceSafariVC: false);
|
final uri = Uri.parse(createNewYatUrl);
|
||||||
|
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
},
|
},
|
||||||
onConnect: () {
|
onConnect: () {
|
||||||
String url = baseUrl + YatLink.signInSuffix;
|
String url = baseUrl + YatLink.signInSuffix;
|
||||||
final parameters = dashboardViewModel
|
final parameters = dashboardViewModel.yatStore.defineQueryParameters();
|
||||||
.yatStore.defineQueryParameters();
|
|
||||||
if (parameters.isNotEmpty) {
|
if (parameters.isNotEmpty) {
|
||||||
url += YatLink.queryParameter + parameters;
|
url += YatLink.queryParameter + parameters;
|
||||||
}
|
}
|
||||||
launch(url, forceSafariVC: false);
|
final uri = Uri.parse(url);
|
||||||
}
|
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
))
|
}))
|
||||||
: Container()
|
: Container())
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,8 @@ class _ServicesUpdatesWidgetState extends State<ServicesUpdatesWidget> {
|
||||||
child: PrimaryImageButton(
|
child: PrimaryImageButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
try {
|
try {
|
||||||
launchUrl(Uri.parse("https://status.cakewallet.com/"));
|
launchUrl(Uri.parse("https://status.cakewallet.com/"),
|
||||||
|
mode: LaunchMode.externalApplication);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
},
|
},
|
||||||
image: Image.asset(
|
image: Image.asset(
|
||||||
|
|
|
@ -101,13 +101,13 @@ abstract class OrderDetailsViewModelBase with Store {
|
||||||
TrackTradeListItem(
|
TrackTradeListItem(
|
||||||
title: S.current.track,
|
title: S.current.track,
|
||||||
value: buildURL,
|
value: buildURL,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
try {
|
try {
|
||||||
launch(buildURL);
|
final uri = Uri.parse(buildURL);
|
||||||
|
if (await canLaunchUrl(uri))
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ abstract class TradeDetailsViewModelBase with Store {
|
||||||
void _launchUrl(String url) {
|
void _launchUrl(String url) {
|
||||||
final uri = Uri.parse(url);
|
final uri = Uri.parse(url);
|
||||||
try {
|
try {
|
||||||
launchUrl(uri);
|
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,10 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
items.add(BlockExplorerListItem(
|
items.add(BlockExplorerListItem(
|
||||||
title: S.current.view_in_block_explorer,
|
title: S.current.view_in_block_explorer,
|
||||||
value: _explorerDescription(type),
|
value: _explorerDescription(type),
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
try {
|
try {
|
||||||
launch(_explorerUrl(type, tx.id));
|
final uri = Uri.parse(_explorerUrl(type, tx.id));
|
||||||
|
if (await canLaunchUrl(uri)) await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
try {
|
try {
|
||||||
final url = Uri.parse(_explorerUrl(_type, unspentCoinsItem.hash));
|
final url = Uri.parse(_explorerUrl(_type, unspentCoinsItem.hash));
|
||||||
return launchUrl(url);
|
return launchUrl(url, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue