mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 14:06:47 +00:00
fix: make contact shares click able if already added
This commit is contained in:
parent
6da6f1a9bc
commit
8ef497772a
1 changed files with 49 additions and 37 deletions
|
|
@ -3,7 +3,9 @@ import 'dart:convert';
|
||||||
import 'package:drift/drift.dart' show Value;
|
import 'package:drift/drift.dart' show Value;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:twonly/globals.dart';
|
import 'package:twonly/globals.dart';
|
||||||
|
import 'package:twonly/src/constants/routes.keys.dart';
|
||||||
import 'package:twonly/src/database/twonly.db.dart';
|
import 'package:twonly/src/database/twonly.db.dart';
|
||||||
import 'package:twonly/src/model/protobuf/client/generated/data.pb.dart';
|
import 'package:twonly/src/model/protobuf/client/generated/data.pb.dart';
|
||||||
import 'package:twonly/src/services/api/utils.dart';
|
import 'package:twonly/src/services/api/utils.dart';
|
||||||
|
|
@ -99,7 +101,15 @@ class _ContactRow extends StatefulWidget {
|
||||||
class _ContactRowState extends State<_ContactRow> {
|
class _ContactRowState extends State<_ContactRow> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
Future<void> _onContactClick() async {
|
Future<void> _onContactClick(bool isAdded) async {
|
||||||
|
if (widget.contact.userId.toInt() == gUser.userId) {
|
||||||
|
await context.push(Routes.settingsProfile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isAdded) {
|
||||||
|
await context.push(Routes.profileContact(widget.contact.userId.toInt()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
|
|
@ -152,46 +162,48 @@ class _ContactRowState extends State<_ContactRow> {
|
||||||
widget.contact.userId.toInt() == gUser.userId;
|
widget.contact.userId.toInt() == gUser.userId;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: (widget.message.senderId == null || isAdded || _isLoading)
|
onTap: _isLoading ? null : () => _onContactClick(isAdded),
|
||||||
? null
|
child: ColoredBox(
|
||||||
: _onContactClick,
|
color: Colors.transparent,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const FaIcon(
|
const FaIcon(
|
||||||
FontAwesomeIcons.user,
|
FontAwesomeIcons.user,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Flexible(
|
|
||||||
child: BetterText(
|
|
||||||
text: widget.contact.displayName,
|
|
||||||
textColor: Colors.white,
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (widget.message.senderId != null && !isAdded) ...[
|
|
||||||
const Spacer(),
|
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
if (_isLoading)
|
Flexible(
|
||||||
const SizedBox(
|
child: BetterText(
|
||||||
width: 16,
|
text: widget.contact.displayName,
|
||||||
height: 16,
|
textColor: Colors.white,
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
const FaIcon(
|
|
||||||
FontAwesomeIcons.userPlus,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 16,
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
if (widget.message.senderId != null && !isAdded) ...[
|
||||||
|
const Spacer(),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
if (_isLoading)
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(Colors.white),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
const FaIcon(
|
||||||
|
FontAwesomeIcons.userPlus,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue