feat(ui): Also make the profile picture summon the profile page

This commit is contained in:
PapaTutuWawa 2022-12-21 23:41:18 +01:00
parent 7746784949
commit db4b69a24a

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:get_it/get_it.dart';
import 'package:moxxmpp/moxxmpp.dart';
import 'package:moxxyv2/i18n/strings.g.dart';
import 'package:moxxyv2/ui/bloc/conversation_bloc.dart';
@ -80,6 +79,16 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
return state != ChatState.inactive && state != ChatState.gone;
}
/// Summon the profile page of the currently open conversation
void _openProfile(BuildContext context, ConversationState state) {
context.read<profile.ProfileBloc>().add(
profile.ProfilePageRequestedEvent(
false,
conversation: state.conversation,
),
);
}
@override
Widget build(BuildContext context) {
return BlocBuilder<ConversationBloc, ConversationState>(
@ -96,10 +105,12 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
direction: Axis.horizontal,
children: [
const BackButton(),
Hero(
InkWell(
onTap: () => _openProfile(context, state),
child: Hero(
tag: 'conversation_profile_picture',
child: Material(
color: const Color.fromRGBO(0, 0, 0, 0),
color: Colors.transparent,
child: RebuildOnContactIntegrationChange(
builder: () => AvatarWrapper(
radius: 25,
@ -109,14 +120,10 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
),
),
),
),
Expanded(
child: InkWell(
onTap: () => GetIt.I.get<profile.ProfileBloc>().add(
profile.ProfilePageRequestedEvent(
false,
conversation: context.read<ConversationBloc>().state.conversation,
),
),
onTap: () => _openProfile(context, state),
child: Stack(
children: [
AnimatedPositioned(