feat: support smol:// QR sharing, deep links and in-dialog scanning
This commit is contained in:
parent
7d2a147fec
commit
aa74e12ee7
20 changed files with 591 additions and 101 deletions
27
lib/smol/link.dart
Normal file
27
lib/smol/link.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Deep links (SPEC.md §3): the OS hands the app a URI a QR scanner or a
|
||||
// browser produced. Only the smol scheme is ours to interpret, and the
|
||||
// native parser decides validity — fumi rejects a smol:// URI without its
|
||||
// key, so every link that parses is the self-certifying form.
|
||||
|
||||
import "package:smol_mail/smol/address.dart";
|
||||
import "package:smol_mail/smol/errors.dart";
|
||||
|
||||
class SmolLink {
|
||||
final SmolAddress address;
|
||||
final String source;
|
||||
|
||||
const SmolLink._(this.address, this.source);
|
||||
}
|
||||
|
||||
/// Parses a smol:// URI. Returns null for other schemes and for anything
|
||||
/// the native parser rejects — those are not silent fixes, they are not
|
||||
/// for this app to act on.
|
||||
SmolLink? parseSmolLink(String uri) {
|
||||
final text = uri.trim();
|
||||
if (!text.startsWith("smol://")) return null;
|
||||
try {
|
||||
return SmolLink._(parseAddress(text), text);
|
||||
} on SmolError {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue