Skip to content

feat: share an order through the system share sheet - #672

Closed
21Mill wants to merge 2 commits into
MostroP2P:mainfrom
21Mill:feat/order-share-sheet
Closed

feat: share an order through the system share sheet#672
21Mill wants to merge 2 commits into
MostroP2P:mainfrom
21Mill:feat/order-share-sheet

Conversation

@21Mill

@21Mill 21Mill commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Depends on #669 and #673

Cut from feat/order-share-link, which is where OrderShareLinkCard lives. Until #669 merges this diff carries its commits too — review against that branch, or merge #669 first.

#673 fixes the receiving end (#670): until it lands, a recipient opening one of these links with the app closed does not reliably reach the order. Merge order: #673#669 → this.

Closes #671

Problem

#669 put the order's mostro: link on the detail screen with a copy button, which was the whole of what #451 asked for. Copying still means copy → leave the app → open the chat → paste.

There is also something the clipboard cannot do: send the link with an explanation. A bare mostro:8927bb1d-…?relays=… lands in a chat as an unexplained string, and most apps only linkify http(s), so the recipient gets neither a tappable link nor a hint of what they are looking at.

Change

A share button beside the copy one in OrderShareLinkCard, handing the link to the system share sheet wrapped in a sentence: "Take this order on Mostro: <link>".

Both actions stay. Copying is still faster when the destination is not an app — a password manager, a terminal, a QR generator.

The share call follows the pattern pay_lightning_invoice_widget.dart already uses: everything it needs is read from the context before the await, since this card is a ConsumerWidget and has no mounted to check afterwards, and a failure is reported through the snackbar instead of escaping. It passes sharePositionOrigin, which iPads need to anchor the sheet; the three existing Share.share calls in the repo omit it, and #80 will eventually want it.

Adds orderShareMessage and failedToShareOrder to the six locales. share_plus was already a direct dependency, so nothing new is pulled in.

The card now carries both actions, with the link still elided to two lines:

Order link card with the copy and share buttons side by side

Tapping share opens the system sheet with the link whole — sentence, three relays and the instance pubkey — which is what that elision hides:

System share sheet preview showing the sentence followed by the complete mostro link

Tests

test/shared/widgets/order_cards_test.dart, extending the group #669 added:

  • Tapping share invokes dev.fluttercommunity.plus/share with text containing the full link, and asserts the text does not start with mostro: — the sentence is the point, so its absence should fail the test.
  • The share button disappears along with the rest of the card when no relay can resolve the order.
  • A layout test: the card now holds two 48 dp buttons next to a link long enough to wrap, which is exactly the shape that produced the overflow in OrderFilter overflows horizontally by 41 px inside its fixed 320 px panel #654. Confirmed the test fails (RenderFlex overflowed by 152 pixels) against a card whose link is not flexible, so it is a real guard and not one that passes by construction.

