mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
some more missing non updating states
This commit is contained in:
parent
bfb0b64093
commit
2e20859a69
6 changed files with 67 additions and 46 deletions
|
|
@ -111,6 +111,9 @@ class _DrawLayerState extends State<DrawLayer> {
|
||||||
tooltipText: context.lang.imageEditorDrawOk,
|
tooltipText: context.lang.imageEditorDrawOk,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
widget.layerData.isEditing = false;
|
widget.layerData.isEditing = false;
|
||||||
|
if (widget.onUpdate != null) {
|
||||||
|
widget.onUpdate!();
|
||||||
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
"contactVerifyNumberMarkAsVerified": "Als verifiziert markieren",
|
"contactVerifyNumberMarkAsVerified": "Als verifiziert markieren",
|
||||||
"contactVerifyNumberClearVerification": "Verifizierung aufheben",
|
"contactVerifyNumberClearVerification": "Verifizierung aufheben",
|
||||||
"contactVerifyNumberLongDesc": "Um die Ende-zu-Ende-Verschlüsselung mit {username} zu verifizieren, vergleiche die Zahlen mit ihrem Gerät. Die Person kann auch deinen Code mit ihrem Gerät scannen.",
|
"contactVerifyNumberLongDesc": "Um die Ende-zu-Ende-Verschlüsselung mit {username} zu verifizieren, vergleiche die Zahlen mit ihrem Gerät. Die Person kann auch deinen Code mit ihrem Gerät scannen.",
|
||||||
"contactNickame": "Spitzname",
|
"contactNickname": "Spitzname",
|
||||||
"contactBlock": "Blockieren",
|
"contactBlock": "Blockieren",
|
||||||
"contactBlockTitle": "Blockiere {username}",
|
"contactBlockTitle": "Blockiere {username}",
|
||||||
"contactBlockBody": "Ein blockierter Benutzer kann dir keine Nachrichten mehr senden, und sein Profil ist nicht mehr sichtbar. Um die Blockierung eines Benutzers aufzuheben, navigiere einfach zu Einstellungen > Datenschutz > Blockierte Benutzer.",
|
"contactBlockBody": "Ein blockierter Benutzer kann dir keine Nachrichten mehr senden, und sein Profil ist nicht mehr sichtbar. Um die Blockierung eines Benutzers aufzuheben, navigiere einfach zu Einstellungen > Datenschutz > Blockierte Benutzer.",
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
"contactVerifyNumberMarkAsVerified": "Mark as verified",
|
"contactVerifyNumberMarkAsVerified": "Mark as verified",
|
||||||
"contactVerifyNumberClearVerification": "Clear verification",
|
"contactVerifyNumberClearVerification": "Clear verification",
|
||||||
"contactVerifyNumberLongDesc": "To verify the end-to-end encryption with {username}, compare the numbers with their device. The person can also scan your code with their device.",
|
"contactVerifyNumberLongDesc": "To verify the end-to-end encryption with {username}, compare the numbers with their device. The person can also scan your code with their device.",
|
||||||
"contactNickame": "Nickname",
|
"contactNickname": "Nickname",
|
||||||
"contactBlock": "Block",
|
"contactBlock": "Block",
|
||||||
"contactBlockTitle": "Block {username}",
|
"contactBlockTitle": "Block {username}",
|
||||||
"contactBlockBody": "A blocked user will no longer be able to send you messages and their profile will be hidden from view. To unblock a user, simply navigate to Settings > Privacy > Blocked Users.",
|
"contactBlockBody": "A blocked user will no longer be able to send you messages and their profile will be hidden from view. To unblock a user, simply navigate to Settings > Privacy > Blocked Users.",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import 'package:twonly/src/model/contacts_model.dart';
|
||||||
import 'package:twonly/src/model/json/message.dart';
|
import 'package:twonly/src/model/json/message.dart';
|
||||||
import 'package:twonly/src/model/messages_model.dart';
|
import 'package:twonly/src/model/messages_model.dart';
|
||||||
import 'package:twonly/src/providers/api/api.dart';
|
import 'package:twonly/src/providers/api/api.dart';
|
||||||
|
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||||
import 'package:twonly/src/providers/download_change_provider.dart';
|
import 'package:twonly/src/providers/download_change_provider.dart';
|
||||||
import 'package:twonly/src/providers/messages_change_provider.dart';
|
import 'package:twonly/src/providers/messages_change_provider.dart';
|
||||||
import 'package:twonly/src/services/notification_service.dart';
|
import 'package:twonly/src/services/notification_service.dart';
|
||||||
|
|
@ -131,25 +132,29 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
||||||
int lastChangeCounter = 0;
|
int lastChangeCounter = 0;
|
||||||
final TextEditingController newMessageController = TextEditingController();
|
final TextEditingController newMessageController = TextEditingController();
|
||||||
HashSet<int> alreadyReportedOpened = HashSet<int>();
|
HashSet<int> alreadyReportedOpened = HashSet<int>();
|
||||||
|
int sendTextMessages = 0;
|
||||||
|
late Contact user;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
user = widget.user;
|
||||||
_loadAsync(updateOpenStatus: true);
|
_loadAsync(updateOpenStatus: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _loadAsync({bool updateOpenStatus = false}) async {
|
Future _loadAsync({bool updateOpenStatus = false}) async {
|
||||||
// if (_messages.isEmpty || updateOpenStatus) {
|
// if (_messages.isEmpty || updateOpenStatus) {
|
||||||
_messages =
|
if (sendTextMessages <= 0) {
|
||||||
await DbMessages.getAllMessagesForUser(widget.user.userId.toInt());
|
_messages = await DbMessages.getAllMessagesForUser(user.userId.toInt());
|
||||||
// } else {
|
} else {
|
||||||
// will not update older message states like when they now downloaded...
|
sendTextMessages--;
|
||||||
// int lastMessageId = _messages.first.messageId;
|
// will not update older message states like when they now downloaded...
|
||||||
// List<DbMessage> toAppend =
|
int lastMessageId = _messages.first.messageId;
|
||||||
// await DbMessages.getAllMessagesForUserWithHigherMessageId(
|
List<DbMessage> toAppend =
|
||||||
// widget.user.userId.toInt(), lastMessageId);
|
await DbMessages.getAllMessagesForUserWithHigherMessageId(
|
||||||
// _messages.insertAll(0, toAppend);
|
user.userId.toInt(), lastMessageId);
|
||||||
// }
|
_messages.insertAll(0, toAppend);
|
||||||
|
}
|
||||||
|
|
||||||
if (updateOpenStatus) {
|
if (updateOpenStatus) {
|
||||||
_messages.where((x) => x.messageOpenedAt == null).forEach((message) {
|
_messages.where((x) => x.messageOpenedAt == null).forEach((message) {
|
||||||
|
|
@ -175,20 +180,25 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _sendMessage() async {
|
Future _sendMessage() async {
|
||||||
|
sendTextMessages++;
|
||||||
String text = newMessageController.text;
|
String text = newMessageController.text;
|
||||||
if (text == "") return;
|
if (text == "") return;
|
||||||
await sendTextMessage(widget.user.userId, newMessageController.text);
|
await sendTextMessage(user.userId, newMessageController.text);
|
||||||
newMessageController.clear();
|
newMessageController.clear();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
user = context
|
||||||
|
.watch<ContactChangeProvider>()
|
||||||
|
.allContacts
|
||||||
|
.firstWhere((c) => c.userId == widget.user.userId);
|
||||||
final changeCounter = context.watch<MessagesChangeProvider>().changeCounter;
|
final changeCounter = context.watch<MessagesChangeProvider>().changeCounter;
|
||||||
if (changeCounter.containsKey(widget.user.userId.toInt())) {
|
if (changeCounter.containsKey(user.userId.toInt())) {
|
||||||
if (changeCounter[widget.user.userId.toInt()] != lastChangeCounter) {
|
if (changeCounter[user.userId.toInt()] != lastChangeCounter) {
|
||||||
_loadAsync(updateOpenStatus: true);
|
_loadAsync(updateOpenStatus: true);
|
||||||
lastChangeCounter = changeCounter[widget.user.userId.toInt()]!;
|
lastChangeCounter = changeCounter[user.userId.toInt()]!;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -197,13 +207,13 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
||||||
title: GestureDetector(
|
title: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||||
return ContactView(widget.user);
|
return ContactView(user.userId.toInt());
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
InitialsAvatar(
|
InitialsAvatar(
|
||||||
displayName: widget.user.displayName,
|
displayName: user.displayName,
|
||||||
fontSize: 19,
|
fontSize: 19,
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
|
|
@ -212,9 +222,9 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(widget.user.displayName),
|
Text(user.displayName),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
VerifiedShield(widget.user),
|
VerifiedShield(user),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -248,7 +258,7 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
||||||
}
|
}
|
||||||
return ChatListEntry(
|
return ChatListEntry(
|
||||||
_messages[i],
|
_messages[i],
|
||||||
widget.user,
|
user,
|
||||||
lastMessageFromSameUser,
|
lastMessageFromSameUser,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart';
|
import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:twonly/src/components/format_long_string.dart';
|
import 'package:twonly/src/components/format_long_string.dart';
|
||||||
import 'package:twonly/src/model/contacts_model.dart';
|
import 'package:twonly/src/model/contacts_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/utils/signal.dart';
|
import 'package:twonly/src/utils/signal.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
@ -34,6 +36,11 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Contact contact = context
|
||||||
|
.watch<ContactChangeProvider>()
|
||||||
|
.allContacts
|
||||||
|
.firstWhere((c) => c.userId == widget.contact.userId);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(context.lang.contactVerifyNumberTitle),
|
title: Text(context.lang.contactVerifyNumberTitle),
|
||||||
|
|
@ -88,8 +95,8 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 30),
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
child: Text(
|
child: Text(
|
||||||
context.lang.contactVerifyNumberLongDesc(
|
context.lang
|
||||||
widget.contact.displayName),
|
.contactVerifyNumberLongDesc(contact.displayName),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -118,11 +125,11 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
widget.contact.verified
|
contact.verified
|
||||||
? OutlinedButton.icon(
|
? OutlinedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
DbContacts.updateVerificationStatus(
|
DbContacts.updateVerificationStatus(
|
||||||
widget.contact.userId.toInt(), false);
|
contact.userId.toInt(), false);
|
||||||
},
|
},
|
||||||
label: Text(
|
label: Text(
|
||||||
context.lang.contactVerifyNumberClearVerification),
|
context.lang.contactVerifyNumberClearVerification),
|
||||||
|
|
@ -131,7 +138,7 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
||||||
icon: FaIcon(FontAwesomeIcons.shieldHeart),
|
icon: FaIcon(FontAwesomeIcons.shieldHeart),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
DbContacts.updateVerificationStatus(
|
DbContacts.updateVerificationStatus(
|
||||||
widget.contact.userId.toInt(), true);
|
contact.userId.toInt(), true);
|
||||||
},
|
},
|
||||||
label:
|
label:
|
||||||
Text(context.lang.contactVerifyNumberMarkAsVerified),
|
Text(context.lang.contactVerifyNumberMarkAsVerified),
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,31 @@ import 'package:twonly/src/components/initialsavatar.dart';
|
||||||
import 'package:twonly/src/components/verified_shield.dart';
|
import 'package:twonly/src/components/verified_shield.dart';
|
||||||
import 'package:twonly/src/model/contacts_model.dart';
|
import 'package:twonly/src/model/contacts_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||||
import 'package:twonly/src/providers/messages_change_provider.dart';
|
import 'package:twonly/src/providers/messages_change_provider.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/views/contact/contact_verify_view.dart';
|
import 'package:twonly/src/views/contact/contact_verify_view.dart';
|
||||||
|
|
||||||
class ContactView extends StatefulWidget {
|
class ContactView extends StatefulWidget {
|
||||||
const ContactView(this.contact, {super.key});
|
const ContactView(this.userId, {super.key});
|
||||||
|
|
||||||
final Contact contact;
|
final int userId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ContactView> createState() => _ContactViewState();
|
State<ContactView> createState() => _ContactViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ContactViewState extends State<ContactView> {
|
class _ContactViewState extends State<ContactView> {
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Contact contact = context
|
||||||
|
.watch<ContactChangeProvider>()
|
||||||
|
.allContacts
|
||||||
|
.firstWhere((c) => c.userId == widget.userId);
|
||||||
|
|
||||||
int flameCounter = context
|
int flameCounter = context
|
||||||
.watch<MessagesChangeProvider>()
|
.watch<MessagesChangeProvider>()
|
||||||
.flamesCounter[widget.contact.userId.toInt()] ??
|
.flamesCounter[contact.userId.toInt()] ??
|
||||||
0;
|
0;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|
@ -42,7 +43,7 @@ class _ContactViewState extends State<ContactView> {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: InitialsAvatar(
|
child: InitialsAvatar(
|
||||||
displayName: widget.contact.displayName,
|
displayName: contact.displayName,
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -51,14 +52,14 @@ class _ContactViewState extends State<ContactView> {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(right: 10),
|
padding: EdgeInsets.only(right: 10),
|
||||||
child: VerifiedShield(widget.contact)),
|
child: VerifiedShield(contact)),
|
||||||
Text(
|
Text(
|
||||||
widget.contact.displayName,
|
contact.displayName,
|
||||||
style: TextStyle(fontSize: 20),
|
style: TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
if (flameCounter > 0)
|
if (flameCounter > 0)
|
||||||
FlameCounterWidget(
|
FlameCounterWidget(
|
||||||
widget.contact,
|
contact,
|
||||||
flameCounter,
|
flameCounter,
|
||||||
110000000,
|
110000000,
|
||||||
prefix: true,
|
prefix: true,
|
||||||
|
|
@ -68,13 +69,13 @@ class _ContactViewState extends State<ContactView> {
|
||||||
SizedBox(height: 50),
|
SizedBox(height: 50),
|
||||||
BetterListTile(
|
BetterListTile(
|
||||||
icon: FontAwesomeIcons.pencil,
|
icon: FontAwesomeIcons.pencil,
|
||||||
text: context.lang.contactNickame,
|
text: context.lang.contactNickname,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String? newUsername =
|
String? newUsername =
|
||||||
await showNicknameChangeDialog(context, widget.contact);
|
await showNicknameChangeDialog(context, contact);
|
||||||
if (newUsername != null && newUsername != "") {
|
if (newUsername != null && newUsername != "") {
|
||||||
await DbContacts.changeDisplayName(
|
await DbContacts.changeDisplayName(
|
||||||
widget.contact.userId.toInt(), newUsername);
|
contact.userId.toInt(), newUsername);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -85,7 +86,7 @@ class _ContactViewState extends State<ContactView> {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ContactVerifyView(widget.contact);
|
return ContactVerifyView(contact);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
@ -97,11 +98,11 @@ class _ContactViewState extends State<ContactView> {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
bool block = await showAlertDialog(
|
bool block = await showAlertDialog(
|
||||||
context,
|
context,
|
||||||
context.lang.contactBlockTitle(widget.contact.displayName),
|
context.lang.contactBlockTitle(contact.displayName),
|
||||||
context.lang.contactBlockBody,
|
context.lang.contactBlockBody,
|
||||||
);
|
);
|
||||||
if (block) {
|
if (block) {
|
||||||
await DbContacts.blockUser(widget.contact.userId.toInt());
|
await DbContacts.blockUser(contact.userId.toInt());
|
||||||
// go back to the first
|
// go back to the first
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.popUntil(context, (route) => route.isFirst);
|
Navigator.popUntil(context, (route) => route.isFirst);
|
||||||
|
|
@ -140,8 +141,8 @@ Future<String?> showNicknameChangeDialog(
|
||||||
TextButton(
|
TextButton(
|
||||||
child: Text('Submit'),
|
child: Text('Submit'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
String inputText = controller.text;
|
Navigator.of(context)
|
||||||
Navigator.of(context).pop(inputText); // Return the input text
|
.pop(controller.text); // Return the input text
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue