Skip to content

Commit 95f6e61

Browse files
Merge pull request #1320 from cypherstack/feat/shopinbit
ShopinBit changes in response to feedback
2 parents 778e2bd + 12e207d commit 95f6e61

7 files changed

Lines changed: 334 additions & 153 deletions

File tree

lib/pages/shopinbit/shopinbit_payment_view.dart

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import 'dart:async';
22
import 'dart:io';
33

44
import 'package:decimal/decimal.dart';
5-
import 'package:flutter/gestures.dart';
65
import 'package:flutter/material.dart';
76
import 'package:flutter/services.dart';
87
import 'package:flutter_riverpod/flutter_riverpod.dart';
98
import 'package:flutter_svg/svg.dart';
10-
import 'package:url_launcher/url_launcher.dart';
119

1210
import '../../app_config.dart';
1311
import '../../models/isar/models/ethereum/eth_contract.dart';
@@ -33,7 +31,6 @@ import '../../widgets/desktop/primary_button.dart';
3331
import '../../widgets/desktop/secondary_button.dart';
3432
import '../../widgets/rounded_white_container.dart';
3533
import 'shopinbit_send_from_view.dart';
36-
import 'shopinbit_tickets_view.dart';
3734

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

5047
class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
51-
bool _termsAccepted = false;
5248
bool _loading = false;
5349
int _selectedMethod = 0;
5450
Timer? _pollTimer;
@@ -76,8 +72,7 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
7672
'payment_processing',
7773
}.contains(_status);
7874

79-
bool get _payNowEnabled =>
80-
_termsAccepted && !_isExpiredOrInvalid && !_isTerminal;
75+
bool get _payNowEnabled => !_isExpiredOrInvalid && !_isTerminal;
8176

8277
@override
8378
void initState() {
@@ -160,11 +155,6 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
160155
}
161156
}
162157

163-
Future<void> _openTerms() async {
164-
const url = "https://api.shopinbit.com/static/policy/terms.html";
165-
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
166-
}
167-
168158
Future<void> _checkForPayment() async {
169159
_pollTimer?.cancel();
170160
setState(() => _loading = true);
@@ -334,6 +324,14 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
334324
Navigator.of(context).pop();
335325
}
336326

327+
void _navigateToTickets() {
328+
if (Util.isDesktop) {
329+
Navigator.of(context, rootNavigator: true).pop();
330+
} else {
331+
Navigator.of(context).popUntil((route) => route.isFirst);
332+
}
333+
}
334+
337335
void _navigateToSendFrom({
338336
required CryptoCurrency coin,
339337
required Amount? amount,
@@ -469,16 +467,6 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
469467
);
470468
}
471469

472-
void _copyAddress(BuildContext context) {
473-
Clipboard.setData(ClipboardData(text: _currentAddress));
474-
showFloatingFlushBar(
475-
type: FlushBarType.info,
476-
message: "Copied to clipboard",
477-
iconAsset: Assets.svg.copy,
478-
context: context,
479-
);
480-
}
481-
482470
@override
483471
Widget build(BuildContext context) {
484472
final isDesktop = Util.isDesktop;
@@ -709,59 +697,15 @@ class _ShopInBitPaymentViewState extends ConsumerState<ShopInBitPaymentView> {
709697
],
710698
),
711699
),
700+
SizedBox(height: isDesktop ? 16 : 12),
701+
PrimaryButton(
702+
label: "View My Requests",
703+
onPressed: _navigateToTickets,
704+
),
712705
],
713706
SizedBox(height: isDesktop ? 24 : 16),
714707
// Coin list (replaces tab selector + QR + address + global button)
715708
if (!_isExpiredOrInvalid) ...coinRows,
716-
SizedBox(height: isDesktop ? 16 : 12),
717-
GestureDetector(
718-
onTap: () {
719-
setState(() {
720-
_termsAccepted = !_termsAccepted;
721-
});
722-
},
723-
child: Container(
724-
color: Colors.transparent,
725-
child: Row(
726-
crossAxisAlignment: CrossAxisAlignment.start,
727-
children: [
728-
SizedBox(
729-
width: 20,
730-
height: 20,
731-
child: IgnorePointer(
732-
child: Checkbox(
733-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
734-
value: _termsAccepted,
735-
onChanged: (_) {},
736-
),
737-
),
738-
),
739-
const SizedBox(width: 12),
740-
Expanded(
741-
child: RichText(
742-
text: TextSpan(
743-
style: isDesktop
744-
? STextStyles.desktopTextExtraExtraSmall(context)
745-
: STextStyles.w500_14(context),
746-
children: [
747-
const TextSpan(text: "I accept the "),
748-
TextSpan(
749-
text: "Terms & Conditions",
750-
style: STextStyles.richLink(
751-
context,
752-
).copyWith(fontSize: isDesktop ? null : 14),
753-
recognizer: TapGestureRecognizer()
754-
..onTap = _openTerms,
755-
),
756-
const TextSpan(text: "."),
757-
],
758-
),
759-
),
760-
),
761-
],
762-
),
763-
),
764-
),
765709
],
766710
);
767711