Test plan

  • flutter gen-l10n — no untranslated messages
  • flutter analyze on lib/shared and test/shared — no issues
  • flutter test test/shared/widgets/order_cards_test.dart — 18 passing
  • Full flutter test — 901 passing, the same 11 pre-existing failures as on main (stale test/mocks.mocks.dart, repo issue Dart run build_runner build fails on Flutter 3.44.0, source_gen 3.1.0 incompatible with analyzer 8.x #606)
  • On device (Android 16, debug build): both buttons render without disturbing the link, the share sheet opens with the complete text, and copying still behaves as before
  • CI green

Known limitation

A shared mostro: link will not be tappable in most chat apps, so the recipient has to copy it and open it. Fixing that properly needs verified https links (App Links / Universal Links) redirecting to the scheme, which is a separate piece of work — worth its own issue if the maintainers want it.

Note also #670: opening a mostro: link while the app is not in the foreground currently crashes on a go_router assertion. Pre-existing and unrelated to this branch, but this feature makes such links common.

21Mill added 2 commits August 22, 2026 00:27
The app could already open order links but never produced one, so sharing
an order meant reading its id aloud and having the other side look it up
by hand.

The `mostro:` scheme is registered in the manifest, NostrUtils parses
`mostro:<order-id>?relays=...&mostro=<pubkey>`, and DeepLinkService
resolves the order from those relays, switching Mostro instance when the
link points at a different one. Only the encoder was missing.

NostrUtils.buildMostroUrl now writes that same format, next to the two
functions that read it. It keeps only relays carrying a WebSocket scheme,
drops duplicates, caps the list so the link stays pasteable, and emits the
instance pubkey only when it passes the check the parser applies, so a
link this builds is always one the parser accepts.

OrderShareLinkCard shows the link with a copy button, following the shape
of the OrderIdCard beside it, and renders nothing when no relay can
resolve the order. It appears on the order book's detail screen and, in My
Trades, only while the order is still pending: a link to a trade already
under way is of no use to whoever opens it.

Adds orderLinkLabel and orderLinkCopiedMessage to the six locales.
Copying the order link means copy, leave the app, open the chat, paste.
The share sheet takes the same link straight to Telegram, Signal, a note
or anything else installed, in one gesture.

It also allows something the clipboard cannot: sending the link with a
sentence around it. A bare mostro:8927bb1d-...?relays=... lands in a chat
as an unexplained string, and most apps only linkify http(s), so the
recipient sees neither a tappable link nor a hint of what it is. It now
travels as "Take this order on Mostro: <link>".

Both actions stay: copying is still faster when the destination is not an
app, such as a password manager or a QR generator.

The share call follows the pattern the invoice widget already uses, taking
everything it needs from the context before the await -- this card is a
ConsumerWidget, so there is no mounted to check afterwards -- and reporting
a failure through the snackbar rather than letting it escape. It passes
sharePositionOrigin, which iPads need to anchor the sheet.

Adds orderShareMessage and failedToShareOrder to the six locales.

The card now holds two 48dp buttons next to a link long enough to wrap,
which is the shape that produced the overflow in MostroP2P#654, so a layout test
pins it. Confirmed that test fails against a card whose link is not
flexible.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@21Mill, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f8a98a27-3d26-4bda-a86a-c64b2c51c2c0

📥 Commits

Reviewing files that changed from the base of the PR and between c3c2d7a and 99fc2e6.

📒 Files selected for processing (12)
  • lib/features/order/screens/take_order_screen.dart
  • lib/features/trades/screens/trade_detail_screen.dart
  • lib/l10n/intl_de.arb
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_fr.arb
  • lib/l10n/intl_it.arb
  • lib/l10n/intl_pt.arb
  • lib/shared/utils/nostr_utils.dart
  • lib/shared/widgets/order_cards.dart
  • test/shared/utils/deep_link_parsing_test.dart
  • test/shared/widgets/order_cards_test.dart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Request changes

The share-sheet addition itself looks straightforward: the card keeps copy and share, wraps the link in localized explanatory text, anchors the share sheet, and has widget coverage for the share method call and the two-button layout.

I am still requesting changes because this PR explicitly depends on #669 and ships the same generated mostro: link surface. #669 is not ready as reviewed, and the receiver-side path is still known-broken: #670 means a recipient opening one of these shared links while the app is not in the foreground can crash/fail to navigate. That is the primary use case for this PR (send the order to Telegram/Signal/WhatsApp/etc.). Until the link-opening path is fixed/merged, the share sheet would make it easier to distribute links that recipients cannot reliably open.

Please either:

  • make this PR wait on a merged fix for #669 and #670, or
  • include the receiver-side fix in this stack before closing #671.

Verification performed:

  • Reviewed current head 99fc2e62288349b3882e12a2c3ca1f288737059c against base c3c2d7a7b318e70b2d7555f43d49ef1bfc009624.
  • Read the PR body, linked issue #671, PR comments, and current CI state.
  • Parsed the touched ARB locale files with duplicate-key and placeholder checks; no new ARB issues found.
  • Ran git diff --check on the changed files successfully.
  • Could not run flutter test locally because this environment does not have flutter on PATH; GitHub's build check is currently green for this head.

@21Mill

21Mill commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Agreed. The body now states both dependencies explicitly: this waits on #669 (where OrderShareLinkCard lives) and on #673, which fixes the receiving side (#670). Merge order: #673#669 → this one.

No code change here — the share sheet only makes the same links easier to send, so the fix belongs upstream in #673 rather than in this stack.

@grunch

grunch commented Aug 24, 2026

Copy link
Copy Markdown
Member

same comment #669 (comment)

I'm closing this and all other UI PRs, we only are fixing bugs on this apps, not new features, new features in https://github.com/MostroP2P/app please

@grunch grunch closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share an order through the system share sheet, not only by copying its link

2 participants