diff --git a/RepeatCooking.xcodeproj/project.pbxproj b/RepeatCooking.xcodeproj/project.pbxproj index 47a4c1d..72b2259 100644 --- a/RepeatCooking.xcodeproj/project.pbxproj +++ b/RepeatCooking.xcodeproj/project.pbxproj @@ -26,6 +26,9 @@ 1186603725FAD70900A32B3A /* Data+Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1186603625FAD70900A32B3A /* Data+Image.swift */; }; 1186604E25FE9FE400A32B3A /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1186604D25FE9FE300A32B3A /* Color.swift */; }; 1186606325FEE76600A32B3A /* RepeatCooking.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1186606125FEE76600A32B3A /* RepeatCooking.xcdatamodeld */; }; + 11A9F42B268F396E00FA1CB0 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11A9F42A268F396E00FA1CB0 /* Font.swift */; }; + 11A9F42D268F39CC00FA1CB0 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11A9F42C268F39CC00FA1CB0 /* Padding.swift */; }; + 11A9F430268F3AEF00FA1CB0 /* Hidden.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11A9F42F268F3AEF00FA1CB0 /* Hidden.swift */; }; 11B4CC9625F7C0CA000843FB /* AVFoundationVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B4CC9525F7C0CA000843FB /* AVFoundationVM.swift */; }; 11B4CCC725F7D07E000843FB /* CameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B4CCC625F7D07E000843FB /* CameraView.swift */; }; 11B4CCCD25F7EC94000843FB /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B4CCCC25F7EC94000843FB /* UIApplication.swift */; }; @@ -79,6 +82,9 @@ 1186603625FAD70900A32B3A /* Data+Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Image.swift"; sourceTree = ""; }; 1186604D25FE9FE300A32B3A /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 1186606225FEE76600A32B3A /* RepeatCooking.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = RepeatCooking.xcdatamodel; sourceTree = ""; }; + 11A9F42A268F396E00FA1CB0 /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = ""; }; + 11A9F42C268F39CC00FA1CB0 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = ""; }; + 11A9F42F268F3AEF00FA1CB0 /* Hidden.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hidden.swift; sourceTree = ""; }; 11B4CC9525F7C0CA000843FB /* AVFoundationVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVFoundationVM.swift; sourceTree = ""; }; 11B4CCC625F7D07E000843FB /* CameraView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraView.swift; sourceTree = ""; }; 11B4CCCC25F7EC94000843FB /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = ""; }; @@ -139,6 +145,7 @@ 1108334E25F0169600903FE3 /* RepeatCooking */ = { isa = PBXGroup; children = ( + 11A9F42E268F3AD300FA1CB0 /* Modifier */, 110965AC2609BE880059C6A7 /* Fonts */, 1186606025FEE73E00A32B3A /* DB */, 11B4CCED25F9D2FC000843FB /* Model */, @@ -219,6 +226,14 @@ path = Components; sourceTree = ""; }; + 11A9F42E268F3AD300FA1CB0 /* Modifier */ = { + isa = PBXGroup; + children = ( + 11A9F42F268F3AEF00FA1CB0 /* Hidden.swift */, + ); + path = Modifier; + sourceTree = ""; + }; 11B4CCCB25F7EC70000843FB /* Extensions */ = { isa = PBXGroup; children = ( @@ -228,6 +243,8 @@ 1186603625FAD70900A32B3A /* Data+Image.swift */, 1186604D25FE9FE300A32B3A /* Color.swift */, 110965A72609B4C50059C6A7 /* TextFont.swift */, + 11A9F42A268F396E00FA1CB0 /* Font.swift */, + 11A9F42C268F39CC00FA1CB0 /* Padding.swift */, ); path = Extensions; sourceTree = ""; @@ -439,6 +456,7 @@ 11B4CC9625F7C0CA000843FB /* AVFoundationVM.swift in Sources */, 1108335025F0169600903FE3 /* AppDelegate.swift in Sources */, 11865FEC25FAB4E600A32B3A /* HomeViewItem.swift in Sources */, + 11A9F42D268F39CC00FA1CB0 /* Padding.swift in Sources */, 1186606325FEE76600A32B3A /* RepeatCooking.xcdatamodeld in Sources */, 1186603725FAD70900A32B3A /* Data+Image.swift in Sources */, 11F3B30525F4466C00CE638F /* TextView.swift in Sources */, @@ -446,8 +464,10 @@ 1185038F25F3CE05004A31A3 /* EditStore.swift in Sources */, 11B4CCE925F9D247000843FB /* HomeView.swift in Sources */, 110965A82609B4C50059C6A7 /* TextFont.swift in Sources */, + 11A9F430268F3AEF00FA1CB0 /* Hidden.swift in Sources */, 115DA841260D9C88001E50EF /* LongTouchGestureView.swift in Sources */, 1186603225FAD57A00A32B3A /* CookItem.swift in Sources */, + 11A9F42B268F396E00FA1CB0 /* Font.swift in Sources */, 1108335225F0169600903FE3 /* SceneDelegate.swift in Sources */, 11B4CCEF25F9D30C000843FB /* Model.swift in Sources */, 1186604E25FE9FE400A32B3A /* Color.swift in Sources */, diff --git a/RepeatCooking.xcodeproj/project.xcworkspace/xcuserdata/tachiyoshiki.xcuserdatad/UserInterfaceState.xcuserstate b/RepeatCooking.xcodeproj/project.xcworkspace/xcuserdata/tachiyoshiki.xcuserdatad/UserInterfaceState.xcuserstate index f4993ab..eb19986 100644 Binary files a/RepeatCooking.xcodeproj/project.xcworkspace/xcuserdata/tachiyoshiki.xcuserdatad/UserInterfaceState.xcuserstate and b/RepeatCooking.xcodeproj/project.xcworkspace/xcuserdata/tachiyoshiki.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/RepeatCooking/AppDelegate.swift b/RepeatCooking/AppDelegate.swift index ca77f66..59b7f9a 100644 --- a/RepeatCooking/AppDelegate.swift +++ b/RepeatCooking/AppDelegate.swift @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let container = NSPersistentContainer(name: "RepeatCooking") container.loadPersistentStores(completionHandler: { (_, error) in if let error = error as NSError? { - print(error.localizedDescription) + fatalError(error.localizedDescription) } }) return container @@ -36,11 +36,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) - } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - } } diff --git a/RepeatCooking/Components/Camera/CameraView.swift b/RepeatCooking/Components/Camera/CameraView.swift index cc58e87..9d649c1 100644 --- a/RepeatCooking/Components/Camera/CameraView.swift +++ b/RepeatCooking/Components/Camera/CameraView.swift @@ -19,8 +19,7 @@ struct CameraView: View { HStack { Button(action: { self.isActive.toggle() - }) { - Text("キャンセル") + }) { Text("キャンセル") } .frame(width: 80, height: 80, alignment: .leading) Spacer() diff --git a/RepeatCooking/ContentView.swift b/RepeatCooking/ContentView.swift index 5b2972a..f3dd315 100644 --- a/RepeatCooking/ContentView.swift +++ b/RepeatCooking/ContentView.swift @@ -9,7 +9,7 @@ import SwiftUI struct ContentView: View { var body: some View { - HomeView() + HomeView(action: { print("tap") }) } } diff --git a/RepeatCooking/Extensions/Color.swift b/RepeatCooking/Extensions/Color.swift index 299d935..048d961 100644 --- a/RepeatCooking/Extensions/Color.swift +++ b/RepeatCooking/Extensions/Color.swift @@ -3,8 +3,6 @@ // RepeatCooking // // Created by tiking on 2021/03/15. -// - import Foundation import SwiftUI @@ -12,6 +10,7 @@ extension UIColor { static let lightOrange = UIColor(red: 255/255, green: 249/255, blue: 249/255, alpha: 1) } +// test color enum ColorAssets { case lightOrange var name: String { diff --git a/RepeatCooking/Extensions/Data+Image.swift b/RepeatCooking/Extensions/Data+Image.swift index 8c841f8..d4fb2a3 100644 --- a/RepeatCooking/Extensions/Data+Image.swift +++ b/RepeatCooking/Extensions/Data+Image.swift @@ -1,10 +1,3 @@ -// -// Data+Image.swift -// RepeatCooking -// -// Created by tiking on 2021/03/12. -// - import Foundation import UIKit diff --git a/RepeatCooking/Extensions/Date.swift b/RepeatCooking/Extensions/Date.swift index 431a0ca..bfbda55 100644 --- a/RepeatCooking/Extensions/Date.swift +++ b/RepeatCooking/Extensions/Date.swift @@ -1,10 +1,3 @@ -// -// Date.swift -// RepeatCooking -// -// Created by tiking on 2021/03/11. -// - import Foundation private var formatter: DateFormatter { diff --git a/RepeatCooking/Extensions/Font.swift b/RepeatCooking/Extensions/Font.swift new file mode 100644 index 0000000..74e0366 --- /dev/null +++ b/RepeatCooking/Extensions/Font.swift @@ -0,0 +1,38 @@ +import SwiftUI + +extension Font { + + /// 24px, Bold + static let h1 = Font.system(size: 24, weight: .semibold) + + /// 22px, Bold + static let h2 = Font.system(size: 22, weight: .semibold) + + /// 18px, Bold + static let h3 = Font.system(size: 18, weight: .semibold) + + /// 16px, Bold + static let h4 = Font.system(size: 16, weight: .semibold) + + /// 16px + static let body = Font.system(size: 16) + + /// 15px + static let subtitle = Font.system(size: 15) + + /// 14px + static let body2 = Font.system(size: 14) + + /// 13px + static let subtitle2 = Font.system(size: 13) + + /// 12px + static let caption = Font.system(size: 12) + + /// 10px + static let caption2 = Font.system(size: 10) + + // 15px, Bold + static let button = Font.system(size: 15, weight: .semibold) +} + diff --git a/RepeatCooking/Extensions/Keyboard.swift b/RepeatCooking/Extensions/Keyboard.swift index 291f0bf..8054b5d 100644 --- a/RepeatCooking/Extensions/Keyboard.swift +++ b/RepeatCooking/Extensions/Keyboard.swift @@ -1,10 +1,5 @@ // // Keyboard.swift -// RepeatCooking -// -// Created by tiking on 2021/03/11. -// - import Combine import SwiftUI diff --git a/RepeatCooking/Extensions/Padding.swift b/RepeatCooking/Extensions/Padding.swift new file mode 100644 index 0000000..66eb071 --- /dev/null +++ b/RepeatCooking/Extensions/Padding.swift @@ -0,0 +1,55 @@ +import SwiftUI + +enum Padding { + /// 32px + static let XXL: CGFloat = 32 + + /// 24px + static let XL: CGFloat = 24 + + /// 16px + static let L: CGFloat = 16 + + /// 12px + static let M: CGFloat = 12 + + /// 8px + static let S: CGFloat = 8 + + /// 4px + static let XS: CGFloat = 4 + + /// 0ox + static let Zero: CGFloat = 0 +} + +enum ButtonSize { + case slim, medium, large +} + +extension Padding { + static func buttonEdgeInsets(from size: ButtonSize) -> EdgeInsets { + var horizontal: CGFloat { + switch size { + case .slim: + return 12 + case .medium: + return 16 + case .large: + return 20 + } + } + var vertical: CGFloat { + switch size { + case .slim: + return 8 + case .medium: + return 12 + case .large: + return 16 + } + } + return EdgeInsets(top: vertical, leading: horizontal, bottom: vertical, trailing: horizontal) + } +} + diff --git a/RepeatCooking/Extensions/TextFont.swift b/RepeatCooking/Extensions/TextFont.swift index c316dc2..6e49944 100644 --- a/RepeatCooking/Extensions/TextFont.swift +++ b/RepeatCooking/Extensions/TextFont.swift @@ -1,10 +1,3 @@ -// -// TextFont.swift -// RepeatCooking -// -// Created by tiking on 2021/03/23. -// - import SwiftUI extension Text { diff --git a/RepeatCooking/Extensions/UIApplication.swift b/RepeatCooking/Extensions/UIApplication.swift index e228259..c6d77f4 100644 --- a/RepeatCooking/Extensions/UIApplication.swift +++ b/RepeatCooking/Extensions/UIApplication.swift @@ -1,11 +1,5 @@ -// -// UIApplication.swift -// RepeatCooking -// -// Created by tiking on 2021/03/10. -// - import SwiftUI + extension UIApplication { func closeKeyboard() { sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) diff --git a/RepeatCooking/Home/HomeView.swift b/RepeatCooking/Home/HomeView.swift index 1972482..dfcd912 100644 --- a/RepeatCooking/Home/HomeView.swift +++ b/RepeatCooking/Home/HomeView.swift @@ -15,6 +15,7 @@ struct HomeView: View { @State var flag = false @State var isRemove = false @StateObject private var model = SendModelRequest() + let action: () -> Void var body: some View { ZStack { @@ -44,10 +45,9 @@ struct HomeView: View { } Spacer() ScrollView { - ForEach(cookItems) { - item in + ForEach(cookItems) { item in ZStack { - Button(action: {}) { + Button(action: action) { HomeViewItem(image: item.image.toImage(), dateString: item.cookedAt, text2: item.text, callback: { print("completed") } ) } @@ -80,9 +80,3 @@ struct HomeView: View { } } } - -struct StoreView_Previews: PreviewProvider { - static var previews: some View { - HomeView() - } -} diff --git a/RepeatCooking/Home/HomeViewItem.swift b/RepeatCooking/Home/HomeViewItem.swift index ecdb67e..ba855ef 100644 --- a/RepeatCooking/Home/HomeViewItem.swift +++ b/RepeatCooking/Home/HomeViewItem.swift @@ -60,9 +60,3 @@ struct HomeViewItem: View { .padding(EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)) } } - -struct HomeViewItem_Previews: PreviewProvider { - static var previews: some View { - HomeViewItem(image: UIImage(imageLiteralResourceName: "Camera"), dateString: Date().string, text2: "クッキー", callback: { print("test") }) - } -} diff --git a/RepeatCooking/Modifier/Hidden.swift b/RepeatCooking/Modifier/Hidden.swift new file mode 100644 index 0000000..8d2c334 --- /dev/null +++ b/RepeatCooking/Modifier/Hidden.swift @@ -0,0 +1,11 @@ +import SwiftUI + +extension View { + @ViewBuilder func isHidden(_ isHidden: Bool) -> some View { + if isHidden { + hidden() + } else { + self + } + } +}