Skip to content

Commit 720f223

Browse files
authored
Merge pull request #84 from makinosp/develop
2 parents ffcef03 + 15d1134 commit 720f223

File tree

13 files changed

+110
-42
lines changed

13 files changed

+110
-42
lines changed

Harmonie.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
205B3BF22C00D51A0097D62A /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 205B3BF12C00D51A0097D62A /* SettingsView.swift */; };
3333
205B3BF42C00D8BF0097D62A /* ProgressScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 205B3BF32C00D8BF0097D62A /* ProgressScreen.swift */; };
3434
205C9DAF2C20612500E3782C /* Binding+NilCoalescing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 205C9DAE2C20612500E3782C /* Binding+NilCoalescing.swift */; };
35+
205D81A62C71B9D70047C1CC /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = 205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */; };
3536
206088E92C48079900626DDC /* LocationDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 206088E82C48079900626DDC /* LocationDetailView.swift */; };
3637
206AC9012BFA07AA00E0D5AE /* AsyncSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 206AC9002BFA07AA00E0D5AE /* AsyncSwiftUI */; };
3738
207FC6352C4256E60018E605 /* View+SizeModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 207FC6322C4256E60018E605 /* View+SizeModifier.swift */; };
@@ -138,6 +139,7 @@
138139
2096016D2C4BD30100D905AF /* VRCKit in Frameworks */,
139140
206AC9012BFA07AA00E0D5AE /* AsyncSwiftUI in Frameworks */,
140141
2052C7AE2C4BC97100B341D1 /* VRCKit in Frameworks */,
142+
205D81A62C71B9D70047C1CC /* SwiftUIIntrospect in Frameworks */,
141143
);
142144
runOnlyForDeploymentPostprocessing = 0;
143145
};
@@ -363,6 +365,7 @@
363365
208899AA2C4BB26D00BCE9C5 /* VRCKit */,
364366
2052C7AD2C4BC97100B341D1 /* VRCKit */,
365367
2096016C2C4BD30100D905AF /* VRCKit */,
368+
205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */,
366369
);
367370
productName = harmonie;
368371
productReference = 20395D912B945CD700003921 /* Harmonie.app */;
@@ -446,6 +449,7 @@
446449
201B430E2C27F48E00879A2F /* XCRemoteSwiftPackageReference "LicenseList" */,
447450
20592B012C45640D00E1C8B8 /* XCRemoteSwiftPackageReference "async-swift-ui" */,
448451
2096016B2C4BD30100D905AF /* XCRemoteSwiftPackageReference "vrckit" */,
452+
205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */,
449453
);
450454
productRefGroup = 20395D922B945CD700003921 /* Products */;
451455
projectDirPath = "";
@@ -883,6 +887,14 @@
883887
kind = branch;
884888
};
885889
};
890+
205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */ = {
891+
isa = XCRemoteSwiftPackageReference;
892+
repositoryURL = "https://github.com/siteline/swiftui-introspect";
893+
requirement = {
894+
kind = upToNextMajorVersion;
895+
minimumVersion = 1.3.0;
896+
};
897+
};
886898
2096016B2C4BD30100D905AF /* XCRemoteSwiftPackageReference "vrckit" */ = {
887899
isa = XCRemoteSwiftPackageReference;
888900
repositoryURL = "https://github.com/makinosp/vrckit";
@@ -928,6 +940,11 @@
928940
package = 20592B012C45640D00E1C8B8 /* XCRemoteSwiftPackageReference "async-swift-ui" */;
929941
productName = AsyncSwiftUI;
930942
};
943+
205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */ = {
944+
isa = XCSwiftPackageProductDependency;
945+
package = 205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */;
946+
productName = SwiftUIIntrospect;
947+
};
931948
206AC9002BFA07AA00E0D5AE /* AsyncSwiftUI */ = {
932949
isa = XCSwiftPackageProductDependency;
933950
productName = AsyncSwiftUI;

Harmonie.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

harmonie/Extensions/Status+color.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ import VRCKit
1111
extension UserStatus {
1212
var color: Color {
1313
switch self {
14-
case .joinMe:
15-
return .cyan
16-
case .active:
17-
return .green
18-
case .askMe:
19-
return .orange
20-
case .busy:
21-
return .red
22-
case .offline:
23-
return .gray
14+
case .joinMe: .cyan
15+
case .active: .green
16+
case .askMe: .orange
17+
case .busy: .red
18+
case .offline: .gray
2419
}
2520
}
2621
}

harmonie/Utils/DateUtil.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class DateUtil {
2424
return dateFormatter
2525
}()
2626

27+
func formattedDateTime(from date: Date) -> String {
28+
[formatToyyyyMMdd(from: date), formatToHHmm(from: date)]
29+
.joined(separator: " ")
30+
}
31+
2732
func formatToyyyyMMdd(from date: Date) -> String {
2833
return yyyyMMddDateFormatter.string(from: date)
2934
}

harmonie/ViewModels/FavoriteViewModel.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ typealias FavoriteFriend = (favoriteGroupId: String, friends: [Friend])
1616
class FavoriteViewModel: ObservableObject {
1717
@Published var favoriteGroups: [FavoriteGroup] = []
1818
@Published var favoriteFriends: [FavoriteFriend] = []
19+
@Published var segment: Segment = .friend
1920
let friendVM: FriendViewModel
2021
let service: any FavoriteServiceProtocol
22+
23+
enum Segment {
24+
case friend, world
25+
}
2126

2227
/// Initializes the view model with the specified HTTP client.
2328
/// - Parameter client: The `APIClient` instance used for making network requests.
@@ -128,3 +133,22 @@ class FavoriteViewModel: ObservableObject {
128133
}
129134
}
130135
}
136+
137+
extension FavoriteViewModel.Segment: Identifiable {
138+
var id: Int { hashValue }
139+
}
140+
141+
extension FavoriteViewModel.Segment: CaseIterable {
142+
var allCases: [FavoriteViewModel.Segment] {
143+
[.friend, .world]
144+
}
145+
}
146+
147+
extension FavoriteViewModel.Segment: CustomStringConvertible {
148+
var description: String {
149+
switch self {
150+
case .friend: "Friend"
151+
case .world: "World"
152+
}
153+
}
154+
}

