Skip to content

RecentDmConversationsPage: Add #249

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

Merged
merged 11 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions assets/Source_Sans_3/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2010-2022 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.

This Font Software is licensed under the SIL Open Font License, Version 1.1.

This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added assets/Source_Sans_3/SourceSans3VF-Italic.otf
Binary file not shown.
Binary file added assets/Source_Sans_3/SourceSans3VF-Upright.otf
Binary file not shown.
Binary file modified assets/icons/ZulipIcons.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions assets/icons/group_dm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/api/route/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ Future<InitialSnapshot> registerQueue(ApiConnection connection) {
return connection.post('registerQueue', InitialSnapshot.fromJson, 'register', {
'apply_markdown': true,
'slim_presence': true,
'client_gravatar': false, // TODO(#255): turn on
'client_capabilities': {
'notification_settings_null': true,
'bulk_message_deletion': true,
'user_avatar_url_field_optional': true,
'user_avatar_url_field_optional': false, // TODO(#254): turn on
'stream_typing_notifications': false, // TODO implement
'user_settings_object': true,
},
Expand Down
3 changes: 3 additions & 0 deletions lib/licenses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Stream<LicenseEntry> additionalLicenses() async* {
yield LicenseEntryWithLineBreaks(
['Source Code Pro'],
await rootBundle.loadString('assets/Source_Code_Pro/LICENSE.md'));
yield LicenseEntryWithLineBreaks(
['Source Sans 3'],
await rootBundle.loadString('assets/Source_Sans_3/LICENSE.md'));
}
6 changes: 6 additions & 0 deletions lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../model/narrow.dart';
import 'about_zulip.dart';
import 'login.dart';
import 'message_list.dart';
import 'recent_dm_conversations.dart';
import 'store.dart';

class ZulipApp extends StatelessWidget {
Expand Down Expand Up @@ -152,6 +153,11 @@ class HomePage extends StatelessWidget {
MessageListPage.buildRoute(context: context,
narrow: const AllMessagesNarrow())),
child: const Text("All messages")),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => Navigator.push(context,
RecentDmConversationsPage.buildRoute(context: context)),
child: const Text("Direct messages")),
if (testStreamId != null) ...[
const SizedBox(height: 16),
ElevatedButton(
Expand Down
78 changes: 78 additions & 0 deletions lib/widgets/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,84 @@ class RealmContentNetworkImage extends StatelessWidget {
}
}

/// A rounded square with size [size] showing a user's avatar.
class Avatar extends StatelessWidget {
const Avatar({
super.key,
required this.userId,
required this.size,
required this.borderRadius,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The required borderRadius can be squashed into the "Pull out Avatar widget" commit, resolving the TODO in the latter.

});

final int userId;
final double size;
final double borderRadius;

@override
Widget build(BuildContext context) {
return AvatarShape(
size: size,
borderRadius: borderRadius,
child: AvatarImage(userId: userId));
}
}

/// The appropriate avatar image for a user ID.
///
/// If the user isn't found, gives a [SizedBox.shrink].
///
/// Wrap this with [AvatarShape].
class AvatarImage extends StatelessWidget {
const AvatarImage({
super.key,
required this.userId,
});

final int userId;

@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final user = store.users[userId];

if (user == null) { // TODO(log)
return const SizedBox.shrink();
}

final resolvedUrl = switch (user.avatarUrl) {
null => null, // TODO(#255): handle computing gravatars
var avatarUrl => resolveUrl(avatarUrl, store.account),
};
return (resolvedUrl == null)
? const SizedBox.shrink()
: RealmContentNetworkImage(resolvedUrl, filterQuality: FilterQuality.medium);
}
}

/// A rounded square shape, to wrap an [AvatarImage] or similar.
class AvatarShape extends StatelessWidget {
const AvatarShape({
super.key,
required this.size,
required this.borderRadius,
required this.child,
});

final double size;
final double borderRadius;
final Widget child;

@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: size,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
clipBehavior: Clip.antiAlias,
child: child));
}
}

