Skip to content

Commit

Permalink
Merge pull request #85 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Aug 24, 2024
2 parents 720f223 + eca2803 commit c18f8d9
Show file tree
Hide file tree
Showing 21 changed files with 555 additions and 134 deletions.
36 changes: 36 additions & 0 deletions Harmonie.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "2eeb86afc5727bde810cfe9658cb0153a0ffde99fcf6775df12b79c9ac590451",
"originHash" : "f0fb8ceb3ffd5128d02593ebef3a373aa7fe9597383061f9f65348fd33476726",
"pins" : [
{
"identity" : "async-swift-ui",
Expand Down Expand Up @@ -33,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SimplyDanny/SwiftLintPlugins",
"state" : {
"revision" : "9ad9487c2448b3f1265ea2cc8af246b9cae6878d",
"version" : "0.56.1"
"revision" : "6c3d6c32a37224179dc290f21e03d1238f3d963b",
"version" : "0.56.2"
}
},
{
Expand All @@ -52,7 +52,7 @@
"location" : "https://github.com/makinosp/vrckit",
"state" : {
"branch" : "develop",
"revision" : "eabad8f790cec60415c9e2b4565bffef21f3b283"
"revision" : "43f7122284ee3e34a997b6dd7ae2614dd1d0c8d9"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Components/ProgressScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
struct ProgressScreen: View {
var body: some View {
ZStack {
Color(UIColor.systemBackground)
Color(uiColor: .systemBackground)
ProgressView()
.controlSize(.large)
}
Expand Down
12 changes: 12 additions & 0 deletions harmonie/Extensions/URL+Identifiable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// URL+Identifiable.swift
// Harmonie
//
// Created by makinosp on 2024/08/23.
//

import Foundation

extension URL: Identifiable {
public var id: Int { hashValue }
}
2 changes: 1 addition & 1 deletion harmonie/Extensions/View+SectionModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private struct SectionModifier: ViewModifier {
.padding()
.background {
RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Color(UIColor.secondarySystemGroupedBackground))
.foregroundStyle(Color(uiColor: .secondarySystemGroupedBackground))
}
}
}
11 changes: 10 additions & 1 deletion harmonie/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
// Created by makinosp on 2024/07/22.
//

import Foundation
import SwiftUI

enum Constants {
enum Icon {
static var forward: some View {
Image(systemName: "chevron.forward")
.foregroundStyle(Color(uiColor: .systemGray))
.imageScale(.small)
}
}

enum IconSize {
static let thumbnail = CGSize(width: 28, height: 28)
static let thumbnailOutside = CGSize(width: 32, height: 32)
Expand All @@ -17,6 +25,7 @@ enum Constants {
enum IconName {
static let check = "checkmark"
static let circleFilled = "circle.fill"
static let dots = "ellipsis.circle"
static let exclamation = "exclamationmark.circle"
static let loctaion = "location.fill"
static let filter = "line.3.horizontal.decrease"
Expand Down
2 changes: 1 addition & 1 deletion harmonie/ViewModels/FavoriteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FavoriteViewModel: ObservableObject {
@Published var segment: Segment = .friend
let friendVM: FriendViewModel
let service: any FavoriteServiceProtocol

enum Segment {
case friend, world
}
Expand Down
26 changes: 26 additions & 0 deletions harmonie/ViewModels/ProfileEditViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ProfileEditViewModel.swift
// Harmonie
//
// Created by makinosp on 2024/08/23.
//

import Foundation
import VRCKit

class ProfileEditViewModel: ObservableObject {
@Published var editingUserInfo: EditableUserInfo
private let id: String

init(user: User) {
editingUserInfo = EditableUserInfo(detail: user)
id = user.id
}

func saveProfile(service: any UserServiceProtocol) async throws {
try await service.updateUser(
id: id,
editedInfo: editingUserInfo
)
}
}
39 changes: 19 additions & 20 deletions harmonie/Views/Authentication/AuthenticationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import AsyncSwiftUI
import VRCKit

struct AuthenticationView: View {
@EnvironmentObject var appVM: AppViewModel
@State var verifyType: VerifyType?
@State var username: String = ""
@State var password: String = ""
@State var code: String = ""
@State var isRunning = false
@EnvironmentObject private var appVM: AppViewModel
@State private var verifyType: VerifyType?
@State private var username: String = ""
@State private var password: String = ""
@State private var code: String = ""
@State private var isRequesting = false

var body: some View {
VStack(spacing: 16) {
Expand All @@ -34,57 +34,56 @@ struct AuthenticationView: View {
.ignoresSafeArea(.keyboard)
}

var usernamePasswordFields: some View {
private var usernamePasswordFields: some View {
VStack(spacing: 8) {
HStack {
Image(systemName: "at")
.foregroundStyle(Color.gray)
TextField("UserName", text: $username)
.textFieldStyle(RoundedBorderTextFieldStyle())
.textInputAutocapitalization(.never)
.textFieldStyle(.roundedBorder)
}
.padding(.horizontal, 8)
HStack {
Image(systemName: "lock")
.foregroundStyle(Color.gray)
SecureField("Password", text: $password)
.textFieldStyle(RoundedBorderTextFieldStyle())
.textFieldStyle(.roundedBorder)
}
.padding(.horizontal, 8)
}
}

var otpField: some View {
private var otpField: some View {
HStack {
Image(systemName: "ellipsis")
.foregroundStyle(Color.gray)
TextField("Code", text: $code)
.textFieldStyle(RoundedBorderTextFieldStyle())
.keyboardType(.decimalPad)
.textFieldStyle(.roundedBorder)
}
.padding(.horizontal, 8)
.background(
RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Color(UIColor.systemBackground))
.foregroundStyle(Color(uiColor: .systemBackground))
)
}

@ViewBuilder
func loginButton(
_ text: String,
_ action: @escaping () async -> Void
) -> some View {
private func loginButton(_ text: String, action: @escaping () async -> Void) -> some View {
AsyncButton {
isRunning = true
defer { isRequesting = false }
isRequesting = true
await action()
isRunning = false
} label: {
if isRunning {
if isRequesting {
ProgressView()
} else {
Text(text)
}
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.disabled(isRunning)
.disabled(isRequesting)
}
}
80 changes: 40 additions & 40 deletions harmonie/Views/Favorite/FavoritesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,59 @@ import VRCKit
struct FavoritesView: View {
@EnvironmentObject var favoriteVM: FavoriteViewModel
@State var selected: Selected?
@State var isFetching = false

var body: some View {
NavigationSplitView {
if !isFetching {
List {
ForEach(favoriteVM.favoriteFriendGroups) { group in
if let friends = favoriteVM.getFavoriteFriends(group.id) {
Section(header: Text(group.displayName)) {
ForEach(friends) { friend in
rowView(friend)
}
}
NavigationSplitView(columnVisibility: .constant(.all)) {
listView
} detail: {
Text("Select a friend")
}
.navigationSplitViewStyle(.balanced)
}

var listView: some View {
List {
ForEach(favoriteVM.favoriteFriendGroups) { group in
if let friends = favoriteVM.getFavoriteFriends(group.id) {
Section(header: Text(group.displayName)) {
ForEach(friends) { friend in
rowView(friend)
}
}
}
.sheet(item: $selected) { selected in
UserDetailPresentationView(id: selected.id)
.presentationDetents([.medium, .large])
.presentationBackground(Color(UIColor.systemGroupedBackground))
}
.toolbar {
ToolbarItem(placement: .principal) {
Picker("", selection: $favoriteVM.segment) {
ForEach(FavoriteViewModel.Segment.allCases) { segment in
Text(segment.description).tag(segment)
}
}
.pickerStyle(SegmentedPickerStyle())
}
}
.navigationDestination(item: $selected) { selected in
UserDetailPresentationView(id: selected.id)
}
.toolbar {
ToolbarItem(placement: .principal) {
Picker("", selection: $favoriteVM.segment) {
ForEach(FavoriteViewModel.Segment.allCases) { segment in
Text(segment.description).tag(segment)
}
}
.navigationTitle("Favorites")
} else {
ProgressScreen()
.navigationTitle("Favorites")
.pickerStyle(SegmentedPickerStyle())
}
} detail: {
EmptyView()
}
.navigationTitle("Favorites")
}

func rowView(_ friend: Friend) -> some View {
HStack {
CircleURLImage(
imageUrl: friend.thumbnailUrl,
size: Constants.IconSize.thumbnail
)
Text(friend.displayName)
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.onTapGesture {
Button {
selected = Selected(id: friend.id)
} label: {
HStack {
CircleURLImage(
imageUrl: friend.thumbnailUrl,
size: Constants.IconSize.thumbnail
)
Text(friend.displayName)
Spacer()
Constants.Icon.forward
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}
}
2 changes: 1 addition & 1 deletion harmonie/Views/Friend/FriendsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct FriendsView: View {
}
Text(friend.displayName)
Spacer()
Image(systemName: "chevron.right")
Constants.Icon.forward
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
Expand Down
4 changes: 2 additions & 2 deletions harmonie/Views/Location/LocationCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ struct LocationCardView: View {
var backGroundColor: Color {
switch UIDevice.current.userInterfaceIdiom {
case .pad:
Color(UIColor.tertiarySystemGroupedBackground)
Color(uiColor: .tertiarySystemGroupedBackground)
default:
Color(UIColor.secondarySystemGroupedBackground)
Color(uiColor: .secondarySystemGroupedBackground)
}
}

Expand Down
4 changes: 2 additions & 2 deletions harmonie/Views/Location/LocationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ struct LocationsView: View {
var backGroundColor: Color {
switch UIDevice.current.userInterfaceIdiom {
case .pad:
Color(UIColor.secondarySystemGroupedBackground)
Color(uiColor: .secondarySystemGroupedBackground)
default:
Color(UIColor.systemGroupedBackground)
Color(uiColor: .systemGroupedBackground)
}
}

Expand Down
40 changes: 40 additions & 0 deletions harmonie/Views/Setting/Profile/LanguagePickerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// LanguagePickerView.swift
// Harmonie
//
// Created by makinosp on 2024/08/23.
//

import SwiftUI
import VRCKit

struct LanguagePickerView: View {
@Environment(\.dismiss) private var dismiss
@Binding var selectedLanguage: LanguageTag?

var body: some View {
NavigationStack {
Form {
ForEach(LanguageTag.allCases) { languageTag in
Button {
selectedLanguage = languageTag
dismiss()
} label: {
Text(languageTag.description)
}
}
}
.navigationTitle("Languages")
.toolbarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Text("Cancel")
}
}
}
}
}
}
Loading

0 comments on commit c18f8d9

Please sign in to comment.