Skip to content

Commit

Permalink
fix: add revert back setup to support controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dypme committed Feb 13, 2023
1 parent 037f910 commit 7f0bbd2
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 35 deletions.
10 changes: 10 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ target 'iOStarter' do
# Pods for iOS_Starter

end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,6 @@ SPEC CHECKSUMS:
SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e

PODFILE CHECKSUM: c38de0f8e6024b30676e16ce27a67583a53bad4b
PODFILE CHECKSUM: 5679e5d73bb234779129184435c86bae2b4b976d

COCOAPODS: 1.11.3
27 changes: 26 additions & 1 deletion iOStarter/Base/Controller/CollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import UIKit

class CollectionViewController: ViewController {

@IBOutlet weak private(set) var collectionView: UICollectionView!

private(set) var refreshControl = UIRefreshControl()
Expand Down Expand Up @@ -43,9 +43,34 @@ class CollectionViewController: ViewController {
@objc func fetch(isLoadMore: Bool = false) {

}

var backgroundView: UIView? {
if collectionView(collectionView, numberOfItemsInSection: 0) <= 0 {
if isLoading {
return LoadIndicatorView()
}
return ErrorView(message: L10n.Error.dataNotFound)
}
return nil
}

/// Footer view of table view
var footerView: UIView? {
if isAllowLoadMore {
let frame = CGRect(x: 0, y: 0, width: collectionView.frame.width, height: 50)
let loadingView = LoadIndicatorView()
loadingView.frame = frame
return loadingView
}
return UIView(frame: .zero)
}
}

extension CollectionViewController {
@objc open var isLoading: Bool {
false
}

/// Indicate that list can load more
@objc open var isAllowLoadMore: Bool {
false
Expand Down
25 changes: 25 additions & 0 deletions iOStarter/Base/Controller/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,34 @@ class TableViewController: ViewController {

}

var backgroundView: UIView? {
if tableView(tableView, numberOfRowsInSection: 0) <= 0 {
if isLoading {
return LoadIndicatorView()
}
return ErrorView(message: L10n.Error.dataNotFound)
}
return nil
}

/// Footer view of table view
var footerView: UIView? {
if isAllowLoadMore {
let frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50)
let loadingView = LoadIndicatorView()
loadingView.frame = frame
return loadingView
}
return UIView(frame: .zero)
}

}

extension TableViewController {
/// Indicate that list can load more
@objc open var isLoading: Bool {
false
}
/// Indicate that list can load more
@objc open var isAllowLoadMore: Bool {
false
Expand Down
2 changes: 1 addition & 1 deletion iOStarter/Base/Model/BaseModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Foundation
import SwiftyJSON

class BaseModel: NSObject {
required init(fromJson json: JSON) {
required init(fromJson json: JSON!) {

}

Expand Down
6 changes: 3 additions & 3 deletions iOStarter/Components/UIKit/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ extension UIView {
/// - tapReload: Action to reload fetch data while error occur
/// - tag: Mark of error view in superview
func setErrorView(image: UIImage? = nil, message: String, tag: Int = 1431) {
removeErrorView(tag: tag)

let errorView = ErrorView(image: image, message: message, tag: tag)
if !self.subviews.contains(where: { $0.tag == tag }) {
errorView.show(in: self)
}
errorView.show(in: self)
}

/// Stop animating activity indicator in superview of current view
Expand Down
2 changes: 1 addition & 1 deletion iOStarter/Example/Model/Item.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Item: BaseModel, Identifiable {
var image: String = ""
var name: String = ""

required init(fromJson json: JSON) {
required init(fromJson json: JSON!) {
super.init(fromJson: json)
detail = json["detail"].stringValue
id = json["id"].intValue
Expand Down
2 changes: 1 addition & 1 deletion iOStarter/Example/Model/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class User: BaseModel {
var image: String = ""
var lastName: String = ""

required init(fromJson json: JSON) {
required init(fromJson json: JSON!) {
super.init(fromJson: json)

email = json["email"].stringValue
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion iOStarter/Supporting Files/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import Firebase

import MMKV

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
setApp()
// uncomment setupNotification if need push notification
Expand Down
29 changes: 24 additions & 5 deletions iOStarter/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,29 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UILaunchScreen</key>
<dict>
<key>UILaunchScreen</key>
<dict/>
</dict>
<key>UILaunchScreen</key>
<dict>
<key>UILaunchScreen</key>
<dict/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen.xib</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
57 changes: 57 additions & 0 deletions iOStarter/Supporting Files/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// SceneDelegate.swift
// iOStarter
//
// Created by Macintosh on 29/06/22.
// Copyright © 2022 dypme. All rights reserved.
//

import UIKit
import SwiftUI

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
var mainController: UIViewController!

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.makeKeyAndVisible()

mainController = UIHostingController(rootView: TabBarMenuUI())
window?.rootViewController = mainController
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}

}
21 changes: 0 additions & 21 deletions iOStarter/Supporting Files/iOStarterApp.swift

This file was deleted.

39 changes: 39 additions & 0 deletions iOStarter/UI/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="iOStarter" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A7n-V9-YgG">
<rect key="frame" x="111.33333333333333" y="414.66666666666669" width="170.33333333333337" height="48"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="A7n-V9-YgG" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="ZV1-1g-7dY"/>
<constraint firstItem="A7n-V9-YgG" firstAttribute="centerY" secondItem="vUN-kp-3ea" secondAttribute="centerY" id="awB-a6-7ez"/>
</constraints>
<point key="canvasLocation" x="-25" y="20"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
17 changes: 17 additions & 0 deletions iOStarter/Utilities/Extension/UIApplicationExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// UIApplicationExtensions.swift
// iOStarter
//
// Created by MBP2022_1 on 03/01/23.
// Copyright © 2023 dypme. All rights reserved.
//

import Foundation
import UIKit

extension UIApplication {
// For support multiple windows
var activeWindow: UIWindow? {
UIApplication.shared.windows.filter { $0.isKeyWindow }.first
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit 7f0bbd2

Please sign in to comment.