//
// Small helpers.
//
Expand Down
20 changes: 12 additions & 8 deletions lib/widgets/icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ abstract final class ZulipIcons {
//
// * Add an SVG file in `assets/icons/`,
// or otherwise edit the SVG files there.
// The files' names (before ".svg") should be valid Dart identifiers.
//
// * Then run the command `scripts/icons/build-icon-font`.
// That will update this file and the generated icon font,
Expand All @@ -27,29 +28,32 @@ abstract final class ZulipIcons {
/// The Zulip custom icon "globe".
static const IconData globe = IconData(0xf102, fontFamily: "Zulip Icons");

/// The Zulip custom icon "group_dm".
static const IconData group_dm = IconData(0xf103, fontFamily: "Zulip Icons");

/// The Zulip custom icon "hash_sign".
static const IconData hash_sign = IconData(0xf103, fontFamily: "Zulip Icons");
static const IconData hash_sign = IconData(0xf104, fontFamily: "Zulip Icons");

/// The Zulip custom icon "language".
static const IconData language = IconData(0xf104, fontFamily: "Zulip Icons");
static const IconData language = IconData(0xf105, fontFamily: "Zulip Icons");

/// The Zulip custom icon "lock".
static const IconData lock = IconData(0xf105, fontFamily: "Zulip Icons");
static const IconData lock = IconData(0xf106, fontFamily: "Zulip Icons");

/// The Zulip custom icon "mute".
static const IconData mute = IconData(0xf106, fontFamily: "Zulip Icons");
static const IconData mute = IconData(0xf107, fontFamily: "Zulip Icons");

/// The Zulip custom icon "read_receipts".
static const IconData read_receipts = IconData(0xf107, fontFamily: "Zulip Icons");
static const IconData read_receipts = IconData(0xf108, fontFamily: "Zulip Icons");

/// The Zulip custom icon "topic".
static const IconData topic = IconData(0xf108, fontFamily: "Zulip Icons");
static const IconData topic = IconData(0xf109, fontFamily: "Zulip Icons");

/// The Zulip custom icon "unmute".
static const IconData unmute = IconData(0xf109, fontFamily: "Zulip Icons");
static const IconData unmute = IconData(0xf10a, fontFamily: "Zulip Icons");

/// The Zulip custom icon "user".
static const IconData user = IconData(0xf10a, fontFamily: "Zulip Icons");
static const IconData user = IconData(0xf10b, fontFamily: "Zulip Icons");

// END GENERATED ICON DATA
}
19 changes: 2 additions & 17 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MessageListPage extends StatefulWidget {

static Route<void> buildRoute({required BuildContext context, required Narrow narrow}) {
return MaterialAccountPageRoute(context: context,
settings: RouteSettings(name: 'message_list', arguments: narrow), // for testing
builder: (context) => MessageListPage(narrow: narrow));
Comment on lines 23 to 25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see.

This RouteSettings and the builder feel like they're expressing the same information twice. I'll try experimenting with ways to deduplicate that, and also to avoid us having to make up names like message_list for each of the pages we might want to test something navigating to. But that can be after merging this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, yeah. Thanks!

}

Expand Down Expand Up @@ -474,16 +475,6 @@ class MessageWithSender extends StatelessWidget {

@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final author = store.users[message.senderId]!;

final avatarUrl = author.avatarUrl == null
? null // TODO handle computing gravatars
: resolveUrl(author.avatarUrl!, store.account);
final avatar = (avatarUrl == null)
? const SizedBox.shrink()
: RealmContentNetworkImage(avatarUrl, filterQuality: FilterQuality.medium);

final time = _kMessageTimestampFormat
.format(DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp));

Expand All @@ -496,13 +487,7 @@ class MessageWithSender extends StatelessWidget {
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.fromLTRB(3, 6, 11, 0),
child: Container(
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(4))),
width: 35,
height: 35,
child: avatar)),
child: Avatar(userId: message.senderId, size: 35, borderRadius: 4)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand Down
Loading