mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 08:32:13 +00:00
unblock users and UI improvements
This commit is contained in:
parent
4d39eb0bf4
commit
e6b549e897
2 changed files with 75 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
import 'package:clock/clock.dart';
|
import 'package:clock/clock.dart';
|
||||||
|
import 'package:drift/drift.dart' show Value;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
@ -357,7 +358,14 @@ class MainCameraController {
|
||||||
if (res == null) continue;
|
if (res == null) continue;
|
||||||
final (profile, contact, verificationOk) = res;
|
final (profile, contact, verificationOk) = res;
|
||||||
|
|
||||||
if (contact == null) {
|
if (contact?.blocked ?? false) {
|
||||||
|
await twonlyDB.contactsDao.updateContact(
|
||||||
|
contact!.userId,
|
||||||
|
const ContactsCompanion(blocked: Value(false)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contact == null || contact.deletedByUser) {
|
||||||
if (scannedNewProfiles[profile.userId.toInt()] == null) {
|
if (scannedNewProfiles[profile.userId.toInt()] == null) {
|
||||||
await HapticFeedback.heavyImpact();
|
await HapticFeedback.heavyImpact();
|
||||||
scannedNewProfiles[profile.userId.toInt()] = ScannedNewProfile(
|
scannedNewProfiles[profile.userId.toInt()] = ScannedNewProfile(
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
|
@ -12,7 +13,9 @@ import 'package:twonly/src/services/signal/identity.signal.dart';
|
||||||
import 'package:twonly/src/utils/avatars.dart';
|
import 'package:twonly/src/utils/avatars.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/utils/qr.utils.dart';
|
import 'package:twonly/src/utils/qr.utils.dart';
|
||||||
|
import 'package:twonly/src/visual/components/notification_badge.comp.dart';
|
||||||
import 'package:twonly/src/visual/elements/better_list_title.element.dart';
|
import 'package:twonly/src/visual/elements/better_list_title.element.dart';
|
||||||
|
import 'package:twonly/src/visual/themes/light.dart';
|
||||||
|
|
||||||
class PublicProfileView extends StatefulWidget {
|
class PublicProfileView extends StatefulWidget {
|
||||||
const PublicProfileView({super.key});
|
const PublicProfileView({super.key});
|
||||||
|
|
@ -25,6 +28,8 @@ class _PublicProfileViewState extends State<PublicProfileView> {
|
||||||
String? _qrCode;
|
String? _qrCode;
|
||||||
Uint8List? _userAvatar;
|
Uint8List? _userAvatar;
|
||||||
Uint8List? _publicKey;
|
Uint8List? _publicKey;
|
||||||
|
int _countContactRequest = 0;
|
||||||
|
late StreamSubscription<int?> _countContactRequestStream;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -37,12 +42,72 @@ class _PublicProfileViewState extends State<PublicProfileView> {
|
||||||
_userAvatar = await getUserAvatar();
|
_userAvatar = await getUserAvatar();
|
||||||
_publicKey = await getUserPublicKey();
|
_publicKey = await getUserPublicKey();
|
||||||
if (mounted) setState(() {});
|
if (mounted) setState(() {});
|
||||||
|
|
||||||
|
_countContactRequestStream = twonlyDB.contactsDao
|
||||||
|
.watchContactsRequestedCount()
|
||||||
|
.listen((update) {
|
||||||
|
if (update != null) {
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_countContactRequest = update;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_countContactRequestStream.cancel();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(
|
||||||
|
actions: [
|
||||||
|
Stack(
|
||||||
|
children: (_countContactRequest == 0)
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: primaryColor,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: NotificationBadgeComp(
|
||||||
|
backgroundColor: isDarkMode(context)
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black,
|
||||||
|
textColor: isDarkMode(context)
|
||||||
|
? Colors.black
|
||||||
|
: Colors.white,
|
||||||
|
count: (_countContactRequest).toString(),
|
||||||
|
child: IconButton(
|
||||||
|
color: (_countContactRequest > 0)
|
||||||
|
? Colors.black
|
||||||
|
: null,
|
||||||
|
icon: const FaIcon(
|
||||||
|
FontAwesomeIcons.userPlus,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
onPressed: () => context.push(Routes.chatsAddNewUser),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(width: double.infinity),
|
Container(width: double.infinity),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue