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';
@ -79,6 +78,16 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
bool _isChatStateVisible(ChatState state) { bool _isChatStateVisible(ChatState state) {
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) {
@ -96,27 +105,25 @@ class ConversationTopbar extends StatelessWidget implements PreferredSizeWidget
direction: Axis.horizontal, direction: Axis.horizontal,
children: [ children: [
const BackButton(), const BackButton(),
Hero( InkWell(
tag: 'conversation_profile_picture', onTap: () => _openProfile(context, state),
child: Material( child: Hero(
color: const Color.fromRGBO(0, 0, 0, 0), tag: 'conversation_profile_picture',
child: RebuildOnContactIntegrationChange( child: Material(
builder: () => AvatarWrapper( color: Colors.transparent,
radius: 25, child: RebuildOnContactIntegrationChange(
avatarUrl: state.conversation!.avatarPathWithOptionalContact, builder: () => AvatarWrapper(
altText: state.conversation!.titleWithOptionalContact, radius: 25,
avatarUrl: state.conversation!.avatarPathWithOptionalContact,
altText: state.conversation!.titleWithOptionalContact,
),
), ),
), ),
), ),
), ),
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(