Skip to content
Permalink
Browse files

use SwiftUI for settings; remove magic fatal-error String

  • Loading branch information
vermont42 committed Nov 11, 2019
1 parent 45f8696 commit 5c3d35620aa31c68dd9c201e69302e8dc9a26ddd

Large diffs are not rendered by default.

@@ -35,7 +35,7 @@ class BrowseInfoView: UIView {
}()

required init(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(frame: CGRect) {
@@ -25,7 +25,7 @@ class BrowseVerbsView: UIView {
}()

required init(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(frame: CGRect) {
@@ -22,7 +22,7 @@ class ConjugationCell: UITableViewCell {
}()

required init?(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -6,7 +6,7 @@
// Copyright © 2017 Josh Adams. All rights reserved.
//
enum Difficulty: String {
enum Difficulty: String, CaseIterable {
case easy = "Easy"
case moderate = "Moderate"
case difficult = "Difficult"
@@ -0,0 +1,27 @@
//
// FontExtensions.swift
// Conjugar
//
// Created by Joshua Adams on 11/3/19.
// Copyright © 2019 Josh Adams. All rights reserved.
//
import SwiftUI

extension Font {
static var heading: Font {
Font.custom("AvenirNext-Bold", size: 24.0)
}

static var subheading: Font {
Font.custom("AvenirNext-Bold", size: 18.0)
}

static var smallBody: Font {
Font.custom("AvenirNext-Demibold", size: 12.0)
}

static var button: Font {
Font.custom("AvenirNext-Demibold", size: 24.0)
}
}
@@ -20,7 +20,7 @@ class InfoCell: UITableViewCell {
}()

required init?(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -27,7 +27,7 @@ class InfoVC: UIViewController, UITextViewDelegate {
}

required init?(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override func loadView() {
@@ -29,6 +29,6 @@ class InfoView: UIView {
}

required init(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}
}
@@ -11,4 +11,5 @@ import UIKit
struct Layout {
static let defaultSpacing: CGFloat = 8.0
static let tripleDefaultSpacing: CGFloat = 24.0
static let defaultHorizontalMargin: CGFloat = 16.0
}
@@ -7,6 +7,7 @@
//
import UIKit
import SwiftUI

class MainTabBarVC: UITabBarController {
static let tabs = ["Browse", "Quiz", "Settings", "Info"]
@@ -17,10 +18,11 @@ class MainTabBarVC: UITabBarController {
browseVerbsNavC.tabBarItem = UITabBarItem(title: MainTabBarVC.tabs[0], image: UIImage(named: MainTabBarVC.tabs[0]), selectedImage: nil)
let quizNavC = UINavigationController(rootViewController: QuizVC())
quizNavC.tabBarItem = UITabBarItem(title: MainTabBarVC.tabs[1], image: UIImage(named: MainTabBarVC.tabs[1]), selectedImage: nil)
let settingsNavC = UINavigationController(rootViewController: SettingsVC())
settingsNavC.tabBarItem = UITabBarItem(title: MainTabBarVC.tabs[2], image: UIImage(named: MainTabBarVC.tabs[2]), selectedImage: nil)
let settingsVC = UIHostingController(rootView: SettingsView().environmentObject(Current))
Current.parentViewController = settingsVC
settingsVC.tabBarItem = UITabBarItem(title: MainTabBarVC.tabs[2], image: UIImage(named: MainTabBarVC.tabs[2]), selectedImage: nil)
let browseInfoNavC = UINavigationController(rootViewController: BrowseInfoVC())
browseInfoNavC.tabBarItem = UITabBarItem(title: MainTabBarVC.tabs[3], image: UIImage(named: MainTabBarVC.tabs[3]), selectedImage: nil)
viewControllers = [browseVerbsNavC, quizNavC, browseInfoNavC, settingsNavC]
viewControllers = [browseVerbsNavC, quizNavC, browseInfoNavC, settingsVC]
}
}
@@ -0,0 +1,50 @@
//
// Modifiers.swift
// Conjugar
//
// Created by Joshua Adams on 11/3/19.
// Copyright © 2019 Josh Adams. All rights reserved.
//
import SwiftUI

struct HeadingLabel: ViewModifier {
func body(content: Content) -> some View {
content
.font(.heading)
.foregroundColor(Color(Colors.yellow))
}
}

struct SubheadingLabel: ViewModifier {
func body(content: Content) -> some View {
content
.font(.subheading)
.foregroundColor(Color(Colors.yellow))
}
}

struct BodyLabel: ViewModifier {
func body(content: Content) -> some View {
content
.font(.smallBody)
.foregroundColor(Color(Colors.yellow))
.padding(.horizontal, Layout.defaultHorizontalMargin)
}
}

struct StandardButton: ViewModifier {
func body(content: Content) -> some View {
content
.font(.button)
.foregroundColor(Color(Colors.red))
}
}

struct SegmentedPicker: ViewModifier {
func body(content: Content) -> some View {
content
.pickerStyle(SegmentedPickerStyle())
.padding(.horizontal, Layout.defaultHorizontalMargin)
}
}
@@ -0,0 +1,15 @@
//
// NSCoderExtension.swift
// Conjugar
//
// Created by Joshua Adams on 11/11/19.
// Copyright © 2019 Josh Adams. All rights reserved.
//
import Foundation

extension NSCoder {
static func fatalErrorNotImplemented() -> Never {
fatalError("init(coder:) has not been implemented")
}
}
@@ -44,7 +44,7 @@ class QuizView: UIView {
}()

required init(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(frame: CGRect) {
@@ -6,7 +6,7 @@
// Copyright © 2017 Josh Adams. All rights reserved.
//
enum Region: String {
enum Region: String, CaseIterable {
case spain = "Spain"
case latinAmerica = "Latin America"

@@ -17,7 +17,7 @@ class ResultCell: UITableViewCell {
let proposedAnswer = UILabel()

required init?(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -24,7 +24,7 @@ class ResultsView: UIView {
let timeLabel = UILabel()

required init(coder aDecoder: NSCoder) {
UIViewController.fatalErrorNotImplemented()
NSCoder.fatalErrorNotImplemented()
}

override init(frame: CGRect) {
@@ -6,7 +6,7 @@
// Copyright © 2018 Josh Adams. All rights reserved.
//
enum SecondSingularBrowse: String {
enum SecondSingularBrowse: String, CaseIterable {
case tu = ""
case vos = "Vos"
case both = "Both"
@@ -6,7 +6,7 @@
// Copyright © 2018 Josh Adams. All rights reserved.
//
enum SecondSingularQuiz: String {
enum SecondSingularQuiz: String, CaseIterable {
case tu = ""
case vos = "Vos"
}

This file was deleted.

0 comments on commit 5c3d356

Please sign in to comment.
You can’t perform that action at this time.