Skip to content

Commit

Permalink
Merge pull request #179 from makinosp/develop
Browse files Browse the repository at this point in the history
update: bump up to 0.9.6
  • Loading branch information
makinosp authored Oct 30, 2024
2 parents 9b3605c + c4a9524 commit a208511
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 63 deletions.
5 changes: 3 additions & 2 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
en,
ja,
"zh-Hans",
Base,
);
mainGroup = 20395D882B945CD700003921;
packageReferences = (
Expand Down Expand Up @@ -473,7 +474,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.5;
MARKETING_VERSION = 0.9.6;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -509,7 +510,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.5;
MARKETING_VERSION = 0.9.6;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
22 changes: 22 additions & 0 deletions harmonie/Extensions/FavoriteType+LocalizedStringKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// FavoriteType+LocalizedStringKey.swift
// Harmonie
//
// Created by makinosp on 2024/10/30.
//

import VRCKit
import SwiftUICore

extension FavoriteType {
var localizedStringKey: LocalizedStringKey {
switch self {
case .world:
LocalizedStringKey("World")
case .avatar:
LocalizedStringKey("Avatar")
case .friend:
LocalizedStringKey("Friend")
}
}
}
48 changes: 32 additions & 16 deletions harmonie/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@
}
}
},
"Avatar" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "アバター"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "模型"
}
}
}
},
"Build" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -223,22 +239,6 @@
}
}
},
"Code" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "コード"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "代码"
}
}
}
},
"Confirm" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -544,6 +544,22 @@
}
}
},
"Friend" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "フレンド"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "好友"
}
}
}
},
"Friend Locations" : {
"localizations" : {
"ja" : {
Expand Down
10 changes: 9 additions & 1 deletion harmonie/Models/InstanceLocationModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ import VRCKit

struct InstanceLocation: Hashable {
let location: FriendsLocation
let instance: Instance
let instance: Instance?
}

extension InstanceLocation: Identifiable {
var id: Int { hashValue }
}

extension InstanceLocation {
/// Initialize as private instance
init(friends: [Friend]) {
let location = FriendsLocation(location: .private, friends: friends)
self.init(location: location, instance: nil)
}
}
2 changes: 1 addition & 1 deletion harmonie/Views/Authentication/OtpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct OtpView: View {
Text("Two-step verification")
.font(.headline)
VStack {
TextField("Code", text: $code)
TextField(text: $code) { Text(verbatim: "000000") }
.multilineTextAlignment(TextAlignment.center)
.keyboardType(.decimalPad)
.textFieldStyle(.roundedBorder)
Expand Down
32 changes: 15 additions & 17 deletions harmonie/Views/Location/LocationCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@ struct LocationCardView: View {
let location: FriendsLocation

var body: some View {
Group {
if isFailure {
EmptyView()
} else {
locationCardContent(instance: instance ?? PreviewDataProvider.instance())
}
}
.redacted(reason: isRequesting ? .placeholder : [])
.task {
if case let .id(id) = location.location {
do {
defer { withAnimation { isRequesting = false } }
let service = appVM.services.instanceService
instance = try await service.fetchInstance(location: id)
} catch {
isFailure = true
if isFailure {
EmptyView()
} else {
locationCardContent(instance: instance ?? PreviewDataProvider.instance())
.redacted(reason: isRequesting ? .placeholder : [])
.task {
if case let .id(id) = location.location {
do {
defer { withAnimation { isRequesting = false } }
let service = appVM.services.instanceService
instance = try await service.fetchInstance(location: id)
} catch {
isFailure = true
}
}
}
}
}
}

Expand Down
19 changes: 3 additions & 16 deletions harmonie/Views/Location/LocationDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import VRCKit

@MemberwiseInit
struct LocationDetailView: View {
@InitWrapper(.internal, type: Binding<SegmentIdSelection?>)
@InitWrapper(.internal, label: "_", type: Binding<SegmentIdSelection?>)
@Binding private var selection: SegmentIdSelection?
@Init(.internal) private let instanceLocation: InstanceLocation

private var location: FriendsLocation { instanceLocation.location }
private var instance: Instance { instanceLocation.instance }
@Init(.internal) private let location: FriendsLocation
@Init(.internal) private let instance: Instance

private typealias InformationItem = (title: String, value: String)
private var information: [InformationItem] {
Expand Down Expand Up @@ -62,17 +60,6 @@ struct LocationDetailView: View {
.navigationBarTitleDisplayMode(.inline)
}

private var bottomBar: some View {
VStack(alignment: .leading) {
Text(instance.world.name)
.font(.headline)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 8)
.padding(.horizontal, 12)
.foregroundStyle(Color.white)
}

private var friendList: ForEach<[Friend], Friend.ID, some View> {
ForEach(location.friends) { friend in
NavigationLabel {
Expand Down
14 changes: 8 additions & 6 deletions harmonie/Views/Location/LocationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct LocationsView: View {
@Environment(FriendViewModel.self) var friendVM
@State private var columnVisibility: NavigationSplitViewVisibility = .all
@State private var selectedInstance: InstanceLocation?
@State private var isSelectedPrivate = false
@State private var selection: SegmentIdSelection?

var body: some View {
Expand Down Expand Up @@ -53,11 +54,11 @@ struct LocationsView: View {

private var content: some View {
Group {
if let selectedInstance = selectedInstance {
LocationDetailView(
selection: $selection,
instanceLocation: selectedInstance
)
if let location = selectedInstance?.location,
let instance = selectedInstance?.instance {
LocationDetailView($selection, location: location, instance: instance)
} else if let instance = selectedInstance, instance.location.location == .private {
PrivateLocationView($selection, friends: instance.location.friends)
}
}
.overlay {
Expand Down Expand Up @@ -96,7 +97,7 @@ struct LocationsView: View {
.setColumn()
}

@ViewBuilder private var friendLocations: some View {
private var friendLocations: some View {
Section {
if friendVM.isFetchingAllFriends {
ForEach(0...7, id: \.self) { _ in
Expand Down Expand Up @@ -143,6 +144,7 @@ struct LocationsView: View {
}
.padding(.top, 4)
}
.tag(InstanceLocation(friends: friendVM.friendsInPrivate))
}
}
}
Expand Down
37 changes: 37 additions & 0 deletions harmonie/Views/Location/PrivateLocationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// PrivateLocationView.swift
// Harmonie
//
// Created by makinosp on 2024/10/30.
//

import MemberwiseInit
import SwiftUI
import VRCKit

@MemberwiseInit
struct PrivateLocationView: View {
@InitWrapper(.internal, label: "_", type: Binding<SegmentIdSelection?>)
@Binding private var selection: SegmentIdSelection?
@Init(.internal) private let friends: [Friend]

var body: some View {
List(selection: $selection) {
Section("Friends") {
ForEach(friends) { friend in
NavigationLabel {
Label {
Text(friend.displayName)
} icon: {
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
}
.tag(SegmentIdSelection(friendId: friend.id))
}
}
}
.listStyle(.insetGrouped)
.navigationTitle("Private")
.navigationBarTitleDisplayMode(.inline)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct FavoriteGroupsEditView: View {
@Environment(AppViewModel.self) var appVM
@Environment(FavoriteViewModel.self) var favoriteVM
@Environment(\.dismiss) private var dismiss
@FocusState var isFocusedTextField
@State private var displayName: String
@State private var visibility: FavoriteGroup.Visibility
@State private var isRequesting = false
Expand All @@ -28,10 +29,14 @@ struct FavoriteGroupsEditView: View {
Form {
Section("Display Name") {
TextField("", text: $displayName)
.focused($isFocusedTextField)
}
}
.toolbar { toolbarItems }
}
.task {
isFocusedTextField = true
}
}

@ToolbarContentBuilder var toolbarItems: some ToolbarContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct FavoriteGroupsListView: View {
List {
let types: [FavoriteType] = [.friend, .world]
ForEach(types, id: \.hashValue) { type in
Section(type.rawValue) {
Section(type.localizedStringKey) {
ForEach(favoriteVM.favoriteGroups(type)) { group in
Button {
selected = group
Expand All @@ -30,6 +30,7 @@ struct FavoriteGroupsListView: View {
}
.sheet(item: $selected) { group in
FavoriteGroupsEditView(favoriteGroup: group)
.presentationDetents([.small])
}
.navigationTitle("Edit favorite groups")
.navigationBarTitleDisplayMode(.inline)
Expand Down
6 changes: 3 additions & 3 deletions harmonie/Views/UserDetail/NoteEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import VRCKit
struct NoteEditView: View {
@Environment(AppViewModel.self) var appVM
@Environment(\.dismiss) private var dismiss
@FocusState var isFocusedNoteField
@FocusState var isFocusedTextField
@State private var text: String
@State private var isRequesting = false
private let userId: String
Expand All @@ -28,7 +28,7 @@ struct NoteEditView: View {
Form {
TextField("Enter note", text: $text, axis: .vertical)
.lineLimit(5...10)
.focused($isFocusedNoteField)
.focused($isFocusedTextField)
}
.scrollDisabled(true)
.contentMargins(.vertical, .zero)
Expand All @@ -37,7 +37,7 @@ struct NoteEditView: View {
.navigationBarTitleDisplayMode(.inline)
}
.task {
isFocusedNoteField = true
isFocusedTextField = true
}
}

Expand Down

0 comments on commit a208511

Please sign in to comment.