SliverAppBar in ChatDetails

This commit is contained in:
Christian Pauly 2020-02-16 10:48:20 +01:00
parent 6bff85a858
commit 4ed9316552

View File

@ -158,295 +158,310 @@ class _ChatDetailsState extends State<ChatDetails> {
activeChat: widget.room.id, activeChat: widget.room.id,
), ),
secondScaffold: Scaffold( secondScaffold: Scaffold(
appBar: AppBar( body: NestedScrollView(
title: Text(widget.room.getLocalizedDisplayname(context)), headerSliverBuilder:
actions: <Widget>[ (BuildContext context, bool innerBoxIsScrolled) => <Widget>[
if (widget.room.canonicalAlias?.isNotEmpty ?? false) SliverAppBar(
IconButton( expandedHeight: 300.0,
icon: Icon(Icons.share), floating: true,
onPressed: () { pinned: true,
Clipboard.setData( actions: <Widget>[
ClipboardData(text: widget.room.canonicalAlias), if (widget.room.canonicalAlias?.isNotEmpty ?? false)
); IconButton(
Toast.show(I18n.of(context).copiedToClipboard, context, icon: Icon(Icons.share),
duration: 5); onPressed: () {
}, Clipboard.setData(
ClipboardData(text: widget.room.canonicalAlias),
);
Toast.show(I18n.of(context).copiedToClipboard, context,
duration: 5);
},
),
ChatSettingsPopupMenu(widget.room, false)
],
title: Text(widget.room.getLocalizedDisplayname(context),
style: TextStyle(color: Colors.black)),
backgroundColor: Theme.of(context).appBarTheme.color,
flexibleSpace: FlexibleSpaceBar(
background: ContentBanner(widget.room.avatar,
onEdit: widget.room.canSendEvent("m.room.avatar") && !kIsWeb
? () => setAvatarAction(context)
: null),
), ),
ChatSettingsPopupMenu(widget.room, false) ),
], ],
), body: ListView.builder(
body: ListView.builder( itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0),
itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0), itemBuilder: (BuildContext context, int i) => i == 0
itemBuilder: (BuildContext context, int i) => i == 0 ? Column(
? Column( crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[
children: <Widget>[ topicEditMode
ContentBanner(widget.room.avatar, ? ListTile(
onEdit: title: TextField(
widget.room.canSendEvent("m.room.avatar") && !kIsWeb textInputAction: TextInputAction.done,
? () => setAvatarAction(context) onSubmitted: (s) => setTopicAction(context, s),
: null), autofocus: true,
Divider(height: 1), minLines: 1,
topicEditMode maxLines: 4,
? ListTile( decoration: InputDecoration(
title: TextField( border: InputBorder.none,
textInputAction: TextInputAction.done, labelText:
onSubmitted: (s) => setTopicAction(context, s), "${I18n.of(context).groupDescription}:",
autofocus: true, labelStyle: TextStyle(
minLines: 1, color: Theme.of(context).primaryColor,
maxLines: 4, fontWeight: FontWeight.bold),
decoration: InputDecoration( hintText: widget.room.topic ??
border: InputBorder.none, I18n.of(context).setGroupDescription,
labelText: ),
"${I18n.of(context).groupDescription}:",
labelStyle: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold),
hintText: widget.room.topic ??
I18n.of(context).setGroupDescription,
), ),
), )
) : ListTile(
: ListTile( leading: widget.room.canSendEvent("m.room.topic")
leading: widget.room.canSendEvent("m.room.topic") ? CircleAvatar(
? CircleAvatar( backgroundColor: Colors.white,
backgroundColor: Colors.white, foregroundColor: Colors.grey,
foregroundColor: Colors.grey, child: Icon(Icons.edit),
child: Icon(Icons.edit), )
) : null,
: null, title: Text(
title: Text("${I18n.of(context).groupDescription}:", "${I18n.of(context).groupDescription}:",
style: TextStyle( style: TextStyle(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
subtitle: LinkText( subtitle: LinkText(
text: widget.room.topic?.isEmpty ?? true text: widget.room.topic?.isEmpty ?? true
? I18n.of(context).addGroupDescription ? I18n.of(context).addGroupDescription
: widget.room.topic, : widget.room.topic,
linkStyle: TextStyle(color: Colors.blueAccent), linkStyle: TextStyle(color: Colors.blueAccent),
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.black, color: Colors.black,
),
), ),
onTap: widget.room.canSendEvent("m.room.topic")
? () => setState(() => topicEditMode = true)
: null,
), ),
onTap: widget.room.canSendEvent("m.room.topic") Divider(thickness: 8),
? () => setState(() => topicEditMode = true)
: null,
),
Divider(thickness: 8),
ListTile(
title: Text(
I18n.of(context).settings,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
if (widget.room.canSendEvent("m.room.name"))
ListTile( ListTile(
leading: CircleAvatar( title: Text(
backgroundColor: Colors.white, I18n.of(context).settings,
foregroundColor: Colors.grey, style: TextStyle(
child: Icon(Icons.people), color: Theme.of(context).primaryColor,
), fontWeight: FontWeight.bold,
title: TextField(
textInputAction: TextInputAction.done,
onSubmitted: (s) => setDisplaynameAction(context, s),
decoration: InputDecoration(
border: InputBorder.none,
labelText: I18n.of(context).changeTheNameOfTheGroup,
labelStyle: TextStyle(color: Colors.black),
hintText:
widget.room.getLocalizedDisplayname(context),
), ),
), ),
), ),
if (widget.room.canSendEvent("m.room.canonical_alias") && if (widget.room.canSendEvent("m.room.name"))
widget.room.joinRules == JoinRules.public) ListTile(
ListTile( leading: CircleAvatar(
leading: CircleAvatar(
backgroundColor: Colors.white,
foregroundColor: Colors.grey,
child: Icon(Icons.link),
),
title: TextField(
textInputAction: TextInputAction.done,
onSubmitted: (s) =>
setCanonicalAliasAction(context, s),
decoration: InputDecoration(
border: InputBorder.none,
labelText: I18n.of(context).setInvitationLink,
labelStyle: TextStyle(color: Colors.black),
hintText: widget.room.canonicalAlias
?.replaceAll("#", "") ??
I18n.of(context).alias,
prefixText: "#",
suffixText: widget.room.client.userID.domain,
),
),
),
PopupMenuButton(
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.public)), child: Icon(Icons.people),
title: ),
Text(I18n.of(context).whoIsAllowedToJoinThisGroup), title: TextField(
subtitle: Text( textInputAction: TextInputAction.done,
widget.room.joinRules.getLocalizedString(context), onSubmitted: (s) =>
setDisplaynameAction(context, s),
decoration: InputDecoration(
border: InputBorder.none,
labelText:
I18n.of(context).changeTheNameOfTheGroup,
labelStyle: TextStyle(color: Colors.black),
hintText:
widget.room.getLocalizedDisplayname(context),
),
),
), ),
), if (widget.room.canSendEvent("m.room.canonical_alias") &&
onSelected: (JoinRules joinRule) => widget.room.joinRules == JoinRules.public)
Matrix.of(context).tryRequestWithLoadingDialog( ListTile(
widget.room.setJoinRules(joinRule), leading: CircleAvatar(
), backgroundColor: Colors.white,
itemBuilder: (BuildContext context) => foregroundColor: Colors.grey,
<PopupMenuEntry<JoinRules>>[ child: Icon(Icons.link),
if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>(
value: JoinRules.public,
child: Text(
JoinRules.public.getLocalizedString(context)),
), ),
if (widget.room.canChangeJoinRules) title: TextField(
PopupMenuItem<JoinRules>( textInputAction: TextInputAction.done,
value: JoinRules.invite, onSubmitted: (s) =>
child: Text( setCanonicalAliasAction(context, s),
JoinRules.invite.getLocalizedString(context)), decoration: InputDecoration(
border: InputBorder.none,
labelText: I18n.of(context).setInvitationLink,
labelStyle: TextStyle(color: Colors.black),
hintText: widget.room.canonicalAlias
?.replaceAll("#", "") ??
I18n.of(context).alias,
prefixText: "#",
suffixText: widget.room.client.userID.domain,
),
), ),
],
),
PopupMenuButton(
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.white,
foregroundColor: Colors.grey,
child: Icon(Icons.visibility),
), ),
title: PopupMenuButton(
Text(I18n.of(context).visibilityOfTheChatHistory), child: ListTile(
subtitle: Text( leading: CircleAvatar(
widget.room.historyVisibility backgroundColor: Colors.white,
.getLocalizedString(context), foregroundColor: Colors.grey,
child: Icon(Icons.public)),
title: Text(
I18n.of(context).whoIsAllowedToJoinThisGroup),
subtitle: Text(
widget.room.joinRules.getLocalizedString(context),
),
), ),
onSelected: (JoinRules joinRule) =>
Matrix.of(context).tryRequestWithLoadingDialog(
widget.room.setJoinRules(joinRule),
),
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<JoinRules>>[
if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>(
value: JoinRules.public,
child: Text(
JoinRules.public.getLocalizedString(context)),
),
if (widget.room.canChangeJoinRules)
PopupMenuItem<JoinRules>(
value: JoinRules.invite,
child: Text(
JoinRules.invite.getLocalizedString(context)),
),
],
), ),
onSelected: (HistoryVisibility historyVisibility) =>
Matrix.of(context).tryRequestWithLoadingDialog(
widget.room.setHistoryVisibility(historyVisibility),
),
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<HistoryVisibility>>[
if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.invited,
child: Text(HistoryVisibility.invited
.getLocalizedString(context)),
),
if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.joined,
child: Text(HistoryVisibility.joined
.getLocalizedString(context)),
),
if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.shared,
child: Text(HistoryVisibility.shared
.getLocalizedString(context)),
),
if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.world_readable,
child: Text(HistoryVisibility.world_readable
.getLocalizedString(context)),
),
],
),
if (widget.room.joinRules == JoinRules.public)
PopupMenuButton( PopupMenuButton(
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.info_outline), child: Icon(Icons.visibility),
), ),
title: Text(I18n.of(context).areGuestsAllowedToJoin), title:
Text(I18n.of(context).visibilityOfTheChatHistory),
subtitle: Text( subtitle: Text(
widget.room.guestAccess.getLocalizedString(context), widget.room.historyVisibility
.getLocalizedString(context),
), ),
), ),
onSelected: (GuestAccess guestAccess) => onSelected: (HistoryVisibility historyVisibility) =>
Matrix.of(context).tryRequestWithLoadingDialog( Matrix.of(context).tryRequestWithLoadingDialog(
widget.room.setGuestAccess(guestAccess), widget.room.setHistoryVisibility(historyVisibility),
), ),
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
<PopupMenuEntry<GuestAccess>>[ <PopupMenuEntry<HistoryVisibility>>[
if (widget.room.canChangeGuestAccess) if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<GuestAccess>( PopupMenuItem<HistoryVisibility>(
value: GuestAccess.can_join, value: HistoryVisibility.invited,
child: Text( child: Text(HistoryVisibility.invited
GuestAccess.can_join .getLocalizedString(context)),
.getLocalizedString(context),
),
), ),
if (widget.room.canChangeGuestAccess) if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<GuestAccess>( PopupMenuItem<HistoryVisibility>(
value: GuestAccess.forbidden, value: HistoryVisibility.joined,
child: Text( child: Text(HistoryVisibility.joined
GuestAccess.forbidden .getLocalizedString(context)),
.getLocalizedString(context), ),
), if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.shared,
child: Text(HistoryVisibility.shared
.getLocalizedString(context)),
),
if (widget.room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.world_readable,
child: Text(HistoryVisibility.world_readable
.getLocalizedString(context)),
), ),
], ],
), ),
Divider(thickness: 8), if (widget.room.joinRules == JoinRules.public)
ListTile( PopupMenuButton(
title: Text( child: ListTile(
actualMembersCount > 1
? I18n.of(context).countParticipants(
actualMembersCount.toString())
: I18n.of(context).emptyChat,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
Divider(height: 1),
widget.room.canInvite
? ListTile(
title: Text(I18n.of(context).inviteContact),
leading: CircleAvatar( leading: CircleAvatar(
child: Icon(Icons.add), backgroundColor: Colors.white,
backgroundColor: Theme.of(context).primaryColor, foregroundColor: Colors.grey,
foregroundColor: Colors.white, child: Icon(Icons.info_outline),
), ),
onTap: () => Navigator.of(context).push( title:
AppRoute.defaultRoute( Text(I18n.of(context).areGuestsAllowedToJoin),
context, subtitle: Text(
InvitationSelection(widget.room), widget.room.guestAccess
.getLocalizedString(context),
),
),
onSelected: (GuestAccess guestAccess) =>
Matrix.of(context).tryRequestWithLoadingDialog(
widget.room.setGuestAccess(guestAccess),
),
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<GuestAccess>>[
if (widget.room.canChangeGuestAccess)
PopupMenuItem<GuestAccess>(
value: GuestAccess.can_join,
child: Text(
GuestAccess.can_join
.getLocalizedString(context),
),
), ),
), if (widget.room.canChangeGuestAccess)
) PopupMenuItem<GuestAccess>(
: Container(), value: GuestAccess.forbidden,
], child: Text(
) GuestAccess.forbidden
: i < members.length + 1 .getLocalizedString(context),
? ParticipantListItem(members[i - 1]) ),
: ListTile( ),
title: Text(I18n.of(context).loadCountMoreParticipants( ],
(actualMembersCount - members.length).toString())), ),
leading: CircleAvatar( Divider(thickness: 8),
backgroundColor: Colors.white, ListTile(
child: Icon( title: Text(
Icons.refresh, actualMembersCount > 1
color: Colors.grey, ? I18n.of(context).countParticipants(
actualMembersCount.toString())
: I18n.of(context).emptyChat,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
), ),
), ),
onTap: () => requestMoreMembersAction(context), Divider(height: 1),
), widget.room.canInvite
? ListTile(
title: Text(I18n.of(context).inviteContact),
leading: CircleAvatar(
child: Icon(Icons.add),
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
),
onTap: () => Navigator.of(context).push(
AppRoute.defaultRoute(
context,
InvitationSelection(widget.room),
),
),
)
: Container(),
],
)
: i < members.length + 1
? ParticipantListItem(members[i - 1])
: ListTile(
title: Text(I18n.of(context).loadCountMoreParticipants(
(actualMembersCount - members.length).toString())),
leading: CircleAvatar(
backgroundColor: Colors.white,
child: Icon(
Icons.refresh,
color: Colors.grey,
),
),
onTap: () => requestMoreMembersAction(context),
),
),
), ),
), ),
); );