Skip to content
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
84 changes: 14 additions & 70 deletions lib/pages/shopinbit/shopinbit_payment_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import 'dart:async';
import 'dart:io';

import 'package:decimal/decimal.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../app_config.dart';
import '../../models/isar/models/ethereum/eth_contract.dart';
Expand All @@ -33,7 +31,6 @@ import '../../widgets/desktop/primary_button.dart';
import '../../widgets/desktop/secondary_button.dart';
import '../../widgets/rounded_white_container.dart';
import 'shopinbit_send_from_view.dart';
import 'shopinbit_tickets_view.dart';

class ShopInBitPaymentView extends ConsumerStatefulWidget {
const ShopInBitPaymentView({super.key, required this.model});
Expand All @@ -48,7 +45,6 @@ class ShopInBitPaymentView extends ConsumerStatefulWidget {
}

class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
bool _termsAccepted = false;
bool _loading = false;
int _selectedMethod = 0;
Timer? _pollTimer;
Expand Down Expand Up @@ -76,8 +72,7 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
'payment_processing',
}.contains(_status);

bool get _payNowEnabled =>
_termsAccepted && !_isExpiredOrInvalid && !_isTerminal;
bool get _payNowEnabled => !_isExpiredOrInvalid && !_isTerminal;

@override
void initState() {
Expand Down Expand Up @@ -160,11 +155,6 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
}
}

Future<void> _openTerms() async {
const url = "https://api.shopinbit.com/static/policy/terms.html";
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
}

Future<void> _checkForPayment() async {
_pollTimer?.cancel();
setState(() => _loading = true);
Expand Down Expand Up @@ -334,6 +324,14 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
Navigator.of(context).pop();
}

void _navigateToTickets() {
if (Util.isDesktop) {
Navigator.of(context, rootNavigator: true).pop();
} else {
Navigator.of(context).popUntil((route) => route.isFirst);
}
}

void _navigateToSendFrom({
required CryptoCurrency coin,
required Amount? amount,
Expand Down Expand Up @@ -469,16 +467,6 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
);
}

void _copyAddress(BuildContext context) {
Clipboard.setData(ClipboardData(text: _currentAddress));
showFloatingFlushBar(
type: FlushBarType.info,
message: "Copied to clipboard",
iconAsset: Assets.svg.copy,
context: context,
);
}

@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
Expand Down Expand Up @@ -709,59 +697,15 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
],
),
),
SizedBox(height: isDesktop ? 16 : 12),
PrimaryButton(
label: "View My Requests",
onPressed: _navigateToTickets,
),
],
SizedBox(height: isDesktop ? 24 : 16),
// Coin list (replaces tab selector + QR + address + global button)
if (!_isExpiredOrInvalid) ...coinRows,
SizedBox(height: isDesktop ? 16 : 12),
GestureDetector(
onTap: () {
setState(() {
_termsAccepted = !_termsAccepted;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 20,
child: IgnorePointer(
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _termsAccepted,
onChanged: (_) {},
),
),
),
const SizedBox(width: 12),
Expanded(
child: RichText(
text: TextSpan(
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
: STextStyles.w500_14(context),
children: [
const TextSpan(text: "I accept the "),
TextSpan(
text: "Terms & Conditions",
style: STextStyles.richLink(
context,
).copyWith(fontSize: isDesktop ? null : 14),
recognizer: TapGestureRecognizer()
..onTap = _openTerms,
),
const TextSpan(text: "."),
],
),
),
),
],
),
),
),
],
);

Expand Down
21 changes: 9 additions & 12 deletions lib/pages/shopinbit/shopinbit_shipping_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

import '../../models/shopinbit/shopinbit_order_model.dart';
import '../../notifications/show_flush_bar.dart';
import '../../services/shopinbit/shopinbit_service.dart';
import '../../services/shopinbit/src/models/address.dart';
import '../../themes/stack_colors.dart';
Expand Down Expand Up @@ -105,6 +104,10 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
_billingCityFocusNode = FocusNode();
_billingPostalCodeFocusNode = FocusNode();

_selectedCountryIso = widget.model.deliveryCountry.isNotEmpty
? widget.model.deliveryCountry
: null;

for (final node in [
_nameFocusNode,
_streetFocusNode,
Expand Down Expand Up @@ -372,15 +375,9 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
_countrySearchController.clear();
}
},
onChanged: _loadingCountries
? null
: (value) {
setState(() {
_selectedCountryIso = value;
});
},
onChanged: null,
hint: Text(
_loadingCountries ? "Loading countries..." : "Country",
"Country",
style: isDesktop
? STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context)
Expand Down Expand Up @@ -677,7 +674,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
),
),
],
const Spacer(),
const SizedBox(height: 24),
PrimaryButton(
label: _submitting ? "Submitting..." : "Continue to payment",
enabled: _canContinue,
Expand All @@ -689,7 +686,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
if (isDesktop) {
return DesktopDialog(
maxWidth: 580,
maxHeight: 600,
maxHeight: 700,
child: Column(
children: [
Row(
Expand All @@ -711,7 +708,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
horizontal: 32,
vertical: 16,
),
child: content,
child: SingleChildScrollView(child: content),
),
),
],
Expand Down
17 changes: 11 additions & 6 deletions lib/pages/shopinbit/shopinbit_step_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,24 @@ class _ShopInBitStep2State extends State<ShopInBitStep2> {

void _continue() {
widget.model.category = _selected;
final skipGuidelines = ShopInBitService.instance.loadGuidelinesAccepted();

final skipGuidelines = ShopInBitService.instance.loadGuidelinesAccepted();

if (Util.isDesktop) {
Navigator.of(context, rootNavigator: true).pop();
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => ShopInBitStep3(model: widget.model),
);
if (skipGuidelines) {
widget.model.guidelinesAccepted = true;
Navigator.of(
context,
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
} else {
Navigator.of(
context,
).pushNamed(ShopInBitStep3.routeName, arguments: widget.model);
}
} else {
if (skipGuidelines) {
// Returning user — skip guidelines.
widget.model.guidelinesAccepted = true;
Navigator.of(
context,
Expand Down
Loading
Loading