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/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:get_it/get_it.dart';
import 'package:moxxmpp/moxxmpp.dart'; import 'package:moxxmpp/moxxmpp.dart';
import 'package:moxxyv2/i18n/strings.g.dart'; import 'package:moxxyv2/i18n/strings.g.dart';
import 'package:moxxyv2/ui/bloc/conversation_bloc.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; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<ConversationBloc, ConversationState>( return BlocBuilder<ConversationBloc, ConversationState>(
@ -96,10 +105,12 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
direction: Axis.horizontal, direction: Axis.horizontal,
children: [ children: [
const BackButton(), const BackButton(),
Hero( InkWell(
onTap: () => _openProfile(context, state),
child: Hero(
tag: 'conversation_profile_picture', tag: 'conversation_profile_picture',
child: Material( child: Material(
color: const Color.fromRGBO(0, 0, 0, 0), color: Colors.transparent,
child: RebuildOnContactIntegrationChange( child: RebuildOnContactIntegrationChange(
builder: () => AvatarWrapper( builder: () => AvatarWrapper(
radius: 25, radius: 25,
@ -109,14 +120,10 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
), ),
), ),
), ),
),
Expanded( Expanded(
child: InkWell( child: InkWell(
onTap: () => GetIt.I.get<profile.ProfileBloc>().add( onTap: () => _openProfile(context, state),
profile.ProfilePageRequestedEvent(
false,
conversation: context.read<ConversationBloc>().state.conversation,
),
),
child: Stack( child: Stack(
children: [ children: [
AnimatedPositioned( AnimatedPositioned(