-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
747 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
FluentTest/.DS_Store | ||
.DS_Store |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
FluentTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
FluentTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+12 KB
...xcodeproj/project.xcworkspace/xcuserdata/emlyn.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
FluentTest.xcodeproj/xcuserdata/emlyn.xcuserdatad/xcschemes/xcschememanagement.plist
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>FluentTest.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>3</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
14 changes: 14 additions & 0 deletions
14
FluentTest.xcodeproj/xcuserdata/john.xcuserdatad/xcschemes/xcschememanagement.plist
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>FluentTest.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>3</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+82.4 KB
FluentTest.xcworkspace/xcuserdata/emlyn.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
FluentTest.xcworkspace/xcuserdata/emlyn.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
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,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "0A82325C-1245-4E22-8070-570F90885062" | ||
type = "0" | ||
version = "2.0"> | ||
<Breakpoints> | ||
<BreakpointProxy | ||
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint"> | ||
<BreakpointContent | ||
uuid = "441D8BB3-2971-41DF-A898-48E3F6929C65" | ||
shouldBeEnabled = "Yes" | ||
ignoreCount = "0" | ||
continueAfterRunningActions = "No"> | ||
</BreakpointContent> | ||
</BreakpointProxy> | ||
<BreakpointProxy | ||
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint"> | ||
<BreakpointContent | ||
uuid = "C1D25B71-501D-48C5-B42A-F6638160ED76" | ||
shouldBeEnabled = "Yes" | ||
ignoreCount = "0" | ||
continueAfterRunningActions = "No" | ||
breakpointStackSelectionBehavior = "1" | ||
scope = "1" | ||
stopOnStyle = "0"> | ||
</BreakpointContent> | ||
</BreakpointProxy> | ||
<BreakpointProxy | ||
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint"> | ||
<BreakpointContent | ||
uuid = "856736C2-2F65-41E3-BD8F-CDEB32A8EC7D" | ||
shouldBeEnabled = "Yes" | ||
condition = "-[NSObject(NSObject) doesNotRecognizeSelector:]" | ||
ignoreCount = "0" | ||
continueAfterRunningActions = "No" | ||
breakpointStackSelectionBehavior = "1" | ||
scope = "1" | ||
stopOnStyle = "0"> | ||
</BreakpointContent> | ||
</BreakpointProxy> | ||
</Breakpoints> | ||
</Bucket> |
Binary file added
BIN
+29 KB
FluentTest.xcworkspace/xcuserdata/john.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
FluentTest.xcworkspace/xcuserdata/john.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "23658206-1476-4583-8EA1-4FCFC79290EC" | ||
type = "0" | ||
version = "2.0"> | ||
</Bucket> |
11 changes: 11 additions & 0 deletions
11
FluentTest/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
FluentTest/Assets.xcassets/AppIcon.appiconset/Contents.json
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,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,25 @@ | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AvatarGroupContainer: UIViewRepresentable { | ||
|
||
var participantList: [ParticipantInfoModel] | ||
var avatarGroup: ParticipantAvatarGroup | ||
|
||
func makeUIView(context: Context) -> ParticipantAvatarGroup { | ||
avatarGroup.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) | ||
return avatarGroup | ||
} | ||
|
||
func updateUIView(_ uiView: ParticipantAvatarGroup, context: Context) { | ||
avatarGroup.setAvatars(to: participantList) | ||
} | ||
} | ||
|
||
struct ParticipantInfoModel { | ||
var displayName: String | ||
} |
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,64 @@ | ||
// | ||
// ContentView.swift | ||
// FluentTest | ||
// | ||
// Created by Emlyn Bolton-Maggs on 2022-11-08. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
@ObservedObject var viewmodel = ViewModel() | ||
|
||
var body: some View { | ||
VStack { | ||
Image(systemName: "globe") | ||
.imageScale(.large) | ||
.foregroundColor(.accentColor) | ||
Text("Hello, world!") | ||
AvatarGroupContainer(participantList: viewmodel.participants, | ||
avatarGroup: viewmodel.avatarGroup) | ||
} | ||
.padding() | ||
.onAppear { | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.9, execute: { | ||
viewmodel.participants = [ | ||
ParticipantInfoModel(displayName: "pp"), | ||
ParticipantInfoModel(displayName: "sd"), | ||
ParticipantInfoModel(displayName: "jj"), | ||
ParticipantInfoModel(displayName: "jm"), | ||
ParticipantInfoModel(displayName: "jd"), | ||
ParticipantInfoModel(displayName: "jq") | ||
] | ||
}) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: { | ||
viewmodel.participants = [ | ||
ParticipantInfoModel(displayName: "jj"), | ||
ParticipantInfoModel(displayName: "jm"), | ||
ParticipantInfoModel(displayName: "jd"), | ||
ParticipantInfoModel(displayName: "jq") | ||
] | ||
}) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.1, execute: { | ||
viewmodel.participants = [ | ||
ParticipantInfoModel(displayName: "oo"), | ||
ParticipantInfoModel(displayName: "oo"), | ||
] | ||
}) | ||
} | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} | ||
|
||
class ViewModel: ObservableObject { | ||
var avatarGroup = ParticipantAvatarGroup() | ||
@Published var participants: [ParticipantInfoModel] = [ | ||
ParticipantInfoModel(displayName: "oo"), | ||
ParticipantInfoModel(displayName: "oo"), | ||
] | ||
} |
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,17 @@ | ||
// | ||
// FluentTestApp.swift | ||
// FluentTest | ||
// | ||
// Created by Emlyn Bolton-Maggs on 2022-11-08. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct FluentTestApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
} | ||
} | ||
} |
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,71 @@ | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
|
||
import FluentUI | ||
import UIKit | ||
|
||
class ParticipantAvatarGroup: UIView { | ||
|
||
private var group: MSFAvatarGroup? | ||
private var lastSeen: [ParticipantInfoModel]? | ||
private var avatarCount: Int = 0 | ||
|
||
private enum Constants { | ||
static let avatarWidth: CGFloat = 16.0 | ||
static let maxAvatarAllowed: Int = 2 | ||
static let overflowCount: Int = 0 | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
initAvatarGroup() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
initAvatarGroup() | ||
} | ||
|
||
} | ||
|
||
extension ParticipantAvatarGroup { | ||
private func initAvatarGroup() { | ||
group = MSFAvatarGroup(style: .stack, size: .xsmall) | ||
guard let group = group else { | ||
return | ||
} | ||
group.state.overflowCount = Constants.overflowCount | ||
// total avatar shown would be 3 | ||
// (max allowed 2 + 1 to show number of remaining participants) | ||
group.state.maxDisplayedAvatars = Constants.maxAvatarAllowed | ||
group.isAccessibilityElement = false | ||
addSubview(group) | ||
group.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
group.leftAnchor.constraint(equalTo: self.leftAnchor), | ||
group.rightAnchor.constraint(equalTo: self.rightAnchor), | ||
group.topAnchor.constraint(equalTo: self.topAnchor), | ||
group.bottomAnchor.constraint(equalTo: self.bottomAnchor) | ||
]) | ||
} | ||
|
||
func setAvatars(to newData: [ParticipantInfoModel]) { | ||
guard let group = group else { | ||
return | ||
} | ||
for _ in 0..<avatarCount { | ||
group.state.removeAvatar(at: 0) | ||
} | ||
avatarCount = 0 | ||
for participant in newData { | ||
avatarCount += 1 | ||
let newAvatar = group.state.createAvatar() | ||
newAvatar.primaryText = participant.displayName | ||
newAvatar.isTransparent = false | ||
newAvatar.isRingVisible = false | ||
} | ||
lastSeen = newData | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
FluentTest/Preview Content/Preview Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |