mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-03-27 02:01:51 +01:00
printed qr code for user pubkey in profile print
can be read from nostrylus in both white/black font combo.
This commit is contained in:
parent
a5e320cf72
commit
83d05c2721
@ -5,6 +5,7 @@ import 'package:nostr_console/tree_ds.dart';
|
||||
import 'package:nostr_console/relays.dart';
|
||||
import 'package:nostr_console/settings.dart';
|
||||
import 'package:bip340/bip340.dart';
|
||||
import 'package:qr/qr.dart';
|
||||
|
||||
Future<void> processAnyIncomingEvents(Store node, [bool printNotifications = true]) async {
|
||||
reAdjustAlignment();
|
||||
@ -275,6 +276,32 @@ void reAdjustAlignment() {
|
||||
Store.reCalculateMarkerStr();
|
||||
}
|
||||
|
||||
String getQrCodeAsString(String str) {
|
||||
String output = "";
|
||||
|
||||
final qrCode = QrCode(4, QrErrorCorrectLevel.L)
|
||||
..addData('$str');
|
||||
final qrImage = QrImage(qrCode);
|
||||
|
||||
//print("qrimage modulecount = ${qrImage.moduleCount}");
|
||||
String leftPadding = " ";
|
||||
for (var x = 0; x < qrImage.moduleCount; x++) {
|
||||
output += leftPadding;
|
||||
for (var y = 0; y < qrImage.moduleCount; y++) {
|
||||
if (qrImage.isDark(y, x)) {
|
||||
// render a dark square on the canvas
|
||||
output += "██";
|
||||
}
|
||||
else {
|
||||
output += " ";
|
||||
}
|
||||
}
|
||||
output += "\n";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void printProfile(Store node, String profilePubkey) {
|
||||
bool onlyUserPostAndLike (Tree t) => t.treeSelectorUserPostAndLike(profilePubkey);
|
||||
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), onlyUserPostAndLike);
|
||||
@ -307,6 +334,13 @@ void printProfile(Store node, String profilePubkey) {
|
||||
print("Nip 05 : ${verified?"yes. ${nip05Id}":"no"}");
|
||||
print("\nLast Updated: ${getPrintableDate(dateLastUpdated)}\n");
|
||||
|
||||
// print QR code
|
||||
print("The QR code for the public key:\n\n");
|
||||
try {
|
||||
print(getQrCodeAsString(profilePubkey));
|
||||
} catch(e) {
|
||||
print("Could not generate qr code.\n");
|
||||
}
|
||||
|
||||
if( profilePubkey != userPublicKey) {
|
||||
if( profileContactEvent.eventData.contactList.any((x) => (x.id == userPublicKey))) {
|
||||
|
@ -160,6 +160,7 @@ class EventData {
|
||||
|
||||
int numRoot = 0, numReply = 0;
|
||||
|
||||
// first go over all tags and find out at least one reply and root tag, and count their numbers
|
||||
String rootId = "", replyId = "";
|
||||
for( int i = 0; i < eTags.length; i++) {
|
||||
String eventId = eTags[i][0];
|
||||
@ -176,6 +177,7 @@ class EventData {
|
||||
}
|
||||
}
|
||||
|
||||
// then depending on the numbers and values ( of root and replyto) return the parent
|
||||
if( replyId.length > 0) {
|
||||
if( numReply == 1) {
|
||||
return replyId;
|
||||
@ -197,7 +199,7 @@ class EventData {
|
||||
}
|
||||
|
||||
|
||||
// if reply/root tags don't work, then try to look for parent tag with the deprecated logic from NIP-10
|
||||
// but if reply/root tags don't work, then try to look for parent tag with the deprecated logic from NIP-10
|
||||
if( gDebug > 0) log.info("using deprecated logic of nip10 for event id : $id");
|
||||
for( int i = tags.length - 1; i >= 0; i--) {
|
||||
if( tags[i][0] == "e") {
|
||||
@ -1498,8 +1500,8 @@ extension StringX on String {
|
||||
bool isRomanceLanguage() {
|
||||
|
||||
// https://www.thoughtco.com/most-common-french-words-1372759
|
||||
Set<String> frenchWords = {"oui", "je", "le", "un", "de", "et", "merci", "une", "ce", "pas"};
|
||||
Set<String> spanishWords = {"y", "se", "el", "uso", "que", "te", "los", "va", "ser", "si", "por", "lo", "es", "era", "un", "o"};;
|
||||
Set<String> frenchWords = {"oui", "je", "le", "un", "de", "merci", "une", "ce", "pas"}; // "et" is in 'et al'
|
||||
Set<String> spanishWords = {"y", "se", "el", "uso", "que", "te", "los", "va", "ser", "si", "por", "lo", "es", "era", "un", "o"};
|
||||
|
||||
Set<String> romanceWords = frenchWords.union(spanishWords);
|
||||
for( String word in romanceWords) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user