feat(shopinbit): create DesktopServicesView container
What changed, and why it matters
This commit is a routine user-interface refactor for the Stack Wallet desktop app. It moves the existing ShopInBit service page into a new container so the app can show both 'Services' and 'Gift Cards' tabs. No security-sensitive logic was added or changed; the code that opens web links and starts shopping dialogs is copied unchanged into a new file.
No security action required. Review as normal UI code if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change splits desktop_services_view.dart into a parent tab container (DesktopServicesView) and a child view (DesktopShopInBitView). The original imports, state provider, browser-warning dialog, ShopInBit dialog, RichText terms/privacy links, url_launcher calls, and settings navigation logic are moved verbatim into the new file. A new StateProvider
Changed components
lib/pages_desktop_specific/more_view/sub_widgets/desktop_services_view.dartlib/pages_desktop_specific/more_view/sub_widgets/desktop_shopinbit_view.dartInspect captured patch +417 / −284
diff --git a/lib/pages_desktop_specific/more_view/sub_widgets/desktop_services_view.dart b/lib/pages_desktop_specific/more_view/sub_widgets/desktop_services_view.dart
index 983804c..4ecc0e9 100644
--- a/lib/pages_desktop_specific/more_view/sub_widgets/desktop_services_view.dart
+++ b/lib/pages_desktop_specific/more_view/sub_widgets/desktop_services_view.dart
@@ -1,23 +1,18 @@
-import 'package:flutter/gestures.dart';
import 'package:flutter/material.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 '../../../db/isar/main_db.dart';
-import '../../../models/shopinbit/shopinbit_order_model.dart';
-import '../../../pages/shopinbit/shopinbit_step_1.dart';
-import '../../../pages/shopinbit/shopinbit_tickets_view.dart';
-import '../../../providers/desktop/current_desktop_menu_item.dart';
+import '../../../route_generator.dart';
+import '../../../themes/stack_colors.dart';
import '../../../utilities/assets.dart';
import '../../../utilities/text_styles.dart';
-import '../../../widgets/desktop/desktop_dialog.dart';
-import '../../../widgets/desktop/primary_button.dart';
-import '../../../widgets/desktop/secondary_button.dart';
-import '../../../widgets/rounded_white_container.dart';
-import '../../desktop_menu.dart';
-import '../../settings/settings_menu.dart';
+import '../../../widgets/desktop/desktop_app_bar.dart';
+import '../../../widgets/desktop/desktop_scaffold.dart';
+import '../../settings/settings_menu_item.dart';
+import 'desktop_gift_cards_view.dart';
+import 'desktop_shopinbit_view.dart';
+
+final selectedServicesMenuItemStateProvider = StateProvider<int>((_) => 0);
class DesktopServicesView extends ConsumerStatefulWidget {
const DesktopServicesView({super.key});
@@ -30,285 +25,109 @@ class DesktopServicesView extends ConsumerStatefulWidget {
}
class _DesktopServicesViewState extends ConsumerState<DesktopServicesView> {
- Future<bool> _showOpenBrowserWarning(BuildContext context, String url) async {
- final uri = Uri.parse(url);
- final shouldContinue = await showDialog<bool>(
- context: context,
- barrierDismissible: false,
- builder: (_) => DesktopDialog(
- maxWidth: 550,
- maxHeight: 250,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
- child: Column(
- children: [
- Text("Attention", style: STextStyles.desktopH2(context)),
- const SizedBox(height: 16),
- Text(
- "You are about to open "
- "${uri.scheme}://${uri.host} "
- "in your browser.",
- style: STextStyles.desktopTextSmall(context),
- ),
- const SizedBox(height: 35),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- SecondaryButton(
- width: 200,
- buttonHeight: ButtonHeight.l,
- label: "Cancel",
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop(false);
- },
- ),
- const SizedBox(width: 20),
- PrimaryButton(
- width: 200,
- buttonHeight: ButtonHeight.l,
- label: "Continue",
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop(true);
- },
- ),
- ],
- ),
- ],
- ),
- ),
+ final List<String> _labels = const ["Services", "Gift Cards"];
+
+ @override
+ Widget build(BuildContext context) {
+ final List<Widget> contentViews = [
+ const Navigator(
+ key: Key("servicesShopInBitDesktopKey"),
+ onGenerateRoute: RouteGenerator.generateRoute,
+ initialRoute: DesktopShopInBitView.routeName,
),
- );
- return shouldContinue ?? false;
- }
+ const Navigator(
+ key: Key("servicesGiftCardsDesktopKey"),
+ onGenerateRoute: RouteGenerator.generateRoute,
+ initialRoute: DesktopGiftCardsView.routeName,
+ ),
+ ];
- void _showShopDialog(BuildContext context) {
- showDialog<void>(
- context: context,
- barrierDismissible: true,
- builder: (dialogContext) => DesktopDialog(
- maxWidth: 550,
- maxHeight: 300,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text("ShopInBit", style: STextStyles.desktopH2(dialogContext)),
- const SizedBox(height: 16),
- RichText(
- text: TextSpan(
- style: STextStyles.desktopTextSmall(dialogContext),
+ return DesktopScaffold(
+ background: Theme.of(context).extension<StackColors>()!.background,
+ appBar: DesktopAppBar(
+ isCompactHeight: true,
+ leading: Row(
+ children: [
+ const SizedBox(width: 24, height: 24),
+ Text("Services", style: STextStyles.desktopH3(context)),
+ ],
+ ),
+ ),
+ body: Row(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(15.0),
+ child: Align(
+ alignment: Alignment.topLeft,
+ child: SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const TextSpan(
- text:
- "Please note the following before proceeding:"
- "\n\n\u2022 Minimum order amount: 1,000 EUR"
- "\n\u2022 Service fee: 10% of the order total",
- // "\n\nBy continuing, you agree to the ShopInBit ",
+ SizedBox(
+ width: 250,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (int i = 0; i < _labels.length; i++)
+ Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (i > 0) const SizedBox(height: 2),
+ SettingsMenuItem<int>(
+ icon: SvgPicture.asset(
+ Assets.svg.polygon,
+ width: 11,
+ height: 11,
+ color:
+ ref
+ .watch(
+ selectedServicesMenuItemStateProvider
+ .state,
+ )
+ .state ==
+ i
+ ? Theme.of(
+ context,
+ )
+ .extension<StackColors>()!
+ .accentColorBlue
+ : Colors.transparent,
+ ),
+ label: _labels[i],
+ value: i,
+ group: ref
+ .watch(
+ selectedServicesMenuItemStateProvider
+ .state,
+ )
+ .state,
+ onChanged: (newValue) =>
+ ref
+ .read(
+ selectedServicesMenuItemStateProvider
+ .state,
+ )
+ .state =
+ newValue,
+ ),
+ ],
+ ),
+ ],
+ ),
),
- // TextSpan(
- // text: "Privacy Policy",
- // style: STextStyles.richLink(dialogContext).copyWith(
- // fontSize: 18,
- // ),
- // recognizer: TapGestureRecognizer()
- // ..onTap = () async {
- // const url =
- // "https://api.shopinbit.com/static/policy/privacy.html";
- // final shouldOpen =
- // await _showOpenBrowserWarning(dialogContext, url);
- // if (shouldOpen) {
- // await launchUrl(
- // Uri.parse(url),
- // mode: LaunchMode.externalApplication,
- // );
- // }
- // },
- // ),
- // const TextSpan(text: "."),
],
),
),
- const Spacer(),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- SecondaryButton(
- width: 200,
- buttonHeight: ButtonHeight.l,
- label: "Cancel",
- onPressed: () {
- Navigator.of(dialogContext, rootNavigator: true).pop();
- },
- ),
- const SizedBox(width: 20),
- PrimaryButton(
- width: 200,
- buttonHeight: ButtonHeight.l,
- label: "Continue",
- onPressed: () async {
- Navigator.of(dialogContext, rootNavigator: true).pop();
- await showDialog<void>(
- context: context,
- builder: (_) =>
- ShopInBitStep1(model: ShopInBitOrderModel()),
- );
- if (mounted) setState(() {});
- },
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- );
- }
-
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- Padding(
- padding: const EdgeInsets.only(right: 30),
- child: RoundedWhiteContainer(
- radiusMultiplier: 2,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: SvgPicture.asset(
- Assets.svg.circleSliders,
- width: 48,
- height: 48,
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: RichText(
- textAlign: TextAlign.start,
- text: TextSpan(
- style: STextStyles.desktopTextExtraExtraSmall(context),
- children: [
- TextSpan(
- text: "ShopInBit",
- style: STextStyles.desktopTextSmall(context),
- ),
- const TextSpan(
- text:
- "\n\nConcierge shopping service. Purchase "
- "products and services using cryptocurrency.\n\n"
- "Minimum order value of 1,000 EUR. "
- "A 10% service fee applies to all orders.\n\n"
- "By using ShopInBit, you agree to their ",
- ),
- TextSpan(
- text: "Terms & Conditions",
- style: STextStyles.richLink(context),
- recognizer: TapGestureRecognizer()
- ..onTap = () async {
- const url =
- "https://api.shopinbit.com/static/policy/terms.html";
- final shouldOpen = await _showOpenBrowserWarning(
- context,
- url,
- );
- if (shouldOpen) {
- await launchUrl(
- Uri.parse(url),
- mode: LaunchMode.externalApplication,
- );
- }
- },
- ),
- const TextSpan(text: " and "),
- TextSpan(
- text: "Privacy Policy",
- style: STextStyles.richLink(context),
- recognizer: TapGestureRecognizer()
- ..onTap = () async {
- const url =
- "https://api.shopinbit.com/static/policy/privacy.html";
- final shouldOpen = await _showOpenBrowserWarning(
- context,
- url,
- );
- if (shouldOpen) {
- await launchUrl(
- Uri.parse(url),
- mode: LaunchMode.externalApplication,
- );
- }
- },
- ),
- const TextSpan(text: "."),
- ],
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: Row(
- children: [
- PrimaryButton(
- width: 250,
- buttonHeight: ButtonHeight.m,
- enabled: true,
- label: "Shop with ShopInBit",
- onPressed: () => _showShopDialog(context),
- ),
- const SizedBox(width: 16),
- Builder(
- builder: (context) {
- final count = MainDB.instance
- .getShopInBitTickets()
- .length;
- return SecondaryButton(
- width: 200,
- buttonHeight: ButtonHeight.m,
- label: count > 0
- ? "My tickets ($count)"
- : "My tickets",
- onPressed: () async {
- await showDialog<void>(
- context: context,
- builder: (_) => const ShopInBitTicketsView(),
- );
- if (mounted) setState(() {});
- },
- );
- },
- ),
- const SizedBox(width: 16),
- SecondaryButton(
- width: 140,
- buttonHeight: ButtonHeight.m,
- label: "Settings",
- onPressed: () {
- // ShopInBit is the last settings menu item.
- var idx = 8;
- if (AppConfig.hasFeature(AppFeature.themeSelection)) {
- idx++;
- }
- ref
- .read(
- selectedSettingsMenuItemStateProvider.state,
- )
- .state =
- idx;
- ref.read(currentDesktopMenuItemProvider.state).state =
- DesktopMenuItemId.settings;
- },
- ),
- ],
- ),
- ),
- ],
),
),
- ),
- ],
+ Expanded(
+ child:
+ contentViews[ref
+ .watch(selectedServicesMenuItemStateProvider.state)
+ .state],
+ ),
+ ],
+ ),
);
}
}
diff --git a/lib/pages_desktop_specific/more_view/sub_widgets/desktop_shopinbit_view.dart b/lib/pages_desktop_specific/more_view/sub_widgets/desktop_shopinbit_view.dart
new file mode 100644
index 0000000..2935704
--- /dev/null
+++ b/lib/pages_desktop_specific/more_view/sub_widgets/desktop_shopinbit_view.dart
@@ -0,0 +1,314 @@
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.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 '../../../db/isar/main_db.dart';
+import '../../../models/shopinbit/shopinbit_order_model.dart';
+import '../../../pages/shopinbit/shopinbit_step_1.dart';
+import '../../../pages/shopinbit/shopinbit_tickets_view.dart';
+import '../../../providers/desktop/current_desktop_menu_item.dart';
+import '../../../utilities/assets.dart';
+import '../../../utilities/text_styles.dart';
+import '../../../widgets/desktop/desktop_dialog.dart';
+import '../../../widgets/desktop/primary_button.dart';
+import '../../../widgets/desktop/secondary_button.dart';
+import '../../../widgets/rounded_white_container.dart';
+import '../../desktop_menu.dart';
+import '../../settings/settings_menu.dart';
+
+class DesktopShopInBitView extends ConsumerStatefulWidget {
+ const DesktopShopInBitView({super.key});
+
+ static const String routeName = "/desktopShopInBitView";
+
+ @override
+ ConsumerState<DesktopShopInBitView> createState() =>
+ _DesktopServicesViewState();
+}
+
+class _DesktopServicesViewState extends ConsumerState<DesktopShopInBitView> {
+ Future<bool> _showOpenBrowserWarning(BuildContext context, String url) async {
+ final uri = Uri.parse(url);
+ final shouldContinue = await showDialog<bool>(
+ context: context,
+ barrierDismissible: false,
+ builder: (_) => DesktopDialog(
+ maxWidth: 550,
+ maxHeight: 250,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
+ child: Column(
+ children: [
+ Text("Attention", style: STextStyles.desktopH2(context)),
+ const SizedBox(height: 16),
+ Text(
+ "You are about to open "
+ "${uri.scheme}://${uri.host} "
+ "in your browser.",
+ style: STextStyles.desktopTextSmall(context),
+ ),
+ const SizedBox(height: 35),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ SecondaryButton(
+ width: 200,
+ buttonHeight: ButtonHeight.l,
+ label: "Cancel",
+ onPressed: () {
+ Navigator.of(context, rootNavigator: true).pop(false);
+ },
+ ),
+ const SizedBox(width: 20),
+ PrimaryButton(
+ width: 200,
+ buttonHeight: ButtonHeight.l,
+ label: "Continue",
+ onPressed: () {
+ Navigator.of(context, rootNavigator: true).pop(true);
+ },
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ return shouldContinue ?? false;
+ }
+
+ void _showShopDialog(BuildContext context) {
+ showDialog<void>(
+ context: context,
+ barrierDismissible: true,
+ builder: (dialogContext) => DesktopDialog(
+ maxWidth: 550,
+ maxHeight: 300,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text("ShopInBit", style: STextStyles.desktopH2(dialogContext)),
+ const SizedBox(height: 16),
+ RichText(
+ text: TextSpan(
+ style: STextStyles.desktopTextSmall(dialogContext),
+ children: [
+ const TextSpan(
+ text:
+ "Please note the following before proceeding:"
+ "\n\n\u2022 Minimum order amount: 1,000 EUR"
+ "\n\u2022 Service fee: 10% of the order total",
+ // "\n\nBy continuing, you agree to the ShopInBit ",
+ ),
+ // TextSpan(
+ // text: "Privacy Policy",
+ // style: STextStyles.richLink(dialogContext).copyWith(
+ // fontSize: 18,
+ // ),
+ // recognizer: TapGestureRecognizer()
+ // ..onTap = () async {
+ // const url =
+ // "https://api.shopinbit.com/static/policy/privacy.html";
+ // final shouldOpen =
+ // await _showOpenBrowserWarning(dialogContext, url);
+ // if (shouldOpen) {
+ // await launchUrl(
+ // Uri.parse(url),
+ // mode: LaunchMode.externalApplication,
+ // );
+ // }
+ // },
+ // ),
+ // const TextSpan(text: "."),
+ ],
+ ),
+ ),
+ const Spacer(),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ SecondaryButton(
+ width: 200,
+ buttonHeight: ButtonHeight.l,
+ label: "Cancel",
+ onPressed: () {
+ Navigator.of(dialogContext, rootNavigator: true).pop();
+ },
+ ),
+ const SizedBox(width: 20),
+ PrimaryButton(
+ width: 200,
+ buttonHeight: ButtonHeight.l,
+ label: "Continue",
+ onPressed: () async {
+ Navigator.of(dialogContext, rootNavigator: true).pop();
+ await showDialog<void>(
+ context: context,
+ builder: (_) =>
+ ShopInBitStep1(model: ShopInBitOrderModel()),
+ );
+ if (mounted) setState(() {});
+ },
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(right: 30),
+ child: RoundedWhiteContainer(
+ radiusMultiplier: 2,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: SvgPicture.asset(
+ Assets.svg.circleSliders,
+ width: 48,
+ height: 48,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(10),
+ child: RichText(
+ textAlign: TextAlign.start,
+ text: TextSpan(
+ style: STextStyles.desktopTextExtraExtraSmall(context),
+ children: [
+ TextSpan(
+ text: "ShopInBit",
+ style: STextStyles.desktopTextSmall(context),
+ ),
+ const TextSpan(
+ text:
+ "\n\nConcierge shopping service. Purchase "
+ "products and services using cryptocurrency.\n\n"
+ "Minimum order value of 1,000 EUR. "
+ "A 10% service fee applies to all orders.\n\n"
+ "By using ShopInBit, you agree to their ",
+ ),
+ TextSpan(
+ text: "Terms & Conditions",
+ style: STextStyles.richLink(context),
+ recognizer: TapGestureRecognizer()
+ ..onTap = () async {
+ const url =
+ "https://api.shopinbit.com/static/policy/terms.html";
+ final shouldOpen = await _showOpenBrowserWarning(
+ context,
+ url,
+ );
+ if (shouldOpen) {
+ await launchUrl(
+ Uri.parse(url),
+ mode: LaunchMode.externalApplication,
+ );
+ }
+ },
+ ),
+ const TextSpan(text: " and "),
+ TextSpan(
+ text: "Privacy Policy",
+ style: STextStyles.richLink(context),
+ recognizer: TapGestureRecognizer()
+ ..onTap = () async {
+ const url =
+ "https://api.shopinbit.com/static/policy/privacy.html";
+ final shouldOpen = await _showOpenBrowserWarning(
+ context,
+ url,
+ );
+ if (shouldOpen) {
+ await launchUrl(
+ Uri.parse(url),
+ mode: LaunchMode.externalApplication,
+ );
+ }
+ },
+ ),
+ const TextSpan(text: "."),
+ ],
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(10),
+ child: Row(
+ children: [
+ PrimaryButton(
+ width: 250,
+ buttonHeight: ButtonHeight.m,
+ enabled: true,
+ label: "Shop with ShopInBit",
+ onPressed: () => _showShopDialog(context),
+ ),
+ const SizedBox(width: 16),
+ Builder(
+ builder: (context) {
+ final count = MainDB.instance
+ .getShopInBitTickets()
+ .length;
+ return SecondaryButton(
+ width: 200,
+ buttonHeight: ButtonHeight.m,
+ label: count > 0
+ ? "My tickets ($count)"
+ : "My tickets",
+ onPressed: () async {
+ await showDialog<void>(
+ context: context,
+ builder: (_) => const ShopInBitTicketsView(),
+ );
+ if (mounted) setState(() {});
+ },
+ );
+ },
+ ),
+ const SizedBox(width: 16),
+ SecondaryButton(
+ width: 140,
+ buttonHeight: ButtonHeight.m,
+ label: "Settings",
+ onPressed: () {
+ // ShopInBit is the last settings menu item.
+ var idx = 8;
+ if (AppConfig.hasFeature(AppFeature.themeSelection)) {
+ idx++;
+ }
+ ref
+ .read(
+ selectedSettingsMenuItemStateProvider.state,
+ )
+ .state =
+ idx;
+ ref.read(currentDesktopMenuItemProvider.state).state =
+ DesktopMenuItemId.settings;
+ },
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.