generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stacked avatars * fix tests * remove comment
- Loading branch information
Showing
29 changed files
with
144 additions
and
56 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
66 changes: 66 additions & 0 deletions
66
ElementX/Sources/Other/SwiftUI/Views/StackedAvatarsView.swift
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,66 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct StackedAvatarInfo { | ||
let url: URL? | ||
let name: String? | ||
let contentID: String | ||
} | ||
|
||
struct StackedAvatarsView: View { | ||
let overlap: CGFloat | ||
let lineWidth: CGFloat | ||
var shouldStackFromLast = false | ||
let avatars: [StackedAvatarInfo] | ||
let avatarSize: AvatarSize | ||
let mediaProvider: MediaProviderProtocol? | ||
|
||
var body: some View { | ||
HStack(spacing: -overlap) { | ||
ForEach(0..<avatars.count, id: \.self) { index in | ||
LoadableAvatarImage(url: avatars[index].url, | ||
name: avatars[index].name, | ||
contentID: avatars[index].contentID, | ||
avatarSize: avatarSize, | ||
mediaProvider: mediaProvider) | ||
.padding(lineWidth) | ||
.overlay { | ||
Circle() | ||
.strokeBorder(Color.compound.bgCanvasDefault, lineWidth: lineWidth) | ||
} | ||
.zIndex(shouldStackFromLast ? Double(index) : Double(avatars.count - index)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct StackedAvatarsView_Previews: PreviewProvider, TestablePreview { | ||
static let avatars: [StackedAvatarInfo] = [ | ||
.init(url: nil, name: "Alice", contentID: "@alice:matrix.org"), | ||
.init(url: nil, name: "Bob", contentID: "@bob:matrix.org"), | ||
.init(url: nil, name: "Charlie", contentID: "@charlie:matrix.org"), | ||
.init(url: nil, name: "Dan", contentID: "@charlie:matrix.org") | ||
] | ||
|
||
static var previews: some View { | ||
VStack(spacing: 10) { | ||
StackedAvatarsView(overlap: 16, | ||
lineWidth: 2, | ||
avatars: avatars, | ||
avatarSize: .user(on: .knockingUsers), | ||
mediaProvider: MediaProviderMock()) | ||
StackedAvatarsView(overlap: 16, | ||
lineWidth: 2, | ||
shouldStackFromLast: true, | ||
avatars: avatars, | ||
avatarSize: .user(on: .knockingUsers), | ||
mediaProvider: MediaProviderMock()) | ||
} | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
PreviewTests/Sources/__Snapshots__/PreviewTests/test_roomScreen-iPad-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
PreviewTests/Sources/__Snapshots__/PreviewTests/test_roomScreen-iPad-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...wTests/Sources/__Snapshots__/PreviewTests/test_roomScreen-iPhone-16-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...Tests/Sources/__Snapshots__/PreviewTests/test_roomScreen-iPhone-16-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...sts/Sources/__Snapshots__/PreviewTests/test_stackedAvatarsView-iPad-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ts/Sources/__Snapshots__/PreviewTests/test_stackedAvatarsView-iPad-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ources/__Snapshots__/PreviewTests/test_stackedAvatarsView-iPhone-16-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...urces/__Snapshots__/PreviewTests/test_stackedAvatarsView-iPhone-16-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...reviewTests/test_timelineItemBubbledStylerView-iPad-en-GB.Mock-Timeline-RTL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...__/PreviewTests/test_timelineItemBubbledStylerView-iPad-en-GB.Mock-Timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...eviewTests/test_timelineItemBubbledStylerView-iPad-pseudo.Mock-Timeline-RTL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
..._/PreviewTests/test_timelineItemBubbledStylerView-iPad-pseudo.Mock-Timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...wTests/test_timelineItemBubbledStylerView-iPhone-16-en-GB.Mock-Timeline-RTL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...eviewTests/test_timelineItemBubbledStylerView-iPhone-16-en-GB.Mock-Timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...Tests/test_timelineItemBubbledStylerView-iPhone-16-pseudo.Mock-Timeline-RTL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...viewTests/test_timelineItemBubbledStylerView-iPhone-16-pseudo.Mock-Timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...urces/__Snapshots__/PreviewTests/test_timelineReadReceiptsView-iPad-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...rces/__Snapshots__/PreviewTests/test_timelineReadReceiptsView-iPad-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
.../__Snapshots__/PreviewTests/test_timelineReadReceiptsView-iPhone-16-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...__Snapshots__/PreviewTests/test_timelineReadReceiptsView-iPhone-16-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
PreviewTests/Sources/__Snapshots__/PreviewTests/test_timelineView-iPad-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...iewTests/Sources/__Snapshots__/PreviewTests/test_timelineView-iPad-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ests/Sources/__Snapshots__/PreviewTests/test_timelineView-iPhone-16-en-GB.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...sts/Sources/__Snapshots__/PreviewTests/test_timelineView-iPhone-16-pseudo.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.