lib/pages/shopinbit/shopinbit_shipping_view.dart

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
55
import 'package:flutter_svg/svg.dart';
66

77
import '../../models/shopinbit/shopinbit_order_model.dart';
8-
import '../../notifications/show_flush_bar.dart';
98
import '../../services/shopinbit/shopinbit_service.dart';
109
import '../../services/shopinbit/src/models/address.dart';
1110
import '../../themes/stack_colors.dart';
@@ -105,6 +104,10 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
105104
_billingCityFocusNode = FocusNode();
106105
_billingPostalCodeFocusNode = FocusNode();
107106

107+
_selectedCountryIso = widget.model.deliveryCountry.isNotEmpty
108+
? widget.model.deliveryCountry
109+
: null;
110+
108111
for (final node in [
109112
_nameFocusNode,
110113
_streetFocusNode,
@@ -372,15 +375,9 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
372375
_countrySearchController.clear();
373376
}
374377
},
375-
onChanged: _loadingCountries
376-
? null
377-
: (value) {
378-
setState(() {
379-
_selectedCountryIso = value;
380-
});
381-
},
378+
onChanged: null,
382379
hint: Text(
383-
_loadingCountries ? "Loading countries..." : "Country",
380+
"Country",
384381
style: isDesktop
385382
? STextStyles.desktopTextExtraSmall(context).copyWith(
386383
color: Theme.of(context)
@@ -677,7 +674,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
677674
),
678675
),
679676
],
680-
const Spacer(),
677+
const SizedBox(height: 24),
681678
PrimaryButton(
682679
label: _submitting ? "Submitting..." : "Continue to payment",
683680
enabled: _canContinue,
@@ -689,7 +686,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
689686
if (isDesktop) {
690687
return DesktopDialog(
691688
maxWidth: 580,
692-
maxHeight: 600,
689+
maxHeight: 700,
693690
child: Column(
694691
children: [
695692
Row(
@@ -711,7 +708,7 @@ class _ShopInBitShippingViewState extends State<ShopInBitShippingView> {
711708
horizontal: 32,
712709
vertical: 16,
713710
),
714-
child: content,
711+
child: SingleChildScrollView(child: content),
715712
),
716713
),
717714
],

lib/pages/shopinbit/shopinbit_step_2.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,24 @@ class _ShopInBitStep2State extends State<ShopInBitStep2> {
5454

5555
void _continue() {
5656
widget.model.category = _selected;
57+
final skipGuidelines = ShopInBitService.instance.loadGuidelinesAccepted();
5758

5859
final skipGuidelines = ShopInBitService.instance.loadGuidelinesAccepted();
5960

6061
if (Util.isDesktop) {
6162
Navigator.of(context, rootNavigator: true).pop();
62-
showDialog<void>(
63-
context: context,
64-
barrierDismissible: false,
65-
builder: (_) => ShopInBitStep3(model: widget.model),
66-
);
63+
if (skipGuidelines) {
64+
widget.model.guidelinesAccepted = true;
65+
Navigator.of(
66+
context,
67+
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
68+
} else {
69+
Navigator.of(
70+
context,
71+
).pushNamed(ShopInBitStep3.routeName, arguments: widget.model);
72+
}
6773
} else {
6874
if (skipGuidelines) {
69-
// Returning user — skip guidelines.
7075
widget.model.guidelinesAccepted = true;
7176
Navigator.of(
7277
context,

0 commit comments

Comments
 (0)