feat: simple NWC flow

closes #19
This commit is contained in:
2025-05-26 13:28:00 +01:00
parent befd7c014b
commit 47bed26df6
76 changed files with 3416 additions and 3277 deletions

View File

@ -24,7 +24,7 @@ class LoginPage extends StatelessWidget {
if (state.data ?? false) {
return BasicButton.text(
t.login.amber,
onTap: () async {
onTap: (context) async {
final amber = Amberflutter();
final result = await amber.getPublicKey();
if (result['signature'] != null) {
@ -41,7 +41,7 @@ class LoginPage extends StatelessWidget {
}
},
),
BasicButton.text(t.login.key, onTap: () => context.push("/login/key")),
BasicButton.text(t.login.key, onTap: (context) => context.push("/login/key")),
Container(
margin: EdgeInsets.symmetric(vertical: 20),
height: 1,
@ -51,7 +51,7 @@ class LoginPage extends StatelessWidget {
),
BasicButton.text(
t.login.create,
onTap: () => context.push("/login/new"),
onTap: (context) => context.push("/login/new"),
),
],
);

View File

@ -29,7 +29,7 @@ class _LoginInputPage extends State<LoginInputPage> {
),
BasicButton.text(
t.button.login,
onTap: () async {
onTap: (context) async {
try {
if (_controller.text.startsWith("bunker://")) {
// not supported yet in ndk

View File

@ -74,7 +74,7 @@ class _NewAccountPage extends State<NewAccountPage> {
return BasicButton.text(
t.button.login,
disabled: _loading || value.text.isEmpty,
onTap: () {
onTap: (context) {
setState(() {
_loading = true;
_nameFocus.unfocus();

View File

@ -76,7 +76,7 @@ class ProfilePage extends StatelessWidget {
children: [
BasicButton.text(
t.button.logout,
onTap: () {
onTap: (context) {
loginData.logout();
ndk.accounts.logout();
context.go("/");
@ -84,7 +84,7 @@ class ProfilePage extends StatelessWidget {
),
BasicButton.text(
t.button.edit_profile,
onTap: () {
onTap: (context) {
context.push("/settings/profile");
},
),

View File

@ -87,7 +87,7 @@ class SettingsProfilePage extends StatelessWidget {
BasicButton.text(
t.button.save,
disabled: v,
onTap: () async {
onTap: (context) async {
_loading.value = true;
try {
final newMeta = Metadata(

View File

@ -0,0 +1,77 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:zap_stream_flutter/const.dart';
import 'package:zap_stream_flutter/i18n/strings.g.dart';
import 'package:zap_stream_flutter/login.dart';
import 'package:zap_stream_flutter/theme.dart';
import 'package:zap_stream_flutter/widgets/button.dart';
class SettingsWalletPage extends StatefulWidget {
const SettingsWalletPage({super.key});
@override
State<StatefulWidget> createState() => _Inner();
}
class _Inner extends State<SettingsWalletPage> {
late final TextEditingController _uri;
String? _error;
@override
void initState() {
_uri = TextEditingController();
super.initState();
}
@override
Widget build(BuildContext context) {
final pubkey = ndk.accounts.getPublicKey();
if (pubkey == null) return Text(t.wallet.error.logged_out);
return ValueListenableBuilder(
valueListenable: loginData,
builder: (context, state, child) {
if (state?.wallet == null) {
return Column(
spacing: 8,
children: [
TextField(
controller: _uri,
decoration: InputDecoration(labelText: t.wallet.connect_wallet),
),
BasicButton.text(
t.button.connect,
onTap: (context) async {
try {
await ndk.nwc.connect(_uri.text);
final cfg = WalletConfig(
type: WalletType.nwc,
data: _uri.text,
);
loginData.value = LoginAccount(
type: loginData.value!.type,
pubkey: loginData.value!.pubkey,
privateKey: loginData.value!.privateKey,
signerRelays: loginData.value!.signerRelays,
wallet: cfg,
);
if (context.mounted) {
context.pop();
}
} catch (e) {
setState(() {
_error = e is String ? e : e.toString();
});
}
},
),
if (_error != null)
Text(_error!, style: TextStyle(color: WARNING)),
],
);
}
return SizedBox.shrink();
},
);
}
}

View File

@ -169,7 +169,7 @@ class _StreamPage extends State<StreamPage> with RouteAware {
color: PRIMARY_1,
borderRadius: DEFAULT_BR,
),
onTap: () {
onTap: (context) {
showModalBottomSheet(
context: context,
constraints: BoxConstraints.expand(),