harmonie/ViewModels/FriendViewModel+Filters.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ extension FriendViewModel.FilterUserStatus: CustomStringConvertible {
9393
var description: String {
9494
switch self {
9595
case .all:
96-
return "All"
96+
"All"
9797
case .status(let status):
98-
return status.description
98+
status.description
9999
}
100100
}
101101
}

harmonie/Views/Favorite/FavoritesView.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ struct FavoritesView: View {
3232
.presentationDetents([.medium, .large])
3333
.presentationBackground(Color(UIColor.systemGroupedBackground))
3434
}
35+
.toolbar {
36+
ToolbarItem(placement: .principal) {
37+
Picker("", selection: $favoriteVM.segment) {
38+
ForEach(FavoriteViewModel.Segment.allCases) { segment in
39+
Text(segment.description).tag(segment)
40+
}
41+
}
42+
.pickerStyle(SegmentedPickerStyle())
43+
}
44+
}
3545
.navigationTitle("Favorites")
3646
} else {
3747
ProgressScreen()
@@ -45,7 +55,7 @@ struct FavoritesView: View {
4555
func rowView(_ friend: Friend) -> some View {
4656
HStack {
4757
CircleURLImage(
48-
imageUrl: friend.userIconUrl,
58+
imageUrl: friend.thumbnailUrl,
4959
size: Constants.IconSize.thumbnail
5060
)
5161
Text(friend.displayName)

harmonie/Views/Friend/FriendsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct FriendsView: View {
4545
.foregroundStyle(friend.status.color)
4646
.frame(size: Constants.IconSize.thumbnailOutside)
4747
CircleURLImage(
48-
imageUrl: friend.userIconUrl,
48+
imageUrl: friend.thumbnailUrl,
4949
size: Constants.IconSize.thumbnail
5050
)
5151
}

harmonie/Views/Location/LocationCardView.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ struct LocationCardView: View {
1717
let location: FriendsLocation
1818
let frameWidth: CGFloat = 120
1919

20+
var backGroundColor: Color {
21+
switch UIDevice.current.userInterfaceIdiom {
22+
case .pad:
23+
Color(UIColor.tertiarySystemGroupedBackground)
24+
default:
25+
Color(UIColor.secondarySystemGroupedBackground)
26+
}
27+
}
28+
2029
var body: some View {
2130
ZStack {
2231
RoundedRectangle(cornerRadius: 16)
23-
.foregroundStyle(Color(UIColor.tertiarySystemGroupedBackground))
32+
.foregroundStyle(backGroundColor)
2433
if let instance = instance {
2534
locationCardContent(instance: instance)
2635
.onTapGesture {
@@ -62,7 +71,7 @@ struct LocationCardView: View {
6271
.foregroundStyle(friend.status.color)
6372
.frame(size: Constants.IconSize.thumbnailOutside)
6473
CircleURLImage(
65-
imageUrl: friend.userIconUrl,
74+
imageUrl: friend.thumbnailUrl,
6675
size: Constants.IconSize.thumbnail
6776
)
6877
}
@@ -79,11 +88,9 @@ struct LocationCardView: View {
7988
}
8089

8190
func personAmount(_ instance: Instance) -> String {
82-
[
83-
location.friends.count.description,
84-
instance.userCount.description,
85-
instance.capacity.description
86-
].joined(separator: " / ")
91+
[location.friends.count, instance.userCount, instance.capacity]
92+
.map { $0.description }
93+
.joined(separator: " / ")
8794
}
8895

8996
func locationThumbnail(_ url: URL?) -> some View {

harmonie/Views/Location/LocationDetailView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct LocationDetailView: View {
5656
.foregroundStyle(friend.status.color)
5757
.frame(size: Constants.IconSize.thumbnailOutside)
5858
CircleURLImage(
59-
imageUrl: friend.userIconUrl,
59+
imageUrl: friend.thumbnailUrl,
6060
size: Constants.IconSize.thumbnail
6161
)
6262
}

0 commit comments

Comments
 (0)