Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

Scan QR for npub - #175

Merged
untreu2 merged 9 commits into
masterfrom
scan-npub
Feb 4, 2026
Merged

Scan QR for npub#175
untreu2 merged 9 commits into
masterfrom
scan-npub

Conversation

@untreu2

@untreu2 untreu2 commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the ability to scan a contact's npub QR code from the Share Profile screen and User Search screen.

Closes #127

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Checklist

  • Run just precommit to ensure that formatting and linting are correct
  • Updated the CHANGELOG.md file with your changes (if they affect the user experience)
  • Updated android .so files by running just build-android (only needed if rust dependencies or rust code changes)

Summary by CodeRabbit

  • New Features

    • NPUB QR scanner UI with hint/error states and flow to start a chat from a scanned NPUB; scan button added to profile and search screens.
  • Localization

    • Added scan-related UI strings (scan label, hint, invalid key message) across multiple languages.
  • Tests

    • Comprehensive UI, navigation, and barcode-handling tests for the scanner and scan button.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown

Walkthrough

Adds an NPUB QR scanner flow: new ScanNpubScreen, route and navigation helper, localization keys across multiple languages, UI integrations (ShareProfileScreen, UserSearchScreen, WnSearchField), and tests covering UI, navigation, and barcode handling.

Changes

Cohort / File(s) Summary
Localization
lib/l10n/app_de.arb, lib/l10n/app_en.arb, lib/l10n/app_es.arb, lib/l10n/app_fr.arb, lib/l10n/app_it.arb, lib/l10n/app_pt.arb, lib/l10n/app_ru.arb, lib/l10n/app_tr.arb
Added scanNpub, scanNpubHint, and invalidNpub keys (localized strings); minor trailing-comma adjustments.
Routing
lib/routes.dart
Added _scanNpub route constant, GoRoute entry for ScanNpubScreen, and navigation helper pushToScanNpub.
New Screen
lib/screens/scan_npub_screen.dart
Introduced ScanNpubScreen widget with WnScanBox, barcode handling, npub→hex conversion via API, error state handling, and navigation to StartChat on success.
UI Integration
lib/screens/share_profile_screen.dart, lib/screens/user_search_screen.dart
Added Scan QR button in ShareProfileScreen that routes to scanner; wired UserSearchScreen to call Routes.pushToScanNpub via an onScan callback.
Widget API
lib/widgets/wn_search_field.dart
Added optional VoidCallback? onScan to WnSearchField; shows tappable scan suffix icon when provided.
Changelog
CHANGELOG.md
Replaced "Scan QR for nsec" entry with "Scan QR for npub" in Unreleased -> Added.
Tests
test/screens/scan_npub_screen_test.dart, test/screens/share_profile_screen_test.dart, test/screens/user_search_screen_test.dart, test/widgets/wn_search_field_test.dart
Added tests covering ScanNpub UI/navigation/barcode cases, ShareProfile and UserSearch scan-button behavior, and WnSearchField onScan behavior.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant ShareProfile as ShareProfileScreen
    participant Router as Router
    participant ScanScreen as ScanNpubScreen
    participant API as API (hexFromNpub)
    participant Chat as StartChatScreen

    User->>ShareProfile: Tap "Scan QR" button
    ShareProfile->>Router: pushToScanNpub()
    Router->>ScanScreen: Navigate to ScanNpubScreen
    User->>ScanScreen: Scans QR (npub)
    ScanScreen->>API: hexFromNpub(npub)
    API-->>ScanScreen: hex pubkey or error
    alt valid npub
        ScanScreen->>Router: popAndPushNamed(startChat, pubkey)
        Router->>Chat: Navigate with pubkey
    else invalid npub
        ScanScreen-->>User: Show error (invalidNpub), keep scanner
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Scan QR for nsec #164: Another QR-scanning PR (Scan Nsec vs Scan Npub) sharing scanner components and routing changes.
  • Search user by npub #39: Modifies wn_search_field.dart, directly related to the added onScan API and suffix icon behavior.
  • Copy card #157: Touches share_profile_screen.dart, overlapping UI integration for scan actions.

Suggested reviewers

  • erskingardner
  • josefinalliende
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Scan QR for npub' directly describes the main feature added in this pull request: the ability to scan QR codes for npub values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch scan-npub

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

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Coverage: 99.35% → 99.36% (+0.01%)

1 similar comment
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Coverage: 99.35% → 99.36% (+0.01%)

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test/screens/scan_npub_screen_test.dart`:
- Line 81: Replace the double-quoted literal used in the widget assertions with
single-quoted strings and escape the apostrophe in the text; update the expect
calls that use find.text("Scan a contact's QR code.") (and the similar
occurrence around line 120) to use single quotes with an escaped apostrophe so
they follow the project's Dart/Flutter style guide.

Comment thread test/screens/scan_npub_screen_test.dart Outdated

@erskingardner erskingardner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Coverage: 99.35% → 99.36% (+0.01%)

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@test/screens/scan_npub_screen_test.dart`:
- Around line 91-92: Several testWidgets declarations (e.g., the test that calls
pumpScanNpubScreen) have descriptions that exceed 100 characters; split the
string and the callback onto separate lines and wrap/shorten the description so
each source line is ≤100 chars. Locate the long testWidgets(...) calls in
scan_npub_screen_test.dart, break the description into a shorter string or use
string concatenation, place the opening parenthesis and the async callback on
the next line (e.g., testWidgets('short description', (tester) async { ... }),
or split across two lines) and apply the same wrapping style to the other
offending tests referenced in this file (the tests around the tapping
close/sharing interactions).
- Around line 47-49: The mock API is initialized once via RustLib.initMock(api:
_MockApi()) in setUpAll but never reset, causing StreamController leaks across
tests; keep the shared _MockApi instance and add a setUp() that calls
_api.reset() (or the mock’s reset method) before each test so streams are
cleared, and remove reliance on tearDownAll for this cleanup; locate the
initialization in setUpAll and the mock class _MockApi to implement the reset
call in setUp.

Comment thread test/screens/scan_npub_screen_test.dart
Comment thread test/screens/scan_npub_screen_test.dart
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Coverage: 99.36% → 99.37% (+0.01%)

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Coverage: 99.36% → 99.37% (+0.01%)

@untreu2
untreu2 merged commit d455d25 into master Feb 4, 2026
5 checks passed
@untreu2 untreu2 mentioned this pull request Feb 4, 2026
83 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Feb 18, 2026
11 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Mar 28, 2026
10 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search users with QR scan

2 participants