Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions NativeAppTemplate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -925,6 +927,8 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -937,7 +941,7 @@
BUNDLE_ID_SUFFIX = .dev;
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
DEVELOPMENT_TEAM = NNYDL5U3V3;
ENABLE_PREVIEWS = YES;
Expand All @@ -950,15 +954,15 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.nativeapptemplate.NativeAppTemplate.ios$(BUNDLE_ID_SUFFIX)";
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.nativeapptemplate.NativeAppTemplateFree.ios;
PRODUCT_NAME = NativeAppTemplate;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -971,7 +975,7 @@
BUNDLE_ID_SUFFIX = "";
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
DEVELOPMENT_TEAM = NNYDL5U3V3;
ENABLE_PREVIEWS = YES;
Expand All @@ -984,15 +988,15 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.nativeapptemplate.NativeAppTemplate.ios$(BUNDLE_ID_SUFFIX)";
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.nativeapptemplate.NativeAppTemplateFree.ios;
PRODUCT_NAME = NativeAppTemplate;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -1053,6 +1057,8 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
VALIDATE_PRODUCT = YES;
};
name = Beta;
Expand All @@ -1065,7 +1071,7 @@
BUNDLE_ID_SUFFIX = .beta;
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
DEVELOPMENT_TEAM = NNYDL5U3V3;
ENABLE_PREVIEWS = YES;
Expand All @@ -1078,14 +1084,14 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.nativeapptemplate.NativeAppTemplate.ios$(BUNDLE_ID_SUFFIX)";
PRODUCT_NAME = NativeAppTemplate;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Beta;
Expand Down
36 changes: 2 additions & 34 deletions NativeAppTemplate/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ struct App {
private var dataManager: DataManager
private var messageBus: MessageBus

init() {
@MainActor init() {
// setup objects
let nativeAppTemplateObjects = App.objects
loginRepository = nativeAppTemplateObjects.loginRepository
sessionController = nativeAppTemplateObjects.sessionController
dataManager = nativeAppTemplateObjects.dataManager
messageBus = nativeAppTemplateObjects.messageBus

// configure ui
customizeNavigationBar()
customizeTableView()
customizeControls()

try? Tips.configure()
}
}
Expand All @@ -62,7 +57,7 @@ extension App: SwiftUI.App {
// MARK: - internal
extension App {
// Initialise the database
static var objects: Objects {
@MainActor static var objects: Objects {
let loginRepository = LoginRepository()
let sessionController = SessionController(loginRepository: loginRepository)
let messageBus = MessageBus()
Expand All @@ -77,30 +72,3 @@ extension App {
)
}
}

// MARK: - private
private extension App {
func customizeNavigationBar() {
UINavigationBar.appearance().backgroundColor = .backgroundUiColor

UINavigationBar.appearance().largeTitleTextAttributes = [
.foregroundColor: UIColor(named: "titleText")!,
.font: UIFont.uiLargeTitle
]
UINavigationBar.appearance().titleTextAttributes = [
.foregroundColor: UIColor(named: "titleText")!,
.font: UIFont.uiHeadline
]
}

func customizeTableView() {
UITableView.appearance().separatorColor = .clear
UITableViewCell.appearance().backgroundColor = .backgroundUiColor
UITableViewCell.appearance().selectionStyle = .none
UITableView.appearance().backgroundColor = .backgroundUiColor
}

func customizeControls() {
UISwitch.appearance().onTintColor = .accent
}
}
2 changes: 1 addition & 1 deletion NativeAppTemplate/Data/DataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import SwiftUI

@Observable class DataManager {
@MainActor @Observable class DataManager {

// MARK: - Properties
// Initialiser Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Daisuke Adachi on 2023/02/25.
//

class AccountPasswordRepository {
@MainActor class AccountPasswordRepository {
let accountPasswordService: AccountPasswordService

init(
Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/Data/Repositories/ShopRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import SwiftUI

@Observable class ShopRepository {
@MainActor @Observable class ShopRepository {
let shopsService: ShopsService

var shops: [Shop] = []
Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/Login/LoginRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

@Observable public class LoginRepository {
@MainActor @Observable public class LoginRepository {
// MARK: - Properties
private var _currentShopkeeper: Shopkeeper?

Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/Login/SignUpRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

class SignUpRepository {
@MainActor class SignUpRepository {
func signUp(signUp: SignUp) async throws -> Shopkeeper {
var shopkeeper: Shopkeeper

Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/Models/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct Shop: Codable, Identifiable {
struct Shop: Codable, Identifiable, Sendable {
var id: String
var name: String
var description: String
Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/Models/Shopkeeper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public struct Shopkeeper: Hashable, Codable {
public struct Shopkeeper: Hashable, Codable, Sendable {

// MARK: - Properties
var id: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ public class LoggedInShopkeeper: NSObject, NSCoding, NSSecureCoding {
)
}

public static var supportsSecureCoding = true
public static let supportsSecureCoding = true
}
6 changes: 3 additions & 3 deletions NativeAppTemplate/Sessions/SessionController+States.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
import struct Foundation.Date

extension SessionController {
enum UserState {
enum UserState: Sendable {
case loggedIn
case loggingIn
case notLoggedIn
}

enum SessionState {
enum SessionState: Sendable {
case unknown
case online
case offline
}

enum PermissionState: Equatable {
enum PermissionState: Equatable, Sendable {
case notLoaded
case loading
case loaded
Expand Down
34 changes: 18 additions & 16 deletions NativeAppTemplate/Sessions/SessionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Foundation
import Network
import Observation

@Observable class SessionController {
@MainActor @Observable class SessionController {
// Managing the state of the current session
private(set) var sessionState: SessionState = .unknown
private(set) var userState: UserState = .notLoggedIn
Expand Down Expand Up @@ -98,7 +98,7 @@ import Observation
prepareConnectionMonitor()
}

@MainActor func login(email: String, password: String) async throws {
func login(email: String, password: String) async throws {
guard userState != .loggingIn else { return }

userState = .loggingIn
Expand Down Expand Up @@ -127,7 +127,7 @@ import Observation
}
}

@MainActor func logout() async throws {
func logout() async throws {
do {
shouldPopToRootView = true
try await loginRepository.logout(networkClient: client)
Expand Down Expand Up @@ -169,7 +169,7 @@ import Observation

permissionState = .loading

Task { @MainActor in
Task {
do {
let prmissionsResponse = try await permissionsService.allPermissions()

Expand Down Expand Up @@ -228,18 +228,20 @@ import Observation

private func prepareConnectionMonitor() {
connectionMonitor.pathUpdateHandler = { [weak self] path in
guard let self = self else { return }

let newState: SessionState = path.status == .satisfied ? .online : .offline

if newState != self.sessionState {
self.sessionState = newState
}

if didFetchPermissions {
self.fetchPermissionsIfNeeded()
} else {
self.fetchPermissions()
Task { @MainActor in
guard let self = self else { return }

let newState: SessionState = path.status == .satisfied ? .online : .offline

if newState != self.sessionState {
self.sessionState = newState
}

if self.didFetchPermissions {
self.fetchPermissionsIfNeeded()
} else {
self.fetchPermissions()
}
}
}
connectionMonitor.start(queue: .main)
Expand Down
2 changes: 1 addition & 1 deletion NativeAppTemplate/UI/App Root/AppTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct AppTabView_Previews: PreviewProvider {
}

// MARK: - private
private func tab<Content: View>(
@MainActor private func tab<Content: View>(
content: @escaping () -> Content,
navigationPath: Binding<NavigationPath>?,
text: String,
Expand Down
8 changes: 6 additions & 2 deletions NativeAppTemplate/UI/Shared/MainButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ struct MainButtonView: View {
.stroke(type.color, lineWidth: 2)
)
.onPreferenceChange(SizeKey.self) { size in
height = size?.height
Task { @MainActor in
height = size?.height
}
}
}
}
Expand Down Expand Up @@ -163,7 +165,9 @@ struct MainButtonImageView: View {
.stroke(type.color, lineWidth: 2)
)
.onPreferenceChange(SizeKey.self) { size in
height = size?.height
Task { @MainActor in
height = size?.height
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions NativeAppTemplate/UI/Shop Detail/ShopDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI
import TipKit

struct ShopDetailView {
struct ShopDetailView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.mainTab) private var mainTab
@Environment(TabViewModel.self) private var tabViewModel
Expand All @@ -35,7 +35,7 @@ struct ShopDetailView {
}

// MARK: - View
extension ShopDetailView: View {
extension ShopDetailView {
var body: some View {
contentView
.onAppear {
Expand Down Expand Up @@ -97,7 +97,7 @@ private extension ShopDetailView {
}

private func fetchShopDetail() {
Task { @MainActor in
Task {
isFetching = true

do {
Expand Down
Loading
Loading