mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-15 19:48:23 +00:00
Compare commits
15 Commits
v0.1.0-bet
...
v0.2.1
Author | SHA1 | Date | |
---|---|---|---|
53794158c0
|
|||
706fb27664
|
|||
8507e3171a
|
|||
15fb04cf62
|
|||
062b22b15a
|
|||
b6a69004e6
|
|||
829dd7a0d0
|
|||
4b363762dd
|
|||
af2879406e
|
|||
0fcb773afc
|
|||
a5aa8c5fa7
|
|||
194bff315c
|
|||
658bddbef0
|
|||
a304182e55
|
|||
59ac3f502a
|
3
devtools_options.yaml
Normal file
3
devtools_options.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
description: This file stores settings for Dart & Flutter DevTools.
|
||||||
|
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||||
|
extensions:
|
@ -7,46 +7,46 @@ import 'package:ndk/domain_layer/entities/account.dart';
|
|||||||
import 'package:ndk/shared/nips/nip01/bip340.dart';
|
import 'package:ndk/shared/nips/nip01/bip340.dart';
|
||||||
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
||||||
|
|
||||||
class Account {
|
class LoginAccount {
|
||||||
final AccountType type;
|
final AccountType type;
|
||||||
final String pubkey;
|
final String pubkey;
|
||||||
final String? privateKey;
|
final String? privateKey;
|
||||||
|
|
||||||
Account._({required this.type, required this.pubkey, this.privateKey});
|
LoginAccount._({required this.type, required this.pubkey, this.privateKey});
|
||||||
|
|
||||||
static Account nip19(String key) {
|
static LoginAccount nip19(String key) {
|
||||||
final keyData = Nip19.decode(key);
|
final keyData = Nip19.decode(key);
|
||||||
final pubkey =
|
final pubkey =
|
||||||
Nip19.isKey("nsec", key) ? Bip340.getPublicKey(keyData) : keyData;
|
Nip19.isKey("nsec", key) ? Bip340.getPublicKey(keyData) : keyData;
|
||||||
final privateKey = Nip19.isKey("npub", key) ? null : keyData;
|
final privateKey = Nip19.isKey("npub", key) ? null : keyData;
|
||||||
return Account._(
|
return LoginAccount._(
|
||||||
type: AccountType.privateKey,
|
type: Nip19.isKey("npub", key) ? AccountType.publicKey : AccountType.privateKey,
|
||||||
pubkey: pubkey,
|
pubkey: pubkey,
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Account privateKeyHex(String key) {
|
static LoginAccount privateKeyHex(String key) {
|
||||||
return Account._(
|
return LoginAccount._(
|
||||||
type: AccountType.privateKey,
|
type: AccountType.privateKey,
|
||||||
privateKey: key,
|
privateKey: key,
|
||||||
pubkey: Bip340.getPublicKey(key),
|
pubkey: Bip340.getPublicKey(key),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Account externalPublicKeyHex(String key) {
|
static LoginAccount externalPublicKeyHex(String key) {
|
||||||
return Account._(type: AccountType.externalSigner, pubkey: key);
|
return LoginAccount._(type: AccountType.externalSigner, pubkey: key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String, dynamic> toJson(Account? acc) => {
|
static Map<String, dynamic> toJson(LoginAccount? acc) => {
|
||||||
"type": acc?.type.name,
|
"type": acc?.type.name,
|
||||||
"pubKey": acc?.pubkey,
|
"pubKey": acc?.pubkey,
|
||||||
"privateKey": acc?.privateKey,
|
"privateKey": acc?.privateKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
static Account? fromJson(Map<String, dynamic> json) {
|
static LoginAccount? fromJson(Map<String, dynamic> json) {
|
||||||
if (json.length > 2 && json.containsKey("pubKey")) {
|
if (json.length > 2 && json.containsKey("pubKey")) {
|
||||||
return Account._(
|
return LoginAccount._(
|
||||||
type: AccountType.values.firstWhere(
|
type: AccountType.values.firstWhere(
|
||||||
(v) => v.toString().endsWith(json["type"] as String),
|
(v) => v.toString().endsWith(json["type"] as String),
|
||||||
),
|
),
|
||||||
@ -58,13 +58,13 @@ class Account {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginData extends ValueNotifier<Account?> {
|
class LoginData extends ValueNotifier<LoginAccount?> {
|
||||||
final _storage = FlutterSecureStorage();
|
final _storage = FlutterSecureStorage();
|
||||||
static const String _storageKey = "accounts";
|
static const String _storageKey = "accounts";
|
||||||
|
|
||||||
LoginData() : super(null) {
|
LoginData() : super(null) {
|
||||||
super.addListener(() async {
|
super.addListener(() async {
|
||||||
final data = json.encode(Account.toJson(value));
|
final data = json.encode(LoginAccount.toJson(value));
|
||||||
await _storage.write(key: _storageKey, value: data);
|
await _storage.write(key: _storageKey, value: data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ class LoginData extends ValueNotifier<Account?> {
|
|||||||
final acc = await _storage.read(key: _storageKey);
|
final acc = await _storage.read(key: _storageKey);
|
||||||
if (acc?.isNotEmpty ?? false) {
|
if (acc?.isNotEmpty ?? false) {
|
||||||
try {
|
try {
|
||||||
super.value = Account.fromJson(json.decode(acc!));
|
super.value = LoginAccount.fromJson(json.decode(acc!));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
developer.log(e.toString());
|
developer.log(e.toString());
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import 'package:ndk_amber/ndk_amber.dart';
|
|||||||
import 'package:ndk_objectbox/ndk_objectbox.dart';
|
import 'package:ndk_objectbox/ndk_objectbox.dart';
|
||||||
import 'package:ndk_rust_verifier/ndk_rust_verifier.dart';
|
import 'package:ndk_rust_verifier/ndk_rust_verifier.dart';
|
||||||
import 'package:zap_stream_flutter/pages/login.dart';
|
import 'package:zap_stream_flutter/pages/login.dart';
|
||||||
|
import 'package:zap_stream_flutter/pages/login_input.dart';
|
||||||
|
import 'package:zap_stream_flutter/pages/new_account.dart';
|
||||||
import 'package:zap_stream_flutter/pages/profile.dart';
|
import 'package:zap_stream_flutter/pages/profile.dart';
|
||||||
import 'package:zap_stream_flutter/pages/stream.dart';
|
import 'package:zap_stream_flutter/pages/stream.dart';
|
||||||
import 'package:zap_stream_flutter/theme.dart';
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
@ -25,13 +27,14 @@ class NoVerify extends EventVerifier {
|
|||||||
|
|
||||||
final ndkCache = DbObjectBox();
|
final ndkCache = DbObjectBox();
|
||||||
final eventVerifier = kDebugMode ? NoVerify() : RustEventVerifier();
|
final eventVerifier = kDebugMode ? NoVerify() : RustEventVerifier();
|
||||||
var ndk = Ndk(NdkConfig(eventVerifier: eventVerifier, cache: ndkCache));
|
var ndk = Ndk(NdkConfig(eventVerifier: eventVerifier, cache: ndkCache, bootstrapRelays: defaultRelays));
|
||||||
|
|
||||||
const userAgent = "zap.stream/1.0";
|
const userAgent = "zap.stream/1.0";
|
||||||
const defaultRelays = [
|
const defaultRelays = [
|
||||||
"wss://nos.lol",
|
"wss://nos.lol",
|
||||||
"wss://relay.damus.io",
|
"wss://relay.damus.io",
|
||||||
"wss://relay.primal.net",
|
"wss://relay.primal.net",
|
||||||
|
"wss://relay.snort.social"
|
||||||
];
|
];
|
||||||
const searchRelays = ["wss://relay.nostr.band", "wss://search.nos.today"];
|
const searchRelays = ["wss://relay.nostr.band", "wss://search.nos.today"];
|
||||||
|
|
||||||
@ -87,7 +90,43 @@ Future<void> main() async {
|
|||||||
StatefulShellBranch(
|
StatefulShellBranch(
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(path: "/", builder: (ctx, state) => HomePage()),
|
GoRoute(path: "/", builder: (ctx, state) => HomePage()),
|
||||||
GoRoute(path: "/login", builder: (ctx, state) => LoginPage()),
|
ShellRoute(
|
||||||
|
builder: (context, state, child) {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.only(top: 50),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 20,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Image.asset(
|
||||||
|
"assets/logo.png",
|
||||||
|
height: 150,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: "/login",
|
||||||
|
builder: (ctx, state) => LoginPage(),
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: "key",
|
||||||
|
builder: (ctx, state) => LoginInputPage(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: "new",
|
||||||
|
builder: (context, state) => NewAccountPage(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: "/e/:id",
|
path: "/e/:id",
|
||||||
builder: (ctx, state) {
|
builder: (ctx, state) {
|
||||||
|
@ -4,56 +4,53 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
||||||
import 'package:zap_stream_flutter/login.dart';
|
import 'package:zap_stream_flutter/login.dart';
|
||||||
import 'package:zap_stream_flutter/main.dart';
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
import 'package:zap_stream_flutter/widgets/button.dart';
|
import 'package:zap_stream_flutter/widgets/button.dart';
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {
|
class LoginPage extends StatelessWidget {
|
||||||
const LoginPage({super.key});
|
const LoginPage({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<StatefulWidget> createState() => _LoginPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LoginPage extends State<LoginPage> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Column(
|
||||||
margin: EdgeInsets.only(top: 50),
|
spacing: 20,
|
||||||
child: Column(
|
children: [
|
||||||
spacing: 10,
|
FutureBuilder(
|
||||||
children: [
|
future: Amberflutter().isAppInstalled(),
|
||||||
Image.asset("assets/logo.png", height: 150),
|
builder: (ctx, state) {
|
||||||
FutureBuilder(
|
if (state.data ?? false) {
|
||||||
future: Amberflutter().isAppInstalled(),
|
return BasicButton.text(
|
||||||
builder: (ctx, state) {
|
"Login with Amber",
|
||||||
if (state.data ?? false) {
|
onTap: () async {
|
||||||
return BasicButton.text(
|
final amber = Amberflutter();
|
||||||
"Login with Amber",
|
final result = await amber.getPublicKey();
|
||||||
onTap: () async {
|
if (result['signature'] != null) {
|
||||||
final amber = Amberflutter();
|
final key = Nip19.decode(result['signature']);
|
||||||
final result = await amber.getPublicKey();
|
loginData.value = LoginAccount.externalPublicKeyHex(key);
|
||||||
if (result['signature'] != null) {
|
ctx.go("/");
|
||||||
final key = Nip19.decode(result['signature']);
|
}
|
||||||
loginData.value = Account.externalPublicKeyHex(key);
|
},
|
||||||
ctx.go("/");
|
);
|
||||||
}
|
} else {
|
||||||
},
|
return SizedBox.shrink();
|
||||||
);
|
}
|
||||||
} else {
|
},
|
||||||
return SizedBox.shrink();
|
),
|
||||||
}
|
BasicButton.text(
|
||||||
},
|
"Login with Key",
|
||||||
|
onTap: () => context.push("/login/key"),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 20),
|
||||||
|
height: 1,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(bottom: BorderSide(color: LAYER_2)),
|
||||||
),
|
),
|
||||||
/*BasicButton.text("Login with Key"),
|
),
|
||||||
Container(
|
BasicButton.text(
|
||||||
margin: EdgeInsets.symmetric(vertical: 20),
|
"Create Account",
|
||||||
height: 1,
|
onTap: () => context.push("/login/new"),
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
border: Border(bottom: BorderSide(color: LAYER_1)),
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
Text("Create Account"),*/
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
lib/pages/login_input.dart
Normal file
56
lib/pages/login_input.dart
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
||||||
|
import 'package:zap_stream_flutter/login.dart';
|
||||||
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/button.dart';
|
||||||
|
|
||||||
|
class LoginInputPage extends StatefulWidget {
|
||||||
|
const LoginInputPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _LoginInputPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginInputPage extends State<LoginInputPage> {
|
||||||
|
final TextEditingController _controller = TextEditingController();
|
||||||
|
String? _error;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
spacing: 20,
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _controller,
|
||||||
|
decoration: InputDecoration(labelText: "npub/nsec"),
|
||||||
|
),
|
||||||
|
BasicButton.text(
|
||||||
|
"Login",
|
||||||
|
onTap: () async {
|
||||||
|
try {
|
||||||
|
final keyData = Nip19.decode(_controller.text);
|
||||||
|
if (keyData.isNotEmpty) {
|
||||||
|
loginData.value = LoginAccount.nip19(_controller.text);
|
||||||
|
context.go("/");
|
||||||
|
} else {
|
||||||
|
throw "Invalid key";
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_error = e.toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
if (_error != null)
|
||||||
|
Text(
|
||||||
|
_error!,
|
||||||
|
style: TextStyle(color: WARNING, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
121
lib/pages/new_account.dart
Normal file
121
lib/pages/new_account.dart
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:ndk/ndk.dart';
|
||||||
|
import 'package:ndk/shared/nips/nip01/bip340.dart';
|
||||||
|
import 'package:ndk/shared/nips/nip01/key_pair.dart';
|
||||||
|
import 'package:zap_stream_flutter/login.dart';
|
||||||
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/button.dart';
|
||||||
|
|
||||||
|
class NewAccountPage extends StatefulWidget {
|
||||||
|
const NewAccountPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _NewAccountPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NewAccountPage extends State<NewAccountPage> {
|
||||||
|
final TextEditingController _name = TextEditingController();
|
||||||
|
String? _avatar;
|
||||||
|
String? _error;
|
||||||
|
final KeyPair _privateKey = Bip340.generatePrivateKey();
|
||||||
|
|
||||||
|
Future<void> _uploadAvatar() async {
|
||||||
|
ndk.accounts.loginPrivateKey(
|
||||||
|
pubkey: _privateKey.publicKey,
|
||||||
|
privkey: _privateKey.privateKey!,
|
||||||
|
);
|
||||||
|
|
||||||
|
final file = await ImagePicker().pickImage(source: ImageSource.gallery);
|
||||||
|
if (file != null) {
|
||||||
|
final upload = await ndk.blossom.uploadBlob(
|
||||||
|
serverUrls: ["https://nostr.download"],
|
||||||
|
data: await file.readAsBytes(),
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
_avatar = upload.first.descriptor!.url;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _login() async {
|
||||||
|
if (ndk.accounts.isNotLoggedIn) {
|
||||||
|
ndk.accounts.loginPrivateKey(
|
||||||
|
pubkey: _privateKey.publicKey,
|
||||||
|
privkey: _privateKey.privateKey!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await ndk.metadata.broadcastMetadata(
|
||||||
|
Metadata(
|
||||||
|
pubKey: _privateKey.publicKey,
|
||||||
|
name: _name.text,
|
||||||
|
picture: _avatar,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
spacing: 20,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
_uploadAvatar().catchError((e) {
|
||||||
|
setState(() {
|
||||||
|
if (e is String) {
|
||||||
|
_error = e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(200)),
|
||||||
|
color: Color.fromARGB(100, 50, 50, 50),
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
_avatar == null
|
||||||
|
? Center(child: Text("Upload Avatar"))
|
||||||
|
: CachedNetworkImage(imageUrl: _avatar!),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _name,
|
||||||
|
decoration: InputDecoration(labelText: "Username"),
|
||||||
|
),
|
||||||
|
BasicButton.text(
|
||||||
|
"Login",
|
||||||
|
onTap: () {
|
||||||
|
_login()
|
||||||
|
.then((_) {
|
||||||
|
loginData.value = LoginAccount.privateKeyHex(
|
||||||
|
_privateKey.privateKey!,
|
||||||
|
);
|
||||||
|
context.go("/");
|
||||||
|
})
|
||||||
|
.catchError((e) {
|
||||||
|
setState(() {
|
||||||
|
if (e is String) {
|
||||||
|
_error = e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (_error != null)
|
||||||
|
Text(
|
||||||
|
_error!,
|
||||||
|
style: TextStyle(color: WARNING, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:chewie/chewie.dart';
|
import 'package:chewie/chewie.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
import 'package:zap_stream_flutter/imgproxy.dart';
|
||||||
import 'package:zap_stream_flutter/main.dart';
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
import 'package:zap_stream_flutter/theme.dart';
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
import 'package:zap_stream_flutter/utils.dart';
|
import 'package:zap_stream_flutter/utils.dart';
|
||||||
@ -38,17 +40,21 @@ class _StreamPage extends State<StreamPage> {
|
|||||||
_controller = VideoPlayerController.networkUrl(
|
_controller = VideoPlayerController.networkUrl(
|
||||||
Uri.parse(url),
|
Uri.parse(url),
|
||||||
httpHeaders: Map.from({"user-agent": userAgent}),
|
httpHeaders: Map.from({"user-agent": userAgent}),
|
||||||
videoPlayerOptions: VideoPlayerOptions(allowBackgroundPlayback: true),
|
|
||||||
);
|
);
|
||||||
() async {
|
() async {
|
||||||
await _controller!.initialize();
|
await _controller!.initialize();
|
||||||
|
|
||||||
_chewieController = ChewieController(
|
|
||||||
videoPlayerController: _controller!,
|
|
||||||
autoPlay: true,
|
|
||||||
);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
// nothing
|
_chewieController = ChewieController(
|
||||||
|
videoPlayerController: _controller!,
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
autoPlay: true,
|
||||||
|
placeholder:
|
||||||
|
(widget.stream.info.image?.isNotEmpty ?? false)
|
||||||
|
? CachedNetworkImage(
|
||||||
|
imageUrl: proxyImg(context, widget.stream.info.image!),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@ -75,7 +81,18 @@ class _StreamPage extends State<StreamPage> {
|
|||||||
child:
|
child:
|
||||||
_chewieController != null
|
_chewieController != null
|
||||||
? Chewie(controller: _chewieController!)
|
? Chewie(controller: _chewieController!)
|
||||||
: Container(color: LAYER_1),
|
: Container(
|
||||||
|
color: LAYER_1,
|
||||||
|
child:
|
||||||
|
(widget.stream.info.image?.isNotEmpty ?? false)
|
||||||
|
? CachedNetworkImage(
|
||||||
|
imageUrl: proxyImg(
|
||||||
|
context,
|
||||||
|
widget.stream.info.image!,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
widget.stream.info.title ?? "",
|
widget.stream.info.title ?? "",
|
||||||
@ -123,7 +140,6 @@ class _StreamPage extends State<StreamPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
|
||||||
Expanded(child: ChatWidget(stream: widget.stream)),
|
Expanded(child: ChatWidget(stream: widget.stream)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -54,20 +54,24 @@ class _RxFilter<T> extends State<RxFilter<T>> {
|
|||||||
developer.log("RX:ERROR $e");
|
developer.log("RX:ERROR $e");
|
||||||
})
|
})
|
||||||
.listen((events) {
|
.listen((events) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_events ??= HashMap();
|
_events ??= HashMap();
|
||||||
developer.log("RX:GOT ${events.length} events for ${widget.filters}");
|
developer.log(
|
||||||
events.forEach(_replaceInto);
|
"RX:GOT ${events.length} events for ${widget.filters}",
|
||||||
});
|
);
|
||||||
});
|
events.forEach(_replaceInto);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _replaceInto(Nip01Event ev) {
|
void _replaceInto(Nip01Event ev) {
|
||||||
final evKey = _eventKey(ev);
|
final evKey = _eventKey(ev);
|
||||||
final existing = _events?[evKey];
|
final existing = _events?[evKey];
|
||||||
if (existing == null || existing.$1 < ev.createdAt) {
|
if (existing == null || existing.$1 < ev.createdAt) {
|
||||||
_events?[evKey] =
|
_events?[evKey] = (
|
||||||
(ev.createdAt, widget.mapper != null ? widget.mapper!(ev) : ev as T);
|
ev.createdAt,
|
||||||
|
widget.mapper != null ? widget.mapper!(ev) : ev as T,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,8 +95,7 @@ class _RxFilter<T> extends State<RxFilter<T>> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return widget.builder(context,
|
return widget.builder(context, _events?.values.map((v) => v.$2).toList());
|
||||||
_events?.values.map((v) => v.$2).toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,11 +123,14 @@ class RxFutureFilter<T> extends StatelessWidget {
|
|||||||
builder: (ctx, data) {
|
builder: (ctx, data) {
|
||||||
if (data.hasData) {
|
if (data.hasData) {
|
||||||
return RxFilter<T>(
|
return RxFilter<T>(
|
||||||
filters: data.data!, mapper: mapper, builder: builder);
|
filters: data.data!,
|
||||||
|
mapper: mapper,
|
||||||
|
builder: builder,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return loadingWidget ?? SizedBox.shrink();
|
return loadingWidget ?? SizedBox.shrink();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,3 +15,4 @@ Color LAYER_5 = Color.fromARGB(255, 173, 173, 173);
|
|||||||
Color PRIMARY_1 = Color.fromARGB(255, 248, 56, 217);
|
Color PRIMARY_1 = Color.fromARGB(255, 248, 56, 217);
|
||||||
Color SECONDARY_1 = Color.fromARGB(255, 52, 210, 254);
|
Color SECONDARY_1 = Color.fromARGB(255, 52, 210, 254);
|
||||||
Color ZAP_1 = Color.fromARGB(255, 255, 141, 43);
|
Color ZAP_1 = Color.fromARGB(255, 255, 141, 43);
|
||||||
|
Color WARNING = Color.fromARGB(255, 255, 86, 63);
|
||||||
|
@ -201,7 +201,7 @@ StreamInfo extractStreamInfo(Nip01Event ev) {
|
|||||||
|
|
||||||
String getHost(Nip01Event ev) {
|
String getHost(Nip01Event ev) {
|
||||||
return ev.tags.firstWhere(
|
return ev.tags.firstWhere(
|
||||||
(t) => t[0] == "p" && t[3] == "host",
|
(t) => t[0] == "p" && t.length > 2 && t[3] == "host",
|
||||||
orElse: () => ["p", ev.pubKey], // fake p tag with event pubkey
|
orElse: () => ["p", ev.pubKey], // fake p tag with event pubkey
|
||||||
)[1];
|
)[1];
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,9 @@ import 'package:zap_stream_flutter/rx_filter.dart';
|
|||||||
import 'package:zap_stream_flutter/theme.dart';
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
import 'package:zap_stream_flutter/utils.dart';
|
import 'package:zap_stream_flutter/utils.dart';
|
||||||
import 'package:zap_stream_flutter/widgets/avatar.dart';
|
import 'package:zap_stream_flutter/widgets/avatar.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/nostr_text.dart';
|
||||||
import 'package:zap_stream_flutter/widgets/profile.dart';
|
import 'package:zap_stream_flutter/widgets/profile.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/profile_modal.dart';
|
||||||
|
|
||||||
class ChatWidget extends StatelessWidget {
|
class ChatWidget extends StatelessWidget {
|
||||||
final StreamEvent stream;
|
final StreamEvent stream;
|
||||||
@ -17,63 +19,157 @@ class ChatWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
var muteLists = [stream.info.host];
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
if (ndk.accounts.getPublicKey() != null) {
|
||||||
children: [
|
muteLists.add(ndk.accounts.getPublicKey()!);
|
||||||
Expanded(
|
}
|
||||||
child: SingleChildScrollView(
|
|
||||||
reverse: true,
|
return RxFilter<Nip01Event>(
|
||||||
child: RxFilter<Nip01Event>(
|
filters: [
|
||||||
filters: [
|
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
||||||
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
Filter(kinds: [Nip51List.kMute], authors: muteLists),
|
||||||
],
|
|
||||||
builder: (ctx, state) {
|
|
||||||
return Column(
|
|
||||||
spacing: 8,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children:
|
|
||||||
(state ?? [])
|
|
||||||
.sortedBy((c) => c.createdAt)
|
|
||||||
.map(
|
|
||||||
(c) => switch (c.kind) {
|
|
||||||
1311 => ChatMessageWidget(stream: stream, msg: c),
|
|
||||||
9735 => ChatZapWidget(stream: stream, zap: c),
|
|
||||||
_ => SizedBox.shrink(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (stream.info.status == StreamStatus.live)
|
|
||||||
WriteMessageWidget(stream: stream),
|
|
||||||
if (stream.info.status == StreamStatus.ended)
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
margin: EdgeInsets.symmetric(vertical: 8),
|
|
||||||
width: double.maxFinite,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: PRIMARY_1,
|
|
||||||
borderRadius: DEFAULT_BR,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
"STREAM ENDED",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
|
builder: (ctx, state) {
|
||||||
|
final mutedPubkeys =
|
||||||
|
(state ?? [])
|
||||||
|
.where((e) => e.kind == Nip51List.kMute)
|
||||||
|
.map((e) => e.tags)
|
||||||
|
.expand((e) => e)
|
||||||
|
.where((e) => e[0] == "p")
|
||||||
|
.map((e) => e[1])
|
||||||
|
.toSet();
|
||||||
|
|
||||||
|
final filteredChat =
|
||||||
|
(state ?? [])
|
||||||
|
.where(
|
||||||
|
(e) =>
|
||||||
|
!mutedPubkeys.contains(switch (e.kind) {
|
||||||
|
9735 => ZapReceipt.fromEvent(e).sender ?? e.pubKey,
|
||||||
|
_ => e.pubKey,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.sortedBy((e) => e.createdAt)
|
||||||
|
.reversed
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
spacing: 8,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_TopZappersWidget(events: filteredChat),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
reverse: true,
|
||||||
|
shrinkWrap: true,
|
||||||
|
primary: true,
|
||||||
|
itemCount: filteredChat.length,
|
||||||
|
itemBuilder:
|
||||||
|
(ctx, idx) => switch (filteredChat[idx].kind) {
|
||||||
|
1311 => Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 2,
|
||||||
|
vertical: 2,
|
||||||
|
),
|
||||||
|
child: _ChatMessageWidget(
|
||||||
|
stream: stream,
|
||||||
|
msg: filteredChat[idx],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
9735 => Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 2,
|
||||||
|
vertical: 2,
|
||||||
|
),
|
||||||
|
child: _ChatZapWidget(
|
||||||
|
stream: stream,
|
||||||
|
zap: filteredChat[idx],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_ => SizedBox.shrink(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (stream.info.status == StreamStatus.live)
|
||||||
|
_WriteMessageWidget(stream: stream),
|
||||||
|
if (stream.info.status == StreamStatus.ended)
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
width: double.maxFinite,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(borderRadius: DEFAULT_BR),
|
||||||
|
child: Text(
|
||||||
|
"STREAM ENDED",
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatZapWidget extends StatelessWidget {
|
class _TopZappersWidget extends StatelessWidget {
|
||||||
|
final List<Nip01Event> events;
|
||||||
|
|
||||||
|
const _TopZappersWidget({required this.events});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final topZaps =
|
||||||
|
events
|
||||||
|
.where((e) => e.kind == 9735)
|
||||||
|
.map((e) => ZapReceipt.fromEvent(e))
|
||||||
|
.fold(<String, int>{}, (acc, e) {
|
||||||
|
if (e.sender != null) {
|
||||||
|
acc[e.sender!] = (acc[e.sender!] ?? 0) + e.amountSats!;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
})
|
||||||
|
.entries
|
||||||
|
.sortedBy((e) => e.value)
|
||||||
|
.reversed
|
||||||
|
.take(10)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
primary: false,
|
||||||
|
child: Row(
|
||||||
|
spacing: 10,
|
||||||
|
children:
|
||||||
|
topZaps
|
||||||
|
.map(
|
||||||
|
(v) => Container(
|
||||||
|
padding: EdgeInsets.only(left: 4, right: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: DEFAULT_BR,
|
||||||
|
border: Border.all(color: LAYER_3),
|
||||||
|
),
|
||||||
|
child: ProfileWidget.pubkey(
|
||||||
|
v.key,
|
||||||
|
showName: false,
|
||||||
|
size: 20,
|
||||||
|
spacing: 0,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.bolt, color: ZAP_1),
|
||||||
|
Text(formatSats(v.value)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChatZapWidget extends StatelessWidget {
|
||||||
final StreamEvent stream;
|
final StreamEvent stream;
|
||||||
final Nip01Event zap;
|
final Nip01Event zap;
|
||||||
|
|
||||||
const ChatZapWidget({super.key, required this.stream, required this.zap});
|
const _ChatZapWidget({required this.stream, required this.zap});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -125,6 +221,7 @@ class ChatZapWidget extends StatelessWidget {
|
|||||||
padding: EdgeInsets.only(right: 8),
|
padding: EdgeInsets.only(right: 8),
|
||||||
child: AvatarWidget(profile: profile, size: 20),
|
child: AvatarWidget(profile: profile, size: 20),
|
||||||
),
|
),
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
),
|
),
|
||||||
TextSpan(text: name),
|
TextSpan(text: name),
|
||||||
TextSpan(text: " zapped ", style: TextStyle(color: FONT_COLOR)),
|
TextSpan(text: " zapped ", style: TextStyle(color: FONT_COLOR)),
|
||||||
@ -138,53 +235,128 @@ class ChatZapWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatMessageWidget extends StatelessWidget {
|
class _ChatMessageWidget extends StatelessWidget {
|
||||||
final StreamEvent stream;
|
final StreamEvent stream;
|
||||||
final Nip01Event msg;
|
final Nip01Event msg;
|
||||||
|
|
||||||
const ChatMessageWidget({super.key, required this.stream, required this.msg});
|
const _ChatMessageWidget({required this.stream, required this.msg});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ProfileLoaderWidget(msg.pubKey, (ctx, state) {
|
return ProfileLoaderWidget(msg.pubKey, (ctx, state) {
|
||||||
final profile = state.data ?? Metadata(pubKey: msg.pubKey);
|
final profile = state.data ?? Metadata(pubKey: msg.pubKey);
|
||||||
return RichText(
|
return GestureDetector(
|
||||||
text: TextSpan(
|
onLongPress: () {
|
||||||
|
if (ndk.accounts.canSign) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
constraints: BoxConstraints.expand(),
|
||||||
|
builder:
|
||||||
|
(ctx) => ProfileModalWidget(profile: profile, event: msg),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
spacing: 2,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
WidgetSpan(
|
_chatText(profile),
|
||||||
child: AvatarWidget(profile: profile, size: 24),
|
RxFilter<Nip01Event>(
|
||||||
alignment: PlaceholderAlignment.middle,
|
filters: [
|
||||||
|
Filter(kinds: [9735, 7], eTags: [msg.id]),
|
||||||
|
],
|
||||||
|
builder: (ctx, data) => _chatReactions(data),
|
||||||
),
|
),
|
||||||
TextSpan(text: " "),
|
|
||||||
WidgetSpan(
|
|
||||||
alignment: PlaceholderAlignment.middle,
|
|
||||||
child: ProfileNameWidget(
|
|
||||||
profile: profile,
|
|
||||||
style: TextStyle(
|
|
||||||
color:
|
|
||||||
msg.pubKey == stream.info.host ? PRIMARY_1 : SECONDARY_1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(text: " "),
|
|
||||||
TextSpan(text: msg.content, style: TextStyle(color: FONT_COLOR)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _chatText(Metadata profile) {
|
||||||
|
return RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
WidgetSpan(
|
||||||
|
child: AvatarWidget(profile: profile, size: 24),
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
),
|
||||||
|
TextSpan(text: " "),
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: ProfileNameWidget(
|
||||||
|
profile: profile,
|
||||||
|
style: TextStyle(
|
||||||
|
color: msg.pubKey == stream.info.host ? PRIMARY_1 : SECONDARY_1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(text: " "),
|
||||||
|
...textToSpans(msg.content, msg.tags, msg.pubKey),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _chatReactions(List<Nip01Event>? events) {
|
||||||
|
if ((events?.length ?? 0) == 0) return SizedBox.shrink();
|
||||||
|
|
||||||
|
final zaps = events!
|
||||||
|
.where((e) => e.kind == 9735)
|
||||||
|
.map((e) => ZapReceipt.fromEvent(e));
|
||||||
|
final reactions = events.where((e) => e.kind == 7);
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
if (zaps.isNotEmpty)
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||||
|
decoration: BoxDecoration(color: LAYER_2, borderRadius: DEFAULT_BR),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.bolt, color: ZAP_1, size: 16),
|
||||||
|
Text(
|
||||||
|
formatSats(
|
||||||
|
zaps.fold(0, (acc, v) => acc + (v.amountSats ?? 0)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (reactions.isNotEmpty)
|
||||||
|
...reactions
|
||||||
|
.fold(<String, Set<String>>{}, (acc, v) {
|
||||||
|
acc[v.content] ??= Set();
|
||||||
|
acc[v.content]!.add(v.pubKey);
|
||||||
|
return acc;
|
||||||
|
})
|
||||||
|
.entries
|
||||||
|
.map(
|
||||||
|
(v) => Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: LAYER_2,
|
||||||
|
borderRadius: DEFAULT_BR,
|
||||||
|
),
|
||||||
|
child: Center(child: Text(v.key)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WriteMessageWidget extends StatefulWidget {
|
class _WriteMessageWidget extends StatefulWidget {
|
||||||
final StreamEvent stream;
|
final StreamEvent stream;
|
||||||
|
|
||||||
const WriteMessageWidget({super.key, required this.stream});
|
const _WriteMessageWidget({required this.stream});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _WriteMessageWidget();
|
State<StatefulWidget> createState() => __WriteMessageWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _WriteMessageWidget extends State<WriteMessageWidget> {
|
class __WriteMessageWidget extends State<_WriteMessageWidget> {
|
||||||
final TextEditingController _controller = TextEditingController();
|
final TextEditingController _controller = TextEditingController();
|
||||||
|
|
||||||
Future<void> _sendMessage() async {
|
Future<void> _sendMessage() async {
|
||||||
@ -207,6 +379,7 @@ class _WriteMessageWidget extends State<WriteMessageWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final canSign = ndk.accounts.canSign;
|
||||||
final isLogin = ndk.accounts.isLoggedIn;
|
final isLogin = ndk.accounts.isLoggedIn;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
@ -214,7 +387,7 @@ class _WriteMessageWidget extends State<WriteMessageWidget> {
|
|||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
decoration: BoxDecoration(color: LAYER_2, borderRadius: DEFAULT_BR),
|
decoration: BoxDecoration(color: LAYER_2, borderRadius: DEFAULT_BR),
|
||||||
child:
|
child:
|
||||||
isLogin
|
canSign
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -240,7 +413,15 @@ class _WriteMessageWidget extends State<WriteMessageWidget> {
|
|||||||
)
|
)
|
||||||
: Container(
|
: Container(
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
padding: EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(children: [Text("Please login to send messages")]),
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
isLogin
|
||||||
|
? "Can't write messages with npub login"
|
||||||
|
: "Please login to send messages",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
58
lib/widgets/mute_button.dart
Normal file
58
lib/widgets/mute_button.dart
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:ndk/domain_layer/entities/nip_51_list.dart';
|
||||||
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/button.dart';
|
||||||
|
|
||||||
|
class MuteButton extends StatelessWidget {
|
||||||
|
final String pubkey;
|
||||||
|
|
||||||
|
const MuteButton({super.key, required this.pubkey});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
||||||
|
if (signer == null || signer.getPublicKey() == pubkey) {
|
||||||
|
return SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FutureBuilder(
|
||||||
|
future: ndk.lists.getSingleNip51List(Nip51List.kMute, signer),
|
||||||
|
builder: (ctx, state) {
|
||||||
|
final mutes = (state.data?.pubKeys ?? []).map((e) => e.value).toSet();
|
||||||
|
final isMuted = mutes.contains(pubkey);
|
||||||
|
return BasicButton(
|
||||||
|
Text(
|
||||||
|
isMuted ? "Unmute" : "Mute",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Color.fromARGB(255, 0, 0, 0),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||||
|
decoration: BoxDecoration(color: WARNING, borderRadius: DEFAULT_BR),
|
||||||
|
onTap: () async {
|
||||||
|
if (isMuted) {
|
||||||
|
await ndk.lists.broadcastRemoveNip51ListElement(
|
||||||
|
Nip51List.kMute,
|
||||||
|
Nip51List.kPubkey,
|
||||||
|
pubkey,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await ndk.lists.broadcastAddNip51ListElement(
|
||||||
|
Nip51List.kMute,
|
||||||
|
Nip51List.kPubkey,
|
||||||
|
pubkey,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (ctx.mounted) {
|
||||||
|
Navigator.pop(ctx);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
108
lib/widgets/nostr_text.dart
Normal file
108
lib/widgets/nostr_text.dart
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:ndk/ndk.dart';
|
||||||
|
import 'package:ndk/shared/nips/nip19/nip19.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/profile.dart';
|
||||||
|
|
||||||
|
/// Converts a nostr note text containing links
|
||||||
|
/// and mentions into multiple spans for rendering
|
||||||
|
List<InlineSpan> textToSpans(
|
||||||
|
String content,
|
||||||
|
List<List<String>> tags,
|
||||||
|
String pubkey,
|
||||||
|
) {
|
||||||
|
return _buildContentSpans(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Content parser from camelus
|
||||||
|
/// https://github.com/leo-lox/camelus/blob/f58455a0ac07fcc780bdc69b8f4544fd5ea4a46d/lib/presentation_layer/components/note_card/note_card_build_split_content.dart#L262
|
||||||
|
List<InlineSpan> _buildContentSpans(String content) {
|
||||||
|
List<InlineSpan> spans = [];
|
||||||
|
RegExp exp = RegExp(
|
||||||
|
r'nostr:(nprofile|npub)[a-zA-Z0-9]+|'
|
||||||
|
r'nostr:(note|nevent)[a-zA-Z0-9]+|'
|
||||||
|
r'(#\$\$\s*[0-9]+\s*\$\$)|'
|
||||||
|
r'(#\w+)|' // Hashtags
|
||||||
|
r'(https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))', // URLs
|
||||||
|
caseSensitive: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
content.splitMapJoin(
|
||||||
|
exp,
|
||||||
|
onMatch: (Match match) {
|
||||||
|
String? matched = match.group(0);
|
||||||
|
if (matched != null) {
|
||||||
|
if (matched.startsWith('nostr:')) {
|
||||||
|
spans.add(_buildProfileOrNoteSpan(matched));
|
||||||
|
} else if (matched.startsWith('#')) {
|
||||||
|
spans.add(_buildHashtagSpan(matched));
|
||||||
|
} else if (matched.startsWith('http')) {
|
||||||
|
spans.add(_buildUrlSpan(matched));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
onNonMatch: (String text) {
|
||||||
|
spans.add(TextSpan(text: text));
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return spans;
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineSpan _buildProfileOrNoteSpan(String word) {
|
||||||
|
final cleanedWord = word.replaceAll('nostr:', '');
|
||||||
|
final isProfile =
|
||||||
|
cleanedWord.startsWith('nprofile') || cleanedWord.startsWith('npub');
|
||||||
|
final isNote =
|
||||||
|
cleanedWord.startsWith('note') || cleanedWord.startsWith('nevent');
|
||||||
|
|
||||||
|
if (isProfile) {
|
||||||
|
return _inlineMention(Nip19.decode(cleanedWord));
|
||||||
|
}
|
||||||
|
if (isNote) {
|
||||||
|
final eventId = Nip19.decode(cleanedWord);
|
||||||
|
return TextSpan(text: eventId, style: TextStyle(color: PRIMARY_1));
|
||||||
|
} else {
|
||||||
|
return TextSpan(text: word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineSpan _buildHashtagSpan(String word) {
|
||||||
|
return TextSpan(text: word, style: TextStyle(color: PRIMARY_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineSpan _buildUrlSpan(String url) {
|
||||||
|
return TextSpan(
|
||||||
|
text: url,
|
||||||
|
style: TextStyle(color: PRIMARY_1),
|
||||||
|
recognizer:
|
||||||
|
TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
launchUrl(Uri.parse(url));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineSpan _inlineMention(String pubkey) {
|
||||||
|
return WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: ProfileLoaderWidget(pubkey, (ctx, profile) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap:
|
||||||
|
() => ctx.push(
|
||||||
|
"/p/${Nip19.encodePubKey(pubkey)}",
|
||||||
|
extra: profile.data,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"@${ProfileNameWidget.nameFromProfile(profile.data ?? Metadata(pubKey: pubkey))}",
|
||||||
|
style: TextStyle(color: PRIMARY_1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
@ -64,19 +64,34 @@ class ProfileWidget extends StatelessWidget {
|
|||||||
final Metadata profile;
|
final Metadata profile;
|
||||||
final TextStyle? style;
|
final TextStyle? style;
|
||||||
final double? size;
|
final double? size;
|
||||||
|
final List<Widget>? children;
|
||||||
|
final bool? showName;
|
||||||
|
final double? spacing;
|
||||||
|
|
||||||
const ProfileWidget({
|
const ProfileWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.profile,
|
required this.profile,
|
||||||
this.style,
|
this.style,
|
||||||
this.size,
|
this.size,
|
||||||
|
this.children,
|
||||||
|
this.showName,
|
||||||
|
this.spacing,
|
||||||
});
|
});
|
||||||
|
|
||||||
static Widget pubkey(String pubkey, {double? size}) {
|
static Widget pubkey(
|
||||||
|
String pubkey, {
|
||||||
|
double? size,
|
||||||
|
List<Widget>? children,
|
||||||
|
bool? showName,
|
||||||
|
double? spacing,
|
||||||
|
}) {
|
||||||
return ProfileLoaderWidget(pubkey, (ctx, state) {
|
return ProfileLoaderWidget(pubkey, (ctx, state) {
|
||||||
return ProfileWidget(
|
return ProfileWidget(
|
||||||
profile: state.data ?? Metadata(pubKey: pubkey),
|
profile: state.data ?? Metadata(pubKey: pubkey),
|
||||||
size: size,
|
size: size,
|
||||||
|
showName: showName,
|
||||||
|
spacing: spacing,
|
||||||
|
children: children,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -84,10 +99,11 @@ class ProfileWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
spacing: 8,
|
spacing: spacing ?? 8,
|
||||||
children: [
|
children: [
|
||||||
AvatarWidget(profile: profile, size: size),
|
AvatarWidget(profile: profile, size: size),
|
||||||
ProfileNameWidget(profile: profile),
|
if (showName ?? true) ProfileNameWidget(profile: profile),
|
||||||
|
...(children ?? []),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
85
lib/widgets/profile_modal.dart
Normal file
85
lib/widgets/profile_modal.dart
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import 'dart:developer' as developer;
|
||||||
|
|
||||||
|
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
||||||
|
import 'package:flutter/foundation.dart' as foundation;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:ndk/ndk.dart';
|
||||||
|
import 'package:zap_stream_flutter/main.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/button.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/mute_button.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/profile.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/zap.dart';
|
||||||
|
|
||||||
|
class ProfileModalWidget extends StatelessWidget {
|
||||||
|
final Metadata profile;
|
||||||
|
final Nip01Event event;
|
||||||
|
|
||||||
|
const ProfileModalWidget({
|
||||||
|
super.key,
|
||||||
|
required this.profile,
|
||||||
|
required this.event,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.fromLTRB(5, 10, 5, 0),
|
||||||
|
child: Column(
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
ProfileWidget(profile: profile),
|
||||||
|
EmojiPicker(
|
||||||
|
onEmojiSelected: (category, emoji) {
|
||||||
|
developer.log(emoji.emoji);
|
||||||
|
ndk.broadcast.broadcastReaction(
|
||||||
|
eventId: event.id,
|
||||||
|
reaction: emoji.emoji,
|
||||||
|
);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
config: Config(
|
||||||
|
height: 256,
|
||||||
|
checkPlatformCompatibility: true,
|
||||||
|
emojiViewConfig: EmojiViewConfig(
|
||||||
|
emojiSizeMax:
|
||||||
|
28 *
|
||||||
|
(foundation.defaultTargetPlatform == TargetPlatform.iOS
|
||||||
|
? 1.20
|
||||||
|
: 1.0),
|
||||||
|
backgroundColor: LAYER_1,
|
||||||
|
),
|
||||||
|
viewOrderConfig: const ViewOrderConfig(
|
||||||
|
top: EmojiPickerItem.categoryBar,
|
||||||
|
middle: EmojiPickerItem.emojiView,
|
||||||
|
bottom: EmojiPickerItem.searchBar,
|
||||||
|
),
|
||||||
|
bottomActionBarConfig: BottomActionBarConfig(
|
||||||
|
backgroundColor: LAYER_2,
|
||||||
|
buttonColor: PRIMARY_1,
|
||||||
|
),
|
||||||
|
categoryViewConfig: CategoryViewConfig(backgroundColor: LAYER_2),
|
||||||
|
searchViewConfig: SearchViewConfig(
|
||||||
|
backgroundColor: LAYER_2,
|
||||||
|
buttonIconColor: PRIMARY_1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BasicButton.text(
|
||||||
|
"Zap",
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
constraints: BoxConstraints.expand(),
|
||||||
|
builder: (ctx) {
|
||||||
|
return ZapWidget(pubkey: event.pubKey, target: event);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
MuteButton(pubkey: event.pubKey),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,8 @@ class StreamGrid extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final streams = events
|
final streams = events
|
||||||
.map((e) => StreamEvent(e))
|
.map((e) => StreamEvent(e))
|
||||||
.where((e) => e.info.stream?.isNotEmpty ?? false)
|
.sortedBy((a) => a.info.starts ?? a.event.createdAt)
|
||||||
.sortedBy((a) => a.info.starts ?? a.event.createdAt);
|
.reversed;
|
||||||
final live = streams.where((s) => s.info.status == StreamStatus.live);
|
final live = streams.where((s) => s.info.status == StreamStatus.live);
|
||||||
final ended = streams.where((s) => s.info.status == StreamStatus.ended);
|
final ended = streams.where((s) => s.info.status == StreamStatus.ended);
|
||||||
final planned = streams.where((s) => s.info.status == StreamStatus.planned);
|
final planned = streams.where((s) => s.info.status == StreamStatus.planned);
|
||||||
|
@ -147,7 +147,7 @@ class _ZapWidget extends State<ZapWidget> {
|
|||||||
pubKey: widget.pubkey,
|
pubKey: widget.pubkey,
|
||||||
eventId: widget.target?.id,
|
eventId: widget.target?.id,
|
||||||
addressableId:
|
addressableId:
|
||||||
widget.target != null
|
widget.target != null && widget.target!.kind >= 30_000 && widget.target!.kind < 40_000
|
||||||
? "${widget.target!.kind}:${widget.target!.pubKey}:${widget.target!.getDtag()!}"
|
? "${widget.target!.kind}:${widget.target!.pubKey}:${widget.target!.getDtag()!}"
|
||||||
: null,
|
: null,
|
||||||
relays: defaultRelays,
|
relays: defaultRelays,
|
||||||
|
@ -6,11 +6,19 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <emoji_picker_flutter/emoji_picker_flutter_plugin.h>
|
||||||
|
#include <file_selector_linux/file_selector_plugin.h>
|
||||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||||
#include <objectbox_flutter_libs/objectbox_flutter_libs_plugin.h>
|
#include <objectbox_flutter_libs/objectbox_flutter_libs_plugin.h>
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
|
g_autoptr(FlPluginRegistrar) emoji_picker_flutter_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "EmojiPickerFlutterPlugin");
|
||||||
|
emoji_picker_flutter_plugin_register_with_registrar(emoji_picker_flutter_registrar);
|
||||||
|
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||||
|
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
||||||
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
emoji_picker_flutter
|
||||||
|
file_selector_linux
|
||||||
flutter_secure_storage_linux
|
flutter_secure_storage_linux
|
||||||
objectbox_flutter_libs
|
objectbox_flutter_libs
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
|
@ -5,20 +5,26 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import emoji_picker_flutter
|
||||||
|
import file_selector_macos
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
import objectbox_flutter_libs
|
import objectbox_flutter_libs
|
||||||
import package_info_plus
|
import package_info_plus
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
|
import shared_preferences_foundation
|
||||||
import sqflite_darwin
|
import sqflite_darwin
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
import video_player_avfoundation
|
import video_player_avfoundation
|
||||||
import wakelock_plus
|
import wakelock_plus
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
|
||||||
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
ObjectboxFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "ObjectboxFlutterLibsPlugin"))
|
ObjectboxFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "ObjectboxFlutterLibsPlugin"))
|
||||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
||||||
|
13
nap.yaml
Normal file
13
nap.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
id: "io.nostrlabs.zap_stream_flutter"
|
||||||
|
name: "zap.stream"
|
||||||
|
description: "Live streaming on nostr"
|
||||||
|
icon: "https://zap.stream/logo.png"
|
||||||
|
images:
|
||||||
|
- "https://nostr.download/baf24ad818fae082cbca3ac9dc1dc132bb9d733fb6660f2128a564e3acfa7d58.webp"
|
||||||
|
- "https://nostr.download/5a5528627022126e54b7501f23fbd3c7bc8437faaac841ad1a98afc2268f8e6f.webp"
|
||||||
|
repository: "https://github.com/nostrlabs-io/zap-stream-flutter"
|
||||||
|
url: "https://zap.stream"
|
||||||
|
license: "MIT"
|
||||||
|
tags:
|
||||||
|
- "livestream"
|
||||||
|
- "video"
|
192
pubspec.lock
192
pubspec.lock
@ -129,6 +129,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
|
cross_file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cross_file
|
||||||
|
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.4+2"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -177,6 +185,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.11"
|
version: "0.3.11"
|
||||||
|
emoji_picker_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: emoji_picker_flutter
|
||||||
|
sha256: "9a44c102079891ea5877f78c70f2e3c6e9df7b7fe0a01757d31f1046eeaa016d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.3.0"
|
||||||
equatable:
|
equatable:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -209,6 +225,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.1"
|
version: "7.0.1"
|
||||||
|
file_selector_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_linux
|
||||||
|
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.3+2"
|
||||||
|
file_selector_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_macos
|
||||||
|
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.4+2"
|
||||||
|
file_selector_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_platform_interface
|
||||||
|
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.6.2"
|
||||||
|
file_selector_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_windows
|
||||||
|
sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.3+4"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -246,6 +294,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
sha256: f948e346c12f8d5480d2825e03de228d0eb8c3a737e4cdaa122267b89c022b5e
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.28"
|
||||||
flutter_rust_bridge:
|
flutter_rust_bridge:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -360,6 +416,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.2"
|
version: "4.1.2"
|
||||||
|
image_picker:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: image_picker
|
||||||
|
sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.2"
|
||||||
|
image_picker_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_android
|
||||||
|
sha256: "317a5d961cec5b34e777b9252393f2afbd23084aa6e60fcf601dcf6341b9ebeb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.12+23"
|
||||||
|
image_picker_for_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_for_web
|
||||||
|
sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.6"
|
||||||
|
image_picker_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_ios
|
||||||
|
sha256: "05da758e67bc7839e886b3959848aa6b44ff123ab4b28f67891008afe8ef9100"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.12+2"
|
||||||
|
image_picker_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_linux
|
||||||
|
sha256: "34a65f6740df08bbbeb0a1abd8e6d32107941fd4868f67a507b25601651022c9"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+2"
|
||||||
|
image_picker_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_macos
|
||||||
|
sha256: "1b90ebbd9dcf98fb6c1d01427e49a55bd96b5d67b8c67cf955d60a5de74207c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+2"
|
||||||
|
image_picker_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_platform_interface
|
||||||
|
sha256: "886d57f0be73c4b140004e78b9f28a8914a09e50c2d816bdd0520051a71236a0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.10.1"
|
||||||
|
image_picker_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_windows
|
||||||
|
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+1"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -440,6 +560,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.16.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
ndk:
|
ndk:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -657,6 +785,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.28.0"
|
version: "0.28.0"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.3"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "20cbd561f743a342c76c151d6ddb93a9ce6005751e7aa458baad3858bfbfb6ac"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.10"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.4"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.3"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -774,6 +958,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
|
universal_io:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: universal_io
|
||||||
|
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.2"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: zap_stream_flutter
|
name: zap_stream_flutter
|
||||||
description: "zap.stream"
|
description: "zap.stream"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.1.0+1
|
version: 0.2.1+3
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.7.2
|
sdk: ^3.7.2
|
||||||
@ -28,6 +28,8 @@ dependencies:
|
|||||||
qr_flutter: ^4.1.0
|
qr_flutter: ^4.1.0
|
||||||
url_launcher: ^6.3.1
|
url_launcher: ^6.3.1
|
||||||
chewie: ^1.11.3
|
chewie: ^1.11.3
|
||||||
|
image_picker: ^1.1.2
|
||||||
|
emoji_picker_flutter: ^4.3.0
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
ndk:
|
ndk:
|
||||||
|
@ -6,11 +6,17 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <emoji_picker_flutter/emoji_picker_flutter_plugin_c_api.h>
|
||||||
|
#include <file_selector_windows/file_selector_windows.h>
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
#include <objectbox_flutter_libs/objectbox_flutter_libs_plugin.h>
|
#include <objectbox_flutter_libs/objectbox_flutter_libs_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
|
EmojiPickerFlutterPluginCApiRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("EmojiPickerFlutterPluginCApi"));
|
||||||
|
FileSelectorWindowsRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
ObjectboxFlutterLibsPluginRegisterWithRegistrar(
|
ObjectboxFlutterLibsPluginRegisterWithRegistrar(
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
emoji_picker_flutter
|
||||||
|
file_selector_windows
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
objectbox_flutter_libs
|
objectbox_flutter_libs
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
|
Reference in New Issue
Block a user