nostr publish event fix

This commit is contained in:
gitea
2025-11-06 21:43:09 +01:00
parent 120a04c69f
commit 947fb667cf
7 changed files with 207 additions and 459 deletions
+111
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../../data/session/session_service.dart';
import '../../data/firebase/firebase_service.dart';
import '../../data/nostr/nostr_service.dart';
import '../../data/nostr/models/nostr_keypair.dart';
/// Screen for user session management (login/logout).
class SessionScreen extends StatefulWidget {
@@ -31,6 +32,7 @@ class _SessionScreenState extends State<SessionScreen> {
bool _isLoading = false;
bool _useFirebaseAuth = false;
bool _useNostrLogin = false;
NostrKeyPair? _generatedKeyPair;
@override
void initState() {
@@ -437,6 +439,115 @@ class _SessionScreenState extends State<SessionScreen> {
),
const SizedBox(height: 24),
if (_useNostrLogin) ...[
// Key pair generation section
if (widget.nostrService != null) ...[
Card(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Generate Key Pair',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
ElevatedButton.icon(
onPressed: () {
setState(() {
_generatedKeyPair = widget.nostrService!.generateKeyPair();
});
},
icon: const Icon(Icons.refresh, size: 18),
label: const Text('Generate'),
),
],
),
if (_generatedKeyPair != null) ...[
const SizedBox(height: 16),
// npub display
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'npub (Public Key):',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
SelectableText(
_generatedKeyPair!.toNpub(),
style: const TextStyle(
fontSize: 11,
fontFamily: 'monospace',
),
),
],
),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.content_copy),
tooltip: 'Copy to field',
onPressed: () {
_nostrKeyController.text = _generatedKeyPair!.toNpub();
},
),
],
),
const SizedBox(height: 12),
// nsec display
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'nsec (Private Key):',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
SelectableText(
_generatedKeyPair!.toNsec(),
style: const TextStyle(
fontSize: 11,
fontFamily: 'monospace',
),
),
],
),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.content_copy),
tooltip: 'Copy to field',
onPressed: () {
_nostrKeyController.text = _generatedKeyPair!.toNsec();
},
),
],
),
],
],
),
),
),
const SizedBox(height: 16),
],
TextField(
controller: _nostrKeyController,
decoration: const InputDecoration(