mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 12:16: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:flutter/material.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/src/constants/routes.keys.dart';
|
||||
import 'package:twonly/src/database/twonly.db.dart';
|
||||
import 'package:twonly/src/model/protobuf/client/generated/data.pb.dart';
|
||||
import 'package:twonly/src/services/api/utils.dart';
|
||||
|
|
@ -99,7 +101,15 @@ class _ContactRow extends StatefulWidget {
|
|||
class _ContactRowState extends State<_ContactRow> {
|
||||
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(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
|
@ -152,9 +162,9 @@ class _ContactRowState extends State<_ContactRow> {
|
|||
widget.contact.userId.toInt() == gUser.userId;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: (widget.message.senderId == null || isAdded || _isLoading)
|
||||
? null
|
||||
: _onContactClick,
|
||||
onTap: _isLoading ? null : () => _onContactClick(isAdded),
|
||||
child: ColoredBox(
|
||||
color: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
child: Row(
|
||||
|
|
@ -181,7 +191,8 @@ class _ContactRowState extends State<_ContactRow> {
|
|||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
),
|
||||
)
|
||||
else
|
||||
|
|
@ -194,6 +205,7 @@ class _ContactRowState extends State<_ContactRow> {
|
|||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue