-
Notifications
You must be signed in to change notification settings - Fork 350
share: Support switching accounts #1883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
5dbcb34
52b3bbb
ab52325
96e87ff
415b1e9
f3e6429
765d19e
6b9694c
01bc09d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,14 +11,15 @@ import '../log.dart'; | |||||||||||||||||
| import '../model/binding.dart'; | ||||||||||||||||||
| import '../model/narrow.dart'; | ||||||||||||||||||
| import 'app.dart'; | ||||||||||||||||||
| import 'color.dart'; | ||||||||||||||||||
| import 'compose_box.dart'; | ||||||||||||||||||
| import 'content.dart'; | ||||||||||||||||||
| import 'dialog.dart'; | ||||||||||||||||||
| import 'icons.dart'; | ||||||||||||||||||
| import 'message_list.dart'; | ||||||||||||||||||
| import 'page.dart'; | ||||||||||||||||||
| import 'recent_dm_conversations.dart'; | ||||||||||||||||||
| import 'store.dart'; | ||||||||||||||||||
| import 'subscription_list.dart'; | ||||||||||||||||||
| import 'text.dart'; | ||||||||||||||||||
| import 'theme.dart'; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Responds to receiving shared content from other apps. | ||||||||||||||||||
|
|
@@ -99,16 +100,16 @@ class ShareService { | |||||||||||||||||
| mimeType: mimeType); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| unawaited(navigator.push( | ||||||||||||||||||
| SharePage.buildRoute( | ||||||||||||||||||
| accountId: accountId, | ||||||||||||||||||
| sharedFiles: sharedFiles, | ||||||||||||||||||
| sharedText: intentSendEvent.extraText))); | ||||||||||||||||||
| ShareDialog.show( | ||||||||||||||||||
| pageContext: context, | ||||||||||||||||||
| initialAccountId: accountId, | ||||||||||||||||||
| sharedFiles: sharedFiles, | ||||||||||||||||||
| sharedText: intentSendEvent.extraText); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| class SharePage extends StatelessWidget { | ||||||||||||||||||
| const SharePage({ | ||||||||||||||||||
| class ShareDialog extends StatelessWidget { | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's link to the Figma in a dartdoc, to help inform future changes to this. |
||||||||||||||||||
| const ShareDialog({ | ||||||||||||||||||
| super.key, | ||||||||||||||||||
| required this.sharedFiles, | ||||||||||||||||||
| required this.sharedText, | ||||||||||||||||||
|
|
@@ -117,16 +118,27 @@ class SharePage extends StatelessWidget { | |||||||||||||||||
| final Iterable<FileToUpload>? sharedFiles; | ||||||||||||||||||
| final String? sharedText; | ||||||||||||||||||
|
|
||||||||||||||||||
| static AccountRoute<void> buildRoute({ | ||||||||||||||||||
| required int accountId, | ||||||||||||||||||
| static void show({ | ||||||||||||||||||
| required BuildContext pageContext, | ||||||||||||||||||
| required int initialAccountId, | ||||||||||||||||||
| required Iterable<FileToUpload>? sharedFiles, | ||||||||||||||||||
| required String? sharedText, | ||||||||||||||||||
| }) { | ||||||||||||||||||
| return MaterialAccountWidgetRoute( | ||||||||||||||||||
| accountId: accountId, | ||||||||||||||||||
| page: SharePage( | ||||||||||||||||||
| sharedFiles: sharedFiles, | ||||||||||||||||||
| sharedText: sharedText)); | ||||||||||||||||||
| }) async { | ||||||||||||||||||
| unawaited(showModalBottomSheet<void>( | ||||||||||||||||||
| context: pageContext, | ||||||||||||||||||
| // Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect | ||||||||||||||||||
| // on my iPhone 13 Pro but is marked as "much slower": | ||||||||||||||||||
| // https://api.flutter.dev/flutter/dart-ui/Clip.html | ||||||||||||||||||
| clipBehavior: Clip.antiAlias, | ||||||||||||||||||
| useSafeArea: true, | ||||||||||||||||||
| isScrollControlled: true, | ||||||||||||||||||
| builder: (_) { | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| return PerAccountStoreWidget( | ||||||||||||||||||
| accountId: initialAccountId, | ||||||||||||||||||
| child: ShareDialog( | ||||||||||||||||||
| sharedFiles: sharedFiles, | ||||||||||||||||||
| sharedText: sharedText)); | ||||||||||||||||||
| })); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| void _handleNarrowSelect(BuildContext context, Narrow narrow) { | ||||||||||||||||||
|
|
@@ -171,28 +183,74 @@ class SharePage extends StatelessWidget { | |||||||||||||||||
|
|
||||||||||||||||||
| @override | ||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||
| final zulipLocalizations = ZulipLocalizations.of(context); | ||||||||||||||||||
| final store = PerAccountStoreWidget.of(context); | ||||||||||||||||||
| final designVariables = DesignVariables.of(context); | ||||||||||||||||||
| final zulipLocalizations = ZulipLocalizations.of(context); | ||||||||||||||||||
|
|
||||||||||||||||||
| // We should already have the `store.realmIcon` after the | ||||||||||||||||||
| // PerAccountStore has completed loading, hence the `!` here. | ||||||||||||||||||
| final realmIconUrl = store.realmUrl.resolveUri(store.realmIcon!); | ||||||||||||||||||
|
Comment on lines
+195
to
+197
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a |
||||||||||||||||||
|
|
||||||||||||||||||
| final labelStyle = TextStyle( | ||||||||||||||||||
| fontSize: 18, | ||||||||||||||||||
| height: 24 / 18, | ||||||||||||||||||
| letterSpacing: 0, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't |
||||||||||||||||||
| ).merge(weightVariableTextStyle(context, wght: 500)); | ||||||||||||||||||
|
|
||||||||||||||||||
| Widget mkLabel(String text) { | ||||||||||||||||||
| return Text( | ||||||||||||||||||
| text, | ||||||||||||||||||
| style: labelStyle, | ||||||||||||||||||
| overflow: TextOverflow.ellipsis, | ||||||||||||||||||
| maxLines: 1); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| return DefaultTabController( | ||||||||||||||||||
| length: 2, | ||||||||||||||||||
| child: Scaffold( | ||||||||||||||||||
| appBar: AppBar( | ||||||||||||||||||
| title: Text(zulipLocalizations.sharePageTitle), | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This UI string isn't used anymore. That feels kind of weird to me; now this UI doesn't have an explicit label saying what its purpose is. Shrug and remove, I guess, because we're being consistent with the Figma?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. …Ah, I see it's removed in a different commit. Let's remove it in the commit that removes its last usage. |
||||||||||||||||||
| bottom: TabBar( | ||||||||||||||||||
| indicatorColor: designVariables.icon, | ||||||||||||||||||
| labelColor: designVariables.foreground, | ||||||||||||||||||
| unselectedLabelColor: designVariables.foreground.withFadedAlpha(0.7), | ||||||||||||||||||
| child: Column(children: [ | ||||||||||||||||||
| Row(children: [ | ||||||||||||||||||
| SizedBox.square( | ||||||||||||||||||
| dimension: 42, | ||||||||||||||||||
| child: Padding( | ||||||||||||||||||
| padding: const EdgeInsets.all(7), | ||||||||||||||||||
| child: RealmContentNetworkImage(realmIconUrl))), | ||||||||||||||||||
|
||||||||||||||||||
| Expanded(child: TabBar( | ||||||||||||||||||
| labelStyle: labelStyle, | ||||||||||||||||||
| labelColor: designVariables.iconSelected, | ||||||||||||||||||
| unselectedLabelColor: designVariables.icon, | ||||||||||||||||||
| indicatorWeight: 0, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, two things stand out to me in the dartdoc of
What happens if we don't pass |
||||||||||||||||||
| indicator: BoxDecoration(border: Border( | ||||||||||||||||||
| bottom: BorderSide( | ||||||||||||||||||
| color: designVariables.iconSelected, | ||||||||||||||||||
| width: 4.0))), | ||||||||||||||||||
|
Comment on lines
+241
to
+244
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe:
Suggested change
; is that equivalent? |
||||||||||||||||||
| indicatorSize: TabBarIndicatorSize.label, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading the dartdoc for /// The tab's bounds are only as wide as the (centered) tab widget itself.
///
/// This value is used to align the tab's label, typically a [Tab]
/// widget's text or icon, with the selected tab indicator.
label,The other enum value looks like a closer match to the Figma: /// The tab indicator's bounds are as wide as the space occupied by the tab
/// in the tab bar: from the right edge of the previous tab to the left edge
/// of the next tab.
tab,The "indicator" in the Figma is 171.5px wide, whether it's on the tab with the longer "Channels" label or the tab with the shorter "DMs" label:
If |
||||||||||||||||||
| dividerHeight: 0, | ||||||||||||||||||
| splashFactory: NoSplash.splashFactory, | ||||||||||||||||||
| tabs: [ | ||||||||||||||||||
| Tab(text: zulipLocalizations.channelsPageTitle), | ||||||||||||||||||
| Tab(text: zulipLocalizations.recentDmConversationsPageTitle), | ||||||||||||||||||
| SizedBox( | ||||||||||||||||||
| height: 42, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this UI respond to the device text-size setting; could you do some quick manual tests for that? Some suggestions that might help make it nicer, depending on your testing:
|
||||||||||||||||||
| child: Row( | ||||||||||||||||||
| mainAxisAlignment: MainAxisAlignment.center, | ||||||||||||||||||
| spacing: 4, | ||||||||||||||||||
| children: [ | ||||||||||||||||||
| Icon(size: 24, ZulipIcons.hash_italic), | ||||||||||||||||||
| Flexible(child: mkLabel(zulipLocalizations.channelsPageTitle)), | ||||||||||||||||||
| ])), | ||||||||||||||||||
| SizedBox( | ||||||||||||||||||
| height: 42, | ||||||||||||||||||
| child: Row( | ||||||||||||||||||
| mainAxisAlignment: MainAxisAlignment.center, | ||||||||||||||||||
| spacing: 4, | ||||||||||||||||||
| children: [ | ||||||||||||||||||
| Icon(size: 24, ZulipIcons.two_person), | ||||||||||||||||||
| Flexible(child: mkLabel(zulipLocalizations.recentDmConversationsPageTitle)), | ||||||||||||||||||
| ])), | ||||||||||||||||||
|
Comment on lines
+258
to
+266
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tab-bar code looks like a good candidate to be pulled out to a helper method or a new private widget, so we don't have to repeat its details for each tab. |
||||||||||||||||||
| ])), | ||||||||||||||||||
| body: TabBarView(children: [ | ||||||||||||||||||
| ]), | ||||||||||||||||||
| Expanded(child: TabBarView(children: [ | ||||||||||||||||||
| SubscriptionListPageBody( | ||||||||||||||||||
| showTopicListButtonInActionSheet: false, | ||||||||||||||||||
| hideChannelsIfUserCantSendMessage: true, | ||||||||||||||||||
| allowGoToAllChannels: false, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removal looks unintentional. |
||||||||||||||||||
| onChannelSelect: (narrow) => _handleNarrowSelect(context, narrow), | ||||||||||||||||||
| // TODO(#412) add onTopicSelect, Currently when user lands on the | ||||||||||||||||||
| // channel feed page from subscription list page and they tap | ||||||||||||||||||
|
|
@@ -204,6 +262,7 @@ class SharePage extends StatelessWidget { | |||||||||||||||||
| RecentDmConversationsPageBody( | ||||||||||||||||||
| hideDmsIfUserCantPost: true, | ||||||||||||||||||
| onDmSelect: (narrow) => _handleNarrowSelect(context, narrow)), | ||||||||||||||||||
| ]))); | ||||||||||||||||||
| ])), | ||||||||||||||||||
| ])); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||



There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit breaks the "New DM" button in the "Direct messages" tab, because a
PageRootancestor is no longer found when the button is tapped: