Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcelocation committed Nov 25, 2022
0 parents commit c9ea9b3
Show file tree
Hide file tree
Showing 31 changed files with 2,171 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
404 changes: 404 additions & 0 deletions AirTroller.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AirTroller.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
5 changes: 5 additions & 0 deletions AirTroller/AirTroller-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "RemoteLog.h"
46 changes: 46 additions & 0 deletions AirTroller/AirTrollerApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AirTrollerApp.swift
// AirTroller
//
// Created by exerhythm on 02.11.2022.
//

import SwiftUI

@main
struct AirTrollerApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onAppear {
// MARK: Check for new versions
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, let url = URL(string: "https://api.github.com/repos/sourcelocation/AirTroller/releases/latest") {
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
guard let data = data else { return }

if let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
if json["tag_name"] as? String != version {
UIApplication.shared.confirmAlert(title: "Update available", body: "A new AirTroller update is available, do you want to visit releases page?", onOK: {
UIApplication.shared.open(URL(string: "https://github.com/sourcelocation/AirTroller/releases/latest")!)
}, noCancel: false)
}
}
}
task.resume()
}

// Clean up tmp dir
for url in (try? FileManager.default.contentsOfDirectory(at: FileManager.default.temporaryDirectory, includingPropertiesForKeys: nil)) ?? [] {
try? FileManager.default.removeItem(at: url)
}
}
}
}
}

func remLog(_ objs: Any...) {
for obj in objs {
let args: [CVarArg] = [ String(describing: obj) ]
withVaList(args) { RLogv("%@", $0) }
}
}
54 changes: 54 additions & 0 deletions AirTroller/Alert.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Alert.swift
// AirTroller
//
// Created by exerhythm on 21.11.2022.
//

import UIKit

var currentUIAlertController: UIAlertController?

extension UIApplication {
func dismissAlert(animated: Bool) {
DispatchQueue.main.async {
currentUIAlertController?.dismiss(animated: animated)
}
}
func alert(title: String = "Error", body: String, animated: Bool = true, withButton: Bool = true) {
DispatchQueue.main.async {
currentUIAlertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
if withButton { currentUIAlertController?.addAction(.init(title: "OK", style: .cancel)) }
self.present(alert: currentUIAlertController!)
}
}
func confirmAlert(title: String = "Error", body: String, onOK: @escaping () -> (), noCancel: Bool) {
DispatchQueue.main.async {
currentUIAlertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
if !noCancel {
currentUIAlertController?.addAction(.init(title: "Cancel", style: .cancel))
}
currentUIAlertController?.addAction(.init(title: "Yes", style: noCancel ? .cancel : .default, handler: { _ in
onOK()
}))
self.present(alert: currentUIAlertController!)
}
}
func change(title: String = "Error", body: String) {
DispatchQueue.main.async {
currentUIAlertController?.title = title
currentUIAlertController?.message = body
}
}

func present(alert: UIAlertController) {
if var topController = self.windows[0].rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}

topController.present(alert, animated: true)
// topController should now be your topmost view controller
}
}
}
11 changes: 11 additions & 0 deletions AirTroller/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions AirTroller/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "Artboard.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions AirTroller/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
21 changes: 21 additions & 0 deletions AirTroller/Assets.xcassets/NonTrolledPerson.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions AirTroller/Assets.xcassets/TrolledPerson.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions AirTroller/Assets.xcassets/github.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"images" : [
{
"filename" : "GitHub-Mark-64px.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c9ea9b3

Please sign in to comment.