Skip to content

Commit

Permalink
Merge pull request #15 from htmlprogrammist/develop
Browse files Browse the repository at this point in the history
Added tests and minor updates
  • Loading branch information
htmlprogrammist authored Jun 20, 2022
2 parents 9eb7dab + 21b5f59 commit 607570e
Showing 86 changed files with 3,857 additions and 513 deletions.
480 changes: 463 additions & 17 deletions Agenda.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
98 changes: 98 additions & 0 deletions Agenda.xcodeproj/xcshareddata/xcschemes/Agenda.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB551627EF4D5400FA7E99"
BuildableName = "Agenda.app"
BlueprintName = "Agenda"
ReferencedContainer = "container:Agenda.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0055BE82854748F00430622"
BuildableName = "AgendaTests.xctest"
BlueprintName = "AgendaTests"
ReferencedContainer = "container:Agenda.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0FFD19028549DC6001EE4A6"
BuildableName = "AgendaUITests.xctest"
BlueprintName = "AgendaUITests"
ReferencedContainer = "container:Agenda.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB551627EF4D5400FA7E99"
BuildableName = "Agenda.app"
BlueprintName = "Agenda"
ReferencedContainer = "container:Agenda.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB551627EF4D5400FA7E99"
BuildableName = "Agenda.app"
BlueprintName = "Agenda"
ReferencedContainer = "container:Agenda.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -10,5 +10,23 @@
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>F0055BE82854748F00430622</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>F0BB551627EF4D5400FA7E99</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>F0FFD19028549DC6001EE4A6</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
10 changes: 5 additions & 5 deletions Agenda/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ private extension AppCoordinator {
let context = AgendaContext(moduleOutput: nil, moduleDependency: coreDataManager)
let container = AgendaContainer.assemble(with: context)

let agendaViewController = createNavController(viewController: container.viewController, itemName: Labels.goals, itemImage: "calendar")
let agendaViewController = createNavController(viewController: container.viewController, itemName: Labels.goals, itemImage: Icons.calendar)
viewControllers.append(agendaViewController)
subscribeToCoreDataManager(vc: container.viewController)
}
@@ -44,23 +44,23 @@ private extension AppCoordinator {
let context = HistoryContext(moduleOutput: nil, moduleDependency: coreDataManager)
let container = HistoryContainer.assemble(with: context)

let historyViewController = createNavController(viewController: container.viewController, itemName: Labels.History.title, itemImage: "clock.fill")
let historyViewController = createNavController(viewController: container.viewController, itemName: Labels.History.title, itemImage: Icons.history)
viewControllers.append(historyViewController)
subscribeToCoreDataManager(vc: container.viewController)
}

func setupSummary() {
let context = SummaryContext(moduleOutput: nil, moduleDependency: coreDataManager)
let container = SummaryContainer.assemble(with: context)
let summaryViewController = createNavController(viewController: container.viewController, itemName: Labels.Summary.title, itemImage: "square.text.square.fill")
let summaryViewController = createNavController(viewController: container.viewController, itemName: Labels.Summary.title, itemImage: Icons.summary)
viewControllers.append(summaryViewController)
subscribeToCoreDataManager(vc: container.viewController)
}

func createNavController(viewController: UIViewController, itemName: String, itemImage: String) -> UINavigationController {
func createNavController(viewController: UIViewController, itemName: String, itemImage: UIImage) -> UINavigationController {

let navController = UINavigationController(rootViewController: viewController)
navController.tabBarItem = UITabBarItem(title: itemName, image: UIImage(named: itemImage), tag: 0)
navController.tabBarItem = UITabBarItem(title: itemName, image: itemImage, tag: 0)
navController.navigationBar.prefersLargeTitles = true
return navController
}
3 changes: 1 addition & 2 deletions Agenda/Extensions/UIKit/UIAlertController.swift
Original file line number Diff line number Diff line change
@@ -7,8 +7,7 @@

import UIKit

// MARK: this code is needed so that the console no longer displays an error about the allegedly negative width

/// this code is needed so that the console no longer displays an error about the allegedly negative width on iOS 13 (14?)
extension UIAlertController {
func negativeWidthConstraint() {
for subView in self.view.subviews {
22 changes: 0 additions & 22 deletions Agenda/Extensions/UIKit/UIButton.swift

This file was deleted.

40 changes: 24 additions & 16 deletions Agenda/Extensions/UIKit/UIViewController.swift
Original file line number Diff line number Diff line change
@@ -8,6 +8,30 @@
import UIKit

extension UIViewController {

func alertForError(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let ok = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(ok)

present(alert, animated: true, completion: nil)
}

func alertForDeletion(title: String, message: String, completion: @escaping () -> ()) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
let yes = UIAlertAction(title: Labels.yes, style: .destructive, handler: { _ in
completion()
})
let no = UIAlertAction(title: Labels.cancel, style: .default)

alert.addAction(yes)
alert.addAction(no)

/// for definition try to open declaration of this functions in Extensions/UIKit/UIAlertController.swift
alert.negativeWidthConstraint()
present(alert, animated: true)
}

func hideKeyboardWhenTappedAround() {
let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
tap.cancelsTouchesInView = false
@@ -18,20 +42,4 @@ extension UIViewController {
@objc private func dismissKeyboard() {
view.endEditing(true)
}

func resize(_ cell: GoalTableViewCell, in tableView: UITableView, with textView: UITextView) {
let size = textView.bounds.size
let newSize = tableView.sizeThatFits(CGSize(width: size.width, height: CGFloat.greatestFiniteMagnitude))

if size.height != newSize.height {
UIView.setAnimationsEnabled(false)
tableView.beginUpdates()
tableView.endUpdates()
UIView.setAnimationsEnabled(true)
// Scoll up your textview if required
if let thisIndexPath = tableView.indexPath(for: cell) {
tableView.scrollToRow(at: thisIndexPath, at: .bottom, animated: false)
}
}
}
}
24 changes: 0 additions & 24 deletions Agenda/Extensions/UserDefaults.swift

This file was deleted.

25 changes: 25 additions & 0 deletions Agenda/Models/UserSettings.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UserSettings.swift
// Agenda
//
// Created by Егор Бадмаев on 10.06.2022.
//

fileprivate enum SettingsKey: CodingKey {
case hasOnboarded
case summaries
}

struct UserSettings {
private let storage = UserDefaultsContainer(keyedBy: SettingsKey.self)

var hasOnboarded: Bool? {
get { storage[.hasOnboarded] }
set { storage[.hasOnboarded] = newValue }
}

var summaries: [Int]? {
get { storage[.summaries] }
set { storage[.summaries] = newValue}
}
}
5 changes: 4 additions & 1 deletion Agenda/Modules/AddGoal/AddGoalInteractor.swift
Original file line number Diff line number Diff line change
@@ -21,7 +21,10 @@ final class AddGoalInteractor {

extension AddGoalInteractor: AddGoalInteractorInput {
func createGoal(goalData: GoalData) {
coreDataManager.createGoal(data: goalData, in: month)
output?.goalDidCreate()

DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
coreDataManager.createGoal(data: goalData, in: month)
}
}
}
Loading
Oops, something went wrong.

0 comments on commit 607570e

Please sign in to comment.