ProjectMagick is a Collection of native Swift Extensions, handy methods and classes.
Xcode 13+, iOS 13+, Swift 5.4+
- Alamofire
- SDWebImage
- IQKeyboardManagerSwift
- FittedSheets
- CodableWrappers
ProjectSetup.swift
- Use the
applyKeyboardSetup()
method to setup keyboard in your AppDelegate or SceneDelegate. - Use
applyFonts()
method to setup fonts in your application. Apply system fonts from Storyboard or XIB in order to work this. AppInfo
class will provide basic information like Appname, current envrionment, version etc.- Use
fetchCountries()
method to get list of countries in model form. i.e.AppInfo.fetchCountries()
- Use
fetchCurrentCountryCodeDial()
method to get current country code with flag. i.e.AppInfo.fetchCurrentCountryCodeDial()
CustomClasses.swift
- This class is a collection of Custom UIViews. Like
TablePlus
andCollectionPlus
comes with no data label and some interesting properties and UIRefreshControl. Check here for more information. PaddingLabel
is useful class for small labels that require some padding around the edges.
ImagePickerManager.swift
ImagePickerManager
will handle all the requirements of native image picker manager class. Just assign this class to anyUIView
, you can also use this class programmatically.- To allow multiple selection, change
selectionLimit = 0
. - It comes with default alert messages, you can customize it if you want.
CoreDataStack.swift
CoreDataStack
is CoreData Utility class. You can perform CRUD operation using this class.- You can perform batch operation as well using this class.
- You can create a fetch request for UIViewController.
- You can store UIColor and URL directly with the help of
CoreDataUIColorTransformer
andCoreDataURLTransformer
. - Check here for more information.
UserDefaults
UserDefault
is a property wrapper that will help you to store any type of native data types.- For example
extension Preferences {
@UserDefault(key : "AnyKey")
static var x : Bool?
@UserDefault(key : "AnyKey", defaultValue : false)
static var y : Bool
Note:- To store model directly, don't forget to set `isObject = true` in initialization. It will consider class name as key automatically.
@UserDefault(isObject : true)
static var z : AnyModel?
}
UITextfield.swift
-
ThemeTextfield
is a feature reach sub-class ofUITextfield
. -
Day to day validations comes out of the box with this class. Most of the basic types are covered in this class.
- Take Password field type for example
txtfield.validationFamily = .familyOfPassword([.emptyPassword, .emptyConfirmPassword, .minimumCharacters]) // Just like that you can add validation checks for this textfield
- Take another example of textfield type Email
txtfield.validationFamily = .familyOfEmail([.emptyEmail, .validEmail]) // Just like that you can add validation checks for email.
- Once you set validation family it will automatically set keyboard type for you.
isValid
Property check for its validation and return message invalidationMessage
.
-
Also, you can prevent user to do such actions like
Cut
,Copy
,Paste
and much more very easily as shown below.
txtfield.setEditActions(actions: [.paste, .cut])
- You can also set
minimumPasswordLength
andminimumPhoneNumberLength
. - Check here for more information.
TextPickerView.swift
TextPickerView
is a combination of Date and normal Picker. Just assign a type after initialization and it will work as per type.- For String type you need to confirm to datasource and delegate.
SwipeNavigationController.swift
SwipeNavigationController
is a navigation class that comes with swipe to pop functionality and more.- There are some handly methods like
setBackButtonImage()
andsetImageInCenter()
. - There are much more to explore about navigation in the file so Check here for more information.
KeyChainServices.swift
KeyChainManager
helps you to store data in Keychain.- You can perform CRUD operation with given access level.
UICollectionFlowLayouts
AlignedCollectionViewFlowLayout
can help you with tags like layouts.CenteredCollectionViewFlowLayout
behaves like carousel effect with one view at the center of the screen at a time.VerticalOverlappingCollectionViewFlowLayout
is as name suggest an overlapping layout, makaingisSticky
property true, can mirror wallet app layout.- There are more layouts to check, go to
CollectionViewFlowLayouts
folder to see them all. - Checkout class files to see in detail. Also, in the begining of file there is a github link for original source, if you need detail description.
BioMetricManager.swift
BioMetricManager
is a fairly simple class that will help you to deal withFaceID
andTouchID
authentication.
Codable.swift
- This class has some useful initializers and generic methods to handle any model type.
- We will be using
CodableWrappers
to handle nullable values and lossy collection types. Check out CodableWrappers for more advance and basic usage. - Please note if you are planning to integrate local database, DO NOT USE PROPERTYWRAPPERS.
-
Go to
APIManager
folder and copy the commented code fromRouter
andSessionManager
file and put it in your local project. -
Make minimum two .xcconfig file for development and live server. Don't forget to set this files in project settings.
-
Also, change the archive setting of your project scheme and set live xcconfig file there.
-
Declare
BaseURL
variables in both the files and also addBaseURL
ininfo.plist
file. Add as many as you want. -
Make on enum or structure that holds all the Project level variable. From that, get the BaseURL and pass it to the request. Something like this or Copy below code.
enum EnvironmentVariables { static var baseURL: URL { return try! URL(string: Configuration.value(for: "BaseURL"))! } }
This will be a collection of some ready to use UI and other things like list of countries in JSON.
CollectionViewCells
TableViewCells
- JSON of country list
- Take advantage of some useful snippets and paste it here in your local computer. You can download it from here
~/Library/Developer/Xcode/UserData/CodeSnippets/