Skip to content

Commit 6b9694c

Browse files
1 parent 765d19e commit 6b9694c

File tree

1 file changed

+89
-30
lines changed

1 file changed

+89
-30
lines changed

lib/widgets/share.dart

Lines changed: 89 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import '../log.dart';
1111
import '../model/binding.dart';
1212
import '../model/narrow.dart';
1313
import 'app.dart';
14-
import 'color.dart';
1514
import 'compose_box.dart';
15+
import 'content.dart';
1616
import 'dialog.dart';
17+
import 'icons.dart';
1718
import 'message_list.dart';
18-
import 'page.dart';
1919
import 'recent_dm_conversations.dart';
2020
import 'store.dart';
2121
import 'subscription_list.dart';
22+
import 'text.dart';
2223
import 'theme.dart';
2324

2425
// Responds to receiving shared content from other apps.
@@ -99,16 +100,16 @@ class ShareService {
99100
mimeType: mimeType);
100101
});
101102

102-
unawaited(navigator.push(
103-
SharePage.buildRoute(
104-
accountId: accountId,
105-
sharedFiles: sharedFiles,
106-
sharedText: intentSendEvent.extraText)));
103+
ShareDialog.show(
104+
pageContext: context,
105+
initialAccountId: accountId,
106+
sharedFiles: sharedFiles,
107+
sharedText: intentSendEvent.extraText);
107108
}
108109
}
109110

110-
class SharePage extends StatelessWidget {
111-
const SharePage({
111+
class ShareDialog extends StatelessWidget {
112+
const ShareDialog({
112113
super.key,
113114
required this.sharedFiles,
114115
required this.sharedText,
@@ -117,16 +118,27 @@ class SharePage extends StatelessWidget {
117118
final Iterable<FileToUpload>? sharedFiles;
118119
final String? sharedText;
119120

120-
static AccountRoute<void> buildRoute({
121-
required int accountId,
121+
static void show({
122+
required BuildContext pageContext,
123+
required int initialAccountId,
122124
required Iterable<FileToUpload>? sharedFiles,
123125
required String? sharedText,
124-
}) {
125-
return MaterialAccountWidgetRoute(
126-
accountId: accountId,
127-
page: SharePage(
128-
sharedFiles: sharedFiles,
129-
sharedText: sharedText));
126+
}) async {
127+
unawaited(showModalBottomSheet<void>(
128+
context: pageContext,
129+
// Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect
130+
// on my iPhone 13 Pro but is marked as "much slower":
131+
// https://api.flutter.dev/flutter/dart-ui/Clip.html
132+
clipBehavior: Clip.antiAlias,
133+
useSafeArea: true,
134+
isScrollControlled: true,
135+
builder: (_) {
136+
return PerAccountStoreWidget(
137+
accountId: initialAccountId,
138+
child: ShareDialog(
139+
sharedFiles: sharedFiles,
140+
sharedText: sharedText));
141+
}));
130142
}
131143

132144
void _handleNarrowSelect(BuildContext context, Narrow narrow) {
@@ -171,28 +183,74 @@ class SharePage extends StatelessWidget {
171183

172184
@override
173185
Widget build(BuildContext context) {
174-
final zulipLocalizations = ZulipLocalizations.of(context);
186+
final store = PerAccountStoreWidget.of(context);
175187
final designVariables = DesignVariables.of(context);
188+
final zulipLocalizations = ZulipLocalizations.of(context);
189+
190+
// We should already have the `store.realmIcon` after the
191+
// PerAccountStore has completed loading, hence the `!` here.
192+
final realmIconUrl = store.realmUrl.resolveUri(store.realmIcon!);
193+
194+
final labelStyle = TextStyle(
195+
fontSize: 18,
196+
height: 24 / 18,
197+
letterSpacing: 0,
198+
).merge(weightVariableTextStyle(context, wght: 500));
199+
200+
Widget mkLabel(String text) {
201+
return Text(
202+
text,
203+
style: labelStyle,
204+
overflow: TextOverflow.ellipsis,
205+
maxLines: 1);
206+
}
176207

177208
return DefaultTabController(
178209
length: 2,
179-
child: Scaffold(
180-
appBar: AppBar(
181-
title: Text(zulipLocalizations.sharePageTitle),
182-
bottom: TabBar(
183-
indicatorColor: designVariables.icon,
184-
labelColor: designVariables.foreground,
185-
unselectedLabelColor: designVariables.foreground.withFadedAlpha(0.7),
210+
child: Column(children: [
211+
Row(children: [
212+
SizedBox.square(
213+
dimension: 42,
214+
child: Padding(
215+
padding: const EdgeInsets.all(7),
216+
child: RealmContentNetworkImage(realmIconUrl))),
217+
Expanded(child: TabBar(
218+
labelStyle: labelStyle,
219+
labelColor: designVariables.iconSelected,
220+
unselectedLabelColor: designVariables.icon,
221+
indicatorWeight: 0,
222+
indicator: BoxDecoration(border: Border(
223+
bottom: BorderSide(
224+
color: designVariables.iconSelected,
225+
width: 4.0))),
226+
indicatorSize: TabBarIndicatorSize.label,
227+
dividerHeight: 0,
186228
splashFactory: NoSplash.splashFactory,
187229
tabs: [
188-
Tab(text: zulipLocalizations.channelsPageTitle),
189-
Tab(text: zulipLocalizations.recentDmConversationsPageTitle),
230+
SizedBox(
231+
height: 42,
232+
child: Row(
233+
mainAxisAlignment: MainAxisAlignment.center,
234+
spacing: 4,
235+
children: [
236+
Icon(size: 24, ZulipIcons.hash_italic),
237+
Flexible(child: mkLabel(zulipLocalizations.channelsPageTitle)),
238+
])),
239+
SizedBox(
240+
height: 42,
241+
child: Row(
242+
mainAxisAlignment: MainAxisAlignment.center,
243+
spacing: 4,
244+
children: [
245+
Icon(size: 24, ZulipIcons.two_person),
246+
Flexible(child: mkLabel(zulipLocalizations.recentDmConversationsPageTitle)),
247+
])),
190248
])),
191-
body: TabBarView(children: [
249+
]),
250+
Expanded(child: TabBarView(children: [
192251
SubscriptionListPageBody(
193252
showTopicListButtonInActionSheet: false,
194253
hideChannelsIfUserCantSendMessage: true,
195-
allowGoToAllChannels: false,
196254
onChannelSelect: (narrow) => _handleNarrowSelect(context, narrow),
197255
// TODO(#412) add onTopicSelect, Currently when user lands on the
198256
// channel feed page from subscription list page and they tap
@@ -204,6 +262,7 @@ class SharePage extends StatelessWidget {
204262
RecentDmConversationsPageBody(
205263
hideDmsIfUserCantPost: true,
206264
onDmSelect: (narrow) => _handleNarrowSelect(context, narrow)),
207-
])));
265+
])),
266+
]));
208267
}
209268
}

0 commit comments

Comments
 (0)