Skip to content

Commit

Permalink
Merge pull request #177 from makinosp/develop
Browse files Browse the repository at this point in the history
update: bump up to 0.9.5
  • Loading branch information
makinosp authored Oct 27, 2024
2 parents 5d5a541 + b25ed82 commit 9b3605c
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 110 deletions.
4 changes: 2 additions & 2 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.4;
MARKETING_VERSION = 0.9.5;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -509,7 +509,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.4;
MARKETING_VERSION = 0.9.5;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
27 changes: 27 additions & 0 deletions harmonie/Components/HorizontalProfileImages.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// HorizontalProfileImages.swift
// Harmonie
//
// Created by makinosp on 2024/10/27.
//

import SwiftUI
import MemberwiseInit
import VRCKit

@MemberwiseInit
struct HorizontalProfileImages<T>: View where T: ProfileElementRepresentable {
@Init(.internal, label: "_") private let profiles: [T]
var body: some View {
ScrollView(.horizontal) {
LazyHStack(spacing: -8) {
ForEach(profiles) { profile in
CircleURLImage(
imageUrl: profile.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
}
}
}
}
3 changes: 0 additions & 3 deletions harmonie/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"" : {
"shouldTranslate" : false
},
"(%@)" : {
"shouldTranslate" : false
},
"%@ / %@" : {
"localizations" : {
"en" : {
Expand Down
17 changes: 17 additions & 0 deletions harmonie/Previews/FriendsLocation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// FriendsLocation.swift
// Harmonie
//
// Created by makinosp on 2024/10/27.
//

import VRCKit

extension PreviewDataProvider {
static var friendsLocation: FriendsLocation {
FriendsLocation(
location: .offline,
friends: (0...5).map { _ in friend }
)
}
}
3 changes: 0 additions & 3 deletions harmonie/ViewModels/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ final class AppViewModel {
var step: Step = .initializing
var isPresentedAlert = false
var vrckError: VRCKitError?
var isRequesting = false
var services: APIServiceUtil
var verifyType: VerifyType?
@ObservationIgnored var client: APIClient
Expand Down Expand Up @@ -82,9 +81,7 @@ final class AppViewModel {
}

func login() async -> Either<User, VerifyType>? {
defer { isRequesting = false }
var result: Either<User, VerifyType>?
isRequesting = true
do {
result = try await services.authenticationService.loginUserInfo()
} catch {
Expand Down
12 changes: 11 additions & 1 deletion harmonie/ViewModels/FriendViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class FriendViewModel {
var filterFavoriteGroups: Set<FavoriteGroup> = []
var filterText: String = ""
var sortType: SortType = .latest
var isRequesting = true
var isFetchingAllFriends = true
var isProcessingFilter = false
@ObservationIgnored let appVM: AppViewModel
@ObservationIgnored var favoriteFriends: [FavoriteFriend] = []
Expand Down Expand Up @@ -49,8 +49,14 @@ final class FriendViewModel {
}
}

var visibleFriendsLocations: [FriendsLocation] {
friendsLocations.filter(\.location.isVisible)
}

/// Fetch friends from API
func fetchAllFriends() async throws {
defer { isFetchingAllFriends = false }
isFetchingAllFriends = true
guard let user = appVM.user else { throw ApplicationError.UserIsNotSetError }
async let onlineFriendsTask = appVM.services.friendService.fetchFriends(
count: user.onlineFriends.count + user.activeFriends.count,
Expand All @@ -69,4 +75,8 @@ final class FriendViewModel {
func setFavoriteFriends(_ favoriteFriends: [FavoriteFriend]) {
self.favoriteFriends = favoriteFriends
}

var isContentUnavailable: Bool {
friendsLocations.isEmpty && !isFetchingAllFriends
}
}
1 change: 1 addition & 0 deletions harmonie/Views/Authentication/HelpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct HelpView: View {
VStack(spacing: 32) {
ForEach(contents, id: \.hashValue) { content($0) }
}
.multilineTextAlignment(.leading)
.foregroundStyle(Color(.systemGray))
.padding()
}
Expand Down
12 changes: 7 additions & 5 deletions harmonie/Views/Authentication/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ struct LoginView: View {

private var loginFields: some View {
VStack(alignment: .leading, spacing: 8) {
TextField("Username", text: $username)
.textInputAutocapitalization(.never)
.textFieldStyle(.roundedBorder)
SecureField("Password", text: $password)
.textFieldStyle(.roundedBorder)
Group {
TextField("Username", text: $username)
SecureField("Password", text: $password)
}
.textInputAutocapitalization(.never)
.textFieldStyle(.roundedBorder)
.multilineTextAlignment(.center)
HStack {
Text("Connect your VRChat account.")
.font(.footnote)
Expand Down
3 changes: 2 additions & 1 deletion harmonie/Views/Authentication/OtpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ struct OtpView: View {
.font(.headline)
VStack {
TextField("Code", text: $code)
.multilineTextAlignment(TextAlignment.center)
.keyboardType(.decimalPad)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 120)
Text(explanation)
.foregroundStyle(.gray)
.font(.caption2)
}
.padding(.horizontal, 8)
enterButton
}
.frame(maxWidth: 560)
.padding(32)
.ignoresSafeArea(.keyboard)
}
Expand Down
15 changes: 3 additions & 12 deletions harmonie/Views/Location/LocationCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,10 @@ struct LocationCardView: View {
.frame(maxWidth: .infinity, alignment: .leading)
NavigationLabel()
}
ScrollView(.horizontal) {
LazyHStack(spacing: -8) {
ForEach(location.friends) { friend in
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
HorizontalProfileImages(location.friends)
.onTapGesture {
selected = tag(instance)
}
}
.onTapGesture {
selected = tag(instance)
}
}
.padding(.top, 4)
}
Expand Down
139 changes: 81 additions & 58 deletions harmonie/Views/Location/LocationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,11 @@ struct LocationsView: View {

var body: some View {
NavigationSplitView(columnVisibility: $columnVisibility) {
locationList
.navigationTitle("Social")
.setColumn()
sidebar
} content: {
Group {
if let selectedInstance = selectedInstance {
LocationDetailView(
selection: $selection,
instanceLocation: selectedInstance
)
} else {
ContentUnavailableView {
Label("Select a location", systemImage: IconSet.location.systemName)
}
}
}
.setColumn()
content
} detail: {
Group {
if let selection = selection {
Group {
switch selection.segment {
case .friends:
UserDetailPresentationView(selected: selection.selected)
case .world:
WorldPresentationView(id: selection.selected.id)
default:
EmptyView()
}
}
.id(selection.selected.id)
} else {
ContentUnavailableView {
Label("Select a friend or world", systemImage: IconSet.info.systemName)
}
}
}
.setColumn()
detail
}
.navigationSplitViewStyle(.balanced)
.refreshable {
Expand All @@ -66,33 +33,91 @@ struct LocationsView: View {
}
}

private var locationList: some View {
private var sidebar: some View {
List(selection: $selectedInstance) {
friendLocations
inPrivateInstance
if !friendVM.isFetchingAllFriends {
inPrivateInstance
}
}
.overlay {
if friendVM.friendsLocations.isEmpty {
if friendVM.isContentUnavailable {
ContentUnavailableView {
Label("No Friend Location", systemImage: IconSet.friends.systemName)
}
}
}
.navigationTitle("Social")
.setColumn()
}

private var content: some View {
Group {
if let selectedInstance = selectedInstance {
LocationDetailView(
selection: $selection,
instanceLocation: selectedInstance
)
}
}
.overlay {
if selectedInstance == nil {
ContentUnavailableView {
Label("Select a location", systemImage: IconSet.location.systemName)
}
}
}
.setColumn()
}

private var detail: some View {
Group {
if let selection = selection {
Group {
switch selection.segment {
case .friends:
UserDetailPresentationView(selected: selection.selected)
case .world:
WorldPresentationView(id: selection.selected.id)
default:
EmptyView()
}
}
.id(selection.selected.id)
}
}
.overlay {
if selection == nil {
ContentUnavailableView {
Label("Select a friend or world", systemImage: IconSet.info.systemName)
}
}
}
.setColumn()
}

@ViewBuilder private var friendLocations: some View {
let friendsLocations = friendVM.friendsLocations.filter(\.location.isVisible)
Section {
ForEach(friendsLocations) { location in
LocationCardView(
selected: $selectedInstance,
location: location
)
if friendVM.isFetchingAllFriends {
ForEach(0...7, id: \.self) { _ in
LocationCardView(
selected: .constant(nil),
location: PreviewDataProvider.friendsLocation
)
}
} else {
ForEach(friendVM.visibleFriendsLocations) { location in
LocationCardView(
selected: $selectedInstance,
location: location
)
}
}
} header: {
HStack {
Text("Friend Locations")
Text("(\(friendsLocations.count.description))")
Text(verbatim: "(\(friendVM.visibleFriendsLocations.count))")
.redacted(reason: friendVM.isFetchingAllFriends ? .placeholder : [])
}
}
}
Expand All @@ -106,26 +131,18 @@ struct LocationsView: View {
VStack(alignment: .leading) {
Text("Private Instances")
.font(.body)
.lineLimit(1)
Text(friendVM.friendsInPrivate.count.description)
.font(.footnote)
.font(.caption)
.foregroundStyle(Color.gray)
}
.frame(maxWidth: .infinity, alignment: .leading)
NavigationLabel()
}
ScrollView(.horizontal) {
LazyHStack(spacing: -8) {
ForEach(friendVM.friendsInPrivate) { friend in
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
}
}
HorizontalProfileImages(friendVM.friendsInPrivate)
}
.padding(.top, 4)
}
.padding(.top, 4)
}
}
}
Expand All @@ -148,3 +165,9 @@ fileprivate extension View {
)
}
}

#Preview {
PreviewContainer {
LocationsView()
}
}
Loading

0 comments on commit 9b3605c

Please sign in to comment.