diff --git a/.DS_Store b/.DS_Store index 1e2f90a..0bae43a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/5l_ChukarkovKonstantin.playground/Contents.swift b/5l_ChukarkovKonstantin.playground/Contents.swift deleted file mode 100644 index f95aa9e..0000000 --- a/5l_ChukarkovKonstantin.playground/Contents.swift +++ /dev/null @@ -1,204 +0,0 @@ -import UIKit - -enum ChangeIgnition: String { - case start = "запущен" - case stop = "заглушен" -} - -enum ChangeWidows: String { - case open = "открыты" - case close = "закрыты" -} - - -protocol Car { - - - var model: String { get set } - var age: Int { get set } - var ignition: ChangeIgnition { get set } - var windows: ChangeWidows { get set } - - mutating func changeIgnition() - mutating func changeWidows() -} - - -extension Car { - - - - mutating func changeIgnition(properties: ChangeIgnition) { - switch properties { - case .start: self.ignition = .start - print("У \(self.model) двигатель \(self.ignition.rawValue)") - case .stop: self.ignition = .stop - print("У \(self.model) двигатель \(self.ignition.rawValue)") - } - } - - mutating func changeWidows(properties: ChangeWidows) { - switch properties { - case .open: self.windows = .open - print("У \(self.model) окна \(self.windows.rawValue)") - case .close: self.windows = .close - print("У \(self.model) окна \(self.windows.rawValue)") - } - } -} - -class TrunkCar: Car { - - func changeWidows() { - } - - func changeIgnition() { - } - - - var model: String = "" - var age: Int = 0 - var ignition: ChangeIgnition = .stop - var windows: ChangeWidows = .close - - enum TypeCar: String { - case sport = "Спортивной" - case truck = "Грузовой" - } - - - let type: TypeCar = .truck - - var bootVolume: Int - - - init(model: String, age: Int, bootVolume: Int) { - self.bootVolume = bootVolume - self.model = model - self.age = age - } - - var trunkVolume: Int = 0 - - enum ChangeTrunkStatus { - case load - case upload - } - - func changeTrunkVolume(act: ChangeTrunkStatus,trunkVolume: Int) { - switch act { - case .load: - self.trunkVolume += trunkVolume - if self.trunkVolume > self.bootVolume { - let unnecessary = self.trunkVolume - self.bootVolume - self.trunkVolume = self.bootVolume - print("Ошибка, слишком большой объем пытаетесь загрузить. Объем багажа \(self.model) заполнен на максимум: \(self.trunkVolume)/\(self.bootVolume) и осталось незагруженно: \(unnecessary)") - } - else { - print("Погрузка в \(self.model) прошла успешна, багажник заполнен на \(self.trunkVolume) из \(self.bootVolume)") - } - case .upload: - self.trunkVolume -= trunkVolume - if self.trunkVolume < 0 { - self.trunkVolume += trunkVolume - print("Ошибка, из \(self.model) невозможно выгрузить \(trunkVolume) литров, там всего \(self.trunkVolume) литров") - } - else { - print("Выгрузка из \(self.model) прошла успешна, багажник заполнен на \(self.trunkVolume) из \(self.bootVolume)") - } - } - } - -} - -extension TrunkCar: CustomStringConvertible { - var description: String { - return "Марка \(self.type.rawValue) машины: \(self.model), год выпуска: \(self.age), объем багажника: \(self.trunkVolume)/\(self.bootVolume) литров, двигатель \(self.ignition.rawValue), окна \(self.windows.rawValue)" - } -} - - -class SportCar: Car { - func changeWidows() { - } - - func changeIgnition() { - } - - enum TypeCar: String { - case sport = "Спортивной" - case truck = "Грузовой" - } - - var model: String = "" - var age: Int = 0 - var ignition: ChangeIgnition = .stop - var windows: ChangeWidows = .close - - let type: TypeCar = .sport - - var topNitro: Int - - var nitro: Int = 0 - - init(model: String, age: Int, topNitro: Int) { - self.topNitro = topNitro - self.nitro = topNitro - self.model = model - self.age = age - } - - - enum ChangeNitro { - case refill - case use - } - - func changeNitro(act: ChangeNitro, nitro: Int) { - switch act { - case .refill: - self.nitro += nitro - if self.nitro > self.topNitro { - let unnecessary = self.nitro - self.topNitro - self.nitro = self.topNitro - print("Ошибка, слишком большой объем пытаетесь загрузить. Бак нитро \(self.model) заполнен на максимум: \(self.nitro)/\(self.topNitro) литров, и осталось незагруженно: \(unnecessary)") - } - else { - print("Добавка нитро в \(self.model) прошла успешна, бак нитро заполнен на \(self.nitro) из \(self.topNitro)") - } - case .use: - self.nitro -= nitro - if self.nitro < 0 { - self.nitro += nitro - print("Ошибка, \(self.model) не может использовать \(nitro) литров, там всего \(self.nitro) литров") - } - else { - print("Использование \(self.model) нитро прошла успешна, бак нитро заполнен на \(self.nitro) из \(self.topNitro)") - } - } - } -} - -extension SportCar: CustomStringConvertible { -var description: String { - return "Марка \(self.type.rawValue) машины: \(self.model), год выпуска: \(self.age), бак нитро: \(self.nitro)/\(self.topNitro) литров, двигатель \(self.ignition.rawValue), окна \(self.windows.rawValue)" - } -} - -var ladaLargus = TrunkCar(model: "Lada Largus", age: 2014, bootVolume: 560) -var mazda = SportCar(model: "Mazda", age: 2009, topNitro: 5) -var largus = TrunkCar(model: "Lada", age: 2007, bootVolume: 350) -var mazda3 = SportCar(model: "Mazda 3", age: 2018, topNitro: 10) - -print(ladaLargus.description) -print(mazda3.description) -ladaLargus.changeTrunkVolume(act: .load, trunkVolume: 300) -print(ladaLargus.description) -mazda3.changeNitro(act: .use, nitro: 5) -mazda3.changeNitro(act: .refill, nitro: 7) -largus.changeWidows(properties: .open) -mazda.changeIgnition(properties: .start) -largus.changeTrunkVolume(act: .load, trunkVolume: 400) -mazda.changeNitro(act: .use, nitro: 3) -print(ladaLargus.description) -print(mazda.description) diff --git a/5l_ChukarkovKonstantin.playground/contents.xcplayground b/5l_ChukarkovKonstantin.playground/contents.xcplayground deleted file mode 100644 index 5da2641..0000000 --- a/5l_ChukarkovKonstantin.playground/contents.xcplayground +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/6l_ChukarkovKonstantin.playground/Contents.swift b/6l_ChukarkovKonstantin.playground/Contents.swift deleted file mode 100644 index d8b0348..0000000 --- a/6l_ChukarkovKonstantin.playground/Contents.swift +++ /dev/null @@ -1,45 +0,0 @@ - -struct Stack { - - var items = [Element]() - mutating func push(_ item: Element) { - items.append(item) - } - - mutating func pop() -> Element { - return items.removeLast() - } - - mutating func append(_ item: Element) { - self.push(item) - } - - - var count: Int { - return items.count - } - - subscript(i: Int) -> Element? { - if i < items.count { - return items[i] - } - return nil - } - -} - - -var stack = Stack() - -stack.push("кот") -stack.push("бегемот") -stack.push("жираф") -stack.push("крыса") - -stack.pop() - -print(stack.count) - - -print(stack[1]!) -print(stack[4] as Any) diff --git a/6l_ChukarkovKonstantin.playground/contents.xcplayground b/6l_ChukarkovKonstantin.playground/contents.xcplayground deleted file mode 100644 index 5da2641..0000000 --- a/6l_ChukarkovKonstantin.playground/contents.xcplayground +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/README.md b/README.md index 7415f74..6382685 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# swiftFirstLesson \ No newline at end of file +# swiftFirstLesson +add 6-l diff --git a/Weather/Weather.xcodeproj/project.pbxproj b/Weather/Weather.xcodeproj/project.pbxproj new file mode 100644 index 0000000..19db2a6 --- /dev/null +++ b/Weather/Weather.xcodeproj/project.pbxproj @@ -0,0 +1,359 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + B5788752249F8FF600D1AE9F /* AllCitiesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5788751249F8FF600D1AE9F /* AllCitiesTableViewController.swift */; }; + B5788754249F90D100D1AE9F /* AllCitiesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5788753249F90D100D1AE9F /* AllCitiesCell.swift */; }; + B5788756249F93A100D1AE9F /* MyCitiesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5788755249F93A100D1AE9F /* MyCitiesTableViewController.swift */; }; + B5788758249FA4D300D1AE9F /* WeatherCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5788757249FA4D300D1AE9F /* WeatherCollectionViewController.swift */; }; + B578875A249FA5D700D1AE9F /* WeatherCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5788759249FA5D700D1AE9F /* WeatherCell.swift */; }; + B59D61CB2497F55E00E3411A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59D61CA2497F55E00E3411A /* AppDelegate.swift */; }; + B59D61CF2497F55E00E3411A /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59D61CE2497F55E00E3411A /* LoginViewController.swift */; }; + B59D61D22497F55E00E3411A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B59D61D02497F55E00E3411A /* Main.storyboard */; }; + B59D61D42497F56100E3411A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B59D61D32497F56100E3411A /* Assets.xcassets */; }; + B59D61D72497F56100E3411A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B59D61D52497F56100E3411A /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B5788751249F8FF600D1AE9F /* AllCitiesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllCitiesTableViewController.swift; sourceTree = ""; }; + B5788753249F90D100D1AE9F /* AllCitiesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllCitiesCell.swift; sourceTree = ""; }; + B5788755249F93A100D1AE9F /* MyCitiesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCitiesTableViewController.swift; sourceTree = ""; }; + B5788757249FA4D300D1AE9F /* WeatherCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherCollectionViewController.swift; sourceTree = ""; }; + B5788759249FA5D700D1AE9F /* WeatherCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherCell.swift; sourceTree = ""; }; + B59D61C72497F55E00E3411A /* Weather.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Weather.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B59D61CA2497F55E00E3411A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B59D61CE2497F55E00E3411A /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; + B59D61D12497F55E00E3411A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B59D61D32497F56100E3411A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B59D61D62497F56100E3411A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + B59D61D82497F56100E3411A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B59D61C42497F55E00E3411A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B59D61BE2497F55E00E3411A = { + isa = PBXGroup; + children = ( + B59D61C92497F55E00E3411A /* Weather */, + B59D61C82497F55E00E3411A /* Products */, + ); + sourceTree = ""; + }; + B59D61C82497F55E00E3411A /* Products */ = { + isa = PBXGroup; + children = ( + B59D61C72497F55E00E3411A /* Weather.app */, + ); + name = Products; + sourceTree = ""; + }; + B59D61C92497F55E00E3411A /* Weather */ = { + isa = PBXGroup; + children = ( + B59D61CA2497F55E00E3411A /* AppDelegate.swift */, + B59D61CE2497F55E00E3411A /* LoginViewController.swift */, + B5788751249F8FF600D1AE9F /* AllCitiesTableViewController.swift */, + B5788753249F90D100D1AE9F /* AllCitiesCell.swift */, + B5788755249F93A100D1AE9F /* MyCitiesTableViewController.swift */, + B5788757249FA4D300D1AE9F /* WeatherCollectionViewController.swift */, + B5788759249FA5D700D1AE9F /* WeatherCell.swift */, + B59D61D02497F55E00E3411A /* Main.storyboard */, + B59D61D32497F56100E3411A /* Assets.xcassets */, + B59D61D52497F56100E3411A /* LaunchScreen.storyboard */, + B59D61D82497F56100E3411A /* Info.plist */, + ); + path = Weather; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B59D61C62497F55E00E3411A /* Weather */ = { + isa = PBXNativeTarget; + buildConfigurationList = B59D61DB2497F56100E3411A /* Build configuration list for PBXNativeTarget "Weather" */; + buildPhases = ( + B59D61C32497F55E00E3411A /* Sources */, + B59D61C42497F55E00E3411A /* Frameworks */, + B59D61C52497F55E00E3411A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Weather; + productName = Weather; + productReference = B59D61C72497F55E00E3411A /* Weather.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B59D61BF2497F55E00E3411A /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1150; + LastUpgradeCheck = 1150; + ORGANIZATIONNAME = Konstantin; + TargetAttributes = { + B59D61C62497F55E00E3411A = { + CreatedOnToolsVersion = 11.5; + }; + }; + }; + buildConfigurationList = B59D61C22497F55E00E3411A /* Build configuration list for PBXProject "Weather" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B59D61BE2497F55E00E3411A; + productRefGroup = B59D61C82497F55E00E3411A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B59D61C62497F55E00E3411A /* Weather */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B59D61C52497F55E00E3411A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B59D61D72497F56100E3411A /* LaunchScreen.storyboard in Resources */, + B59D61D42497F56100E3411A /* Assets.xcassets in Resources */, + B59D61D22497F55E00E3411A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B59D61C32497F55E00E3411A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B5788756249F93A100D1AE9F /* MyCitiesTableViewController.swift in Sources */, + B5788754249F90D100D1AE9F /* AllCitiesCell.swift in Sources */, + B59D61CF2497F55E00E3411A /* LoginViewController.swift in Sources */, + B5788758249FA4D300D1AE9F /* WeatherCollectionViewController.swift in Sources */, + B59D61CB2497F55E00E3411A /* AppDelegate.swift in Sources */, + B5788752249F8FF600D1AE9F /* AllCitiesTableViewController.swift in Sources */, + B578875A249FA5D700D1AE9F /* WeatherCell.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B59D61D02497F55E00E3411A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B59D61D12497F55E00E3411A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + B59D61D52497F56100E3411A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B59D61D62497F56100E3411A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B59D61D92497F56100E3411A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B59D61DA2497F56100E3411A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B59D61DC2497F56100E3411A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = RQYPG8XK25; + INFOPLIST_FILE = Weather/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.ckost9n.Weather; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + B59D61DD2497F56100E3411A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = RQYPG8XK25; + INFOPLIST_FILE = Weather/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.ckost9n.Weather; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B59D61C22497F55E00E3411A /* Build configuration list for PBXProject "Weather" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B59D61D92497F56100E3411A /* Debug */, + B59D61DA2497F56100E3411A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B59D61DB2497F56100E3411A /* Build configuration list for PBXNativeTarget "Weather" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B59D61DC2497F56100E3411A /* Debug */, + B59D61DD2497F56100E3411A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B59D61BF2497F55E00E3411A /* Project object */; +} diff --git a/Weather/Weather.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Weather/Weather.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..561f654 --- /dev/null +++ b/Weather/Weather.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Weather/Weather.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Weather/Weather.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Weather/Weather.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Weather/Weather.xcodeproj/project.xcworkspace/xcuserdata/konstantin.xcuserdatad/UserInterfaceState.xcuserstate b/Weather/Weather.xcodeproj/project.xcworkspace/xcuserdata/konstantin.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..3aaf5eb Binary files /dev/null and b/Weather/Weather.xcodeproj/project.xcworkspace/xcuserdata/konstantin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..bfed2ce --- /dev/null +++ b/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcschemes/xcschememanagement.plist b/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..d1731a2 --- /dev/null +++ b/Weather/Weather.xcodeproj/xcuserdata/konstantin.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Weather.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/Weather/Weather/AllCitiesCell.swift b/Weather/Weather/AllCitiesCell.swift new file mode 100644 index 0000000..f9d0811 --- /dev/null +++ b/Weather/Weather/AllCitiesCell.swift @@ -0,0 +1,15 @@ +// +// AllCitiesCell.swift +// Weather +// +// Created by Konstantin on 21.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +class AllCitiesCell: UITableViewCell { + + @IBOutlet weak var cityLabel: UILabel! + +} diff --git a/Weather/Weather/AllCitiesTableViewController.swift b/Weather/Weather/AllCitiesTableViewController.swift new file mode 100644 index 0000000..aa2377f --- /dev/null +++ b/Weather/Weather/AllCitiesTableViewController.swift @@ -0,0 +1,42 @@ +// +// AllCitiesTableViewController.swift +// Weather +// +// Created by Konstantin on 21.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +class AllCitiesTableViewController: UITableViewController { + + let cities: [String] = [ + "Moscow", + "London", + "New-York" + ] + + override func viewDidLoad() { + super.viewDidLoad() + } + + + + // MARK: - Table view data source + + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return cities.count + } + + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! AllCitiesCell + + cell.cityLabel.text = cities[indexPath.row] + + return cell + } + + +} diff --git a/Weather/Weather/AppDelegate.swift b/Weather/Weather/AppDelegate.swift new file mode 100644 index 0000000..7d045ae --- /dev/null +++ b/Weather/Weather/AppDelegate.swift @@ -0,0 +1,20 @@ +// +// AppDelegate.swift +// Weather +// +// Created by Konstantin on 15.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + return true + } +} + diff --git a/Weather/Weather/Assets.xcassets/AppIcon.appiconset/Contents.json b/Weather/Weather/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/Weather/Weather/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Weather/Weather/Assets.xcassets/Contents.json b/Weather/Weather/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Weather/Weather/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Weather/Weather/Base.lproj/LaunchScreen.storyboard b/Weather/Weather/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Weather/Weather/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Weather/Base.lproj/Main.storyboard b/Weather/Weather/Base.lproj/Main.storyboard new file mode 100644 index 0000000..53f9f94 --- /dev/null +++ b/Weather/Weather/Base.lproj/Main.storyboard @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Weather/Info.plist b/Weather/Weather/Info.plist new file mode 100644 index 0000000..af8868b --- /dev/null +++ b/Weather/Weather/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Weather/Weather/LoginViewController.swift b/Weather/Weather/LoginViewController.swift new file mode 100644 index 0000000..8847807 --- /dev/null +++ b/Weather/Weather/LoginViewController.swift @@ -0,0 +1,85 @@ +// +// ViewController.swift +// Weather +// +// Created by Konstantin on 15.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +class LoginViewController: UIViewController { + + @IBOutlet weak var scrollView: UIScrollView! + @IBOutlet weak var loginTextField: UITextField! + @IBOutlet weak var passwordTextField: UITextField! + + + + override func viewDidLoad() { + super.viewDidLoad() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: UIResponder.keyboardWillShowNotification, + object: nil) + + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: UIResponder.keyboardWillHideNotification, + object: nil) + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + NotificationCenter.default.removeObserver(self) + } + + @objc func keyboardWillShow(_ notification: Notification) { + guard let kbSize = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return } + + scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: kbSize.height, right: 0) + } + + @objc func keyboardWillHide(_ nitification: Notification) { + scrollView.contentInset = .zero + } + + @IBAction func scrollTapped(_ gesture: UIGestureRecognizer) { + scrollView.endEditing(true) + } + + override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { + if identifier == "Home" { + let isValid = checkUserData() + if !isValid { + showErrorAlert() + } + return isValid + } + return true + } + + func checkUserData() -> Bool { + return loginTextField.text == "admin" && passwordTextField.text == "123" + } + + func showErrorAlert() { + let alert = UIAlertController( + title: "Ошибка", + message: "Неправильный логин или пароль", + preferredStyle: .alert + ) + let action = UIAlertAction(title: "OK", style: .cancel, handler: nil) + alert.addAction(action) + + present(alert, animated: true, completion: nil) + } +} + diff --git a/Weather/Weather/MyCitiesTableViewController.swift b/Weather/Weather/MyCitiesTableViewController.swift new file mode 100644 index 0000000..eeafbab --- /dev/null +++ b/Weather/Weather/MyCitiesTableViewController.swift @@ -0,0 +1,58 @@ +// +// MyCitiesTableViewController.swift +// Weather +// +// Created by Konstantin on 21.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +class MyCitiesTableViewController: UITableViewController { + + var cities: [String] = [] + + override func viewDidLoad() { + super.viewDidLoad() + } + + @IBAction func addCity(segue: UIStoryboardSegue) { + guard + let allCitiesController = segue.source as? AllCitiesTableViewController, + let indexPath = allCitiesController.tableView.indexPathForSelectedRow + else { return } + + let city = allCitiesController.cities[indexPath.row] + + guard !cities.contains(city) else { return } + + cities.append(city) + tableView.reloadData() + } + + + // MARK: - Table view data source + + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return cities.count + } + + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) + + cell.textLabel?.text = cities[indexPath.row] + + return cell + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + cities.remove(at: indexPath.row) + tableView.deleteRows(at: [indexPath], with: .fade) + } + } + + +} diff --git a/Weather/Weather/WeatherCell.swift b/Weather/Weather/WeatherCell.swift new file mode 100644 index 0000000..c3cb3bd --- /dev/null +++ b/Weather/Weather/WeatherCell.swift @@ -0,0 +1,13 @@ +// +// WeatherCell.swift +// Weather +// +// Created by Konstantin on 21.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + +class WeatherCell: UICollectionViewCell { + +} diff --git a/Weather/Weather/WeatherCollectionViewController.swift b/Weather/Weather/WeatherCollectionViewController.swift new file mode 100644 index 0000000..cde46df --- /dev/null +++ b/Weather/Weather/WeatherCollectionViewController.swift @@ -0,0 +1,38 @@ +// +// WeatherCollectionViewController.swift +// Weather +// +// Created by Konstantin on 21.06.2020. +// Copyright © 2020 Konstantin. All rights reserved. +// + +import UIKit + + +class WeatherCollectionViewController: UICollectionViewController { + + + + override func viewDidLoad() { + super.viewDidLoad() + + } + + + + // MARK: UICollectionViewDataSource + + + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 20 + } + + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! WeatherCell + + + + return cell + } + +}