-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1369: Support Pinned list actions on mobile
- Loading branch information
Julian KOUNE
committed
Feb 7, 2024
1 parent
d0e6ad7
commit d5ed02d
Showing
8 changed files
with
192 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
lib/pages/chat/chat_pinned_events/pinned_messages_action_button_mobile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages_style.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
class PinnedMessagesActionButton extends StatelessWidget { | ||
const PinnedMessagesActionButton({ | ||
super.key, | ||
this.onTap, | ||
}); | ||
|
||
final VoidCallback? onTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
IconButton( | ||
iconSize: PinnedMessagesStyle.unpinButtonSizeMobile, | ||
padding: EdgeInsets.zero, | ||
constraints: const BoxConstraints(), | ||
onPressed: onTap, | ||
icon: PinnedMessagesStyle.unpinIcon( | ||
size: PinnedMessagesStyle.unpinButtonSizeMobile, | ||
), | ||
), | ||
const SizedBox(height: PinnedMessagesStyle.menuActionBtnGapMobile), | ||
Text( | ||
L10n.of(context)!.unpin, | ||
style: Theme.of(context).textTheme.labelMedium?.copyWith( | ||
color: Theme.of(context).colorScheme.primary, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
lib/pages/chat/chat_pinned_events/pinned_messages_menu_mobile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages.dart'; | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages_action_button_mobile.dart'; | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages_style.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
class PinnedMessagesMenuMobile extends StatelessWidget { | ||
const PinnedMessagesMenuMobile({ | ||
super.key, | ||
required this.controller, | ||
}); | ||
|
||
final PinnedMessagesController controller; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
height: PinnedMessagesStyle.menuHeightMobile, | ||
child: ValueListenableBuilder<List<Event>>( | ||
valueListenable: controller.selectedEvents, | ||
builder: (context, selectedEvents, child) { | ||
if (selectedEvents.isEmpty) return child!; | ||
|
||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
PinnedMessagesActionButton( | ||
onTap: controller.unpinSelectedEvents, | ||
), | ||
], | ||
); | ||
}, | ||
child: Center( | ||
child: TextButton.icon( | ||
onPressed: () => controller.unpinAll(), | ||
icon: PinnedMessagesStyle.unpinIcon(), | ||
label: Text( | ||
L10n.of(context)!.unpinAllMessages, | ||
style: Theme.of(context).textTheme.labelLarge?.copyWith( | ||
color: Theme.of(context).colorScheme.primary, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
lib/pages/chat/chat_pinned_events/pinned_messages_menu_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages.dart'; | ||
import 'package:fluffychat/pages/chat/chat_pinned_events/pinned_messages_style.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
class PinnedMessagesMenuWeb extends StatelessWidget { | ||
const PinnedMessagesMenuWeb({ | ||
super.key, | ||
required this.controller, | ||
}); | ||
|
||
final PinnedMessagesController controller; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ValueListenableBuilder<List<Event>>( | ||
valueListenable: controller.selectedEvents, | ||
builder: (context, selectedEvents, child) { | ||
if (selectedEvents.isEmpty) return child!; | ||
|
||
return Padding( | ||
padding: PinnedMessagesStyle.actionBarParentPaddingWeb, | ||
child: Material( | ||
elevation: 1, | ||
borderRadius: BorderRadius.circular( | ||
PinnedMessagesStyle.actionBarBorderRadiusWeb, | ||
), | ||
child: Container( | ||
height: PinnedMessagesStyle.unpinButtonHeightWeb, | ||
width: PinnedMessagesStyle.unpinButtonWidthWeb, | ||
padding: PinnedMessagesStyle.actionBarPaddingWeb, | ||
decoration: BoxDecoration( | ||
color: Theme.of(context).colorScheme.surfaceVariant, | ||
borderRadius: BorderRadius.circular( | ||
PinnedMessagesStyle.actionBarBorderRadiusWeb, | ||
), | ||
), | ||
child: Row( | ||
children: [ | ||
IconButton( | ||
onPressed: controller.closeSelectionMode, | ||
icon: Icon( | ||
Icons.close, | ||
color: Theme.of(context).colorScheme.onSurfaceVariant, | ||
size: PinnedMessagesStyle.closeSelectionIconSizeWeb, | ||
), | ||
), | ||
Text( | ||
L10n.of(context)!.messageSelected(selectedEvents.length), | ||
style: Theme.of(context).textTheme.labelLarge?.copyWith( | ||
color: Theme.of(context).colorScheme.onSurfaceVariant, | ||
), | ||
), | ||
const Spacer(), | ||
TextButton.icon( | ||
onPressed: () => controller.unpinSelectedEvents(), | ||
icon: PinnedMessagesStyle.unpinIcon(), | ||
label: Text( | ||
L10n.of(context)!.unpin, | ||
style: Theme.of(context).textTheme.labelLarge?.copyWith( | ||
color: Theme.of(context).colorScheme.primary, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
child: const SizedBox.shrink(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters