-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPostViewController.swift
More file actions
105 lines (87 loc) · 4.45 KB
/
Copy pathPostViewController.swift
File metadata and controls
105 lines (87 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// PostViewController.swift
// ReproducingiOS16PopUpControllerBug
//
// Created by Joe Puccio on 8/13/22.
//
import UIKit
import Foundation
// This view controller displays the single post view.
class PostViewController: UIViewController, UIGestureRecognizerDelegate, UITextFieldDelegate, UIAdaptivePresentationControllerDelegate, UITextViewDelegate {
init() {
super.init(nibName:nil, bundle:nil)
}
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.largeTitleDisplayMode = .never
// Set background color
var useAlertAction = false
if(!useAlertAction){
// we usually use this:
//let rootController = self // UIApplication.shared.windows.first!.rootViewController as! CustomTabBar
let popover = FlagPopUpController(delegateController: self)
popover.presentationController?.delegate = self
popover.displayFlagPopUp()
self.addChild(popover)
popover.didMove(toParent: self)
}else{
func flagReasonChosen(choice:String?){
print("flagged")
}
let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
sheet.addAction(UIAlertAction(title: "Cheating", style: .destructive, handler: { action in flagReasonChosen(choice: "Cheating") }))
sheet.addAction(UIAlertAction(title: "Harassment", style: .destructive, handler: { action in flagReasonChosen(choice: "Harassment") }))
sheet.addAction(UIAlertAction(title: "Hate", style: .destructive, handler: { action in flagReasonChosen(choice: "Hate") }))
sheet.addAction(UIAlertAction(title: "Spam", style: .destructive, handler: { action in flagReasonChosen(choice: "Spam") }))
sheet.addAction(UIAlertAction(title: "Nudity", style: .destructive, handler: { action in flagReasonChosen(choice: "Nudity") }))
sheet.addAction(UIAlertAction(title: "Violence", style: .destructive, handler: { action in flagReasonChosen(choice: "Violence") }))
sheet.addAction(UIAlertAction(title: "Other", style: .destructive, handler: { action in flagReasonChosen(choice: "Other") }))
sheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(sheet, animated: true)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension UIDevice {
var iPhoneX: Bool { UIScreen.main.nativeBounds.height == 2436 }
var iPhone: Bool { UIDevice.current.userInterfaceIdiom == .phone }
var iPad: Bool { UIDevice().userInterfaceIdiom == .pad }
enum ScreenType: String {
case iPhones_4_4S = "iPhone 4 or iPhone 4S"
case iPhones_5_5s_5c_SE = "iPhone 5, iPhone 5s, iPhone 5c or iPhone SE"
case iPhones_6_6s_7_8 = "iPhone 6, iPhone 6S, iPhone 7 or iPhone 8"
case iPhones_6Plus_6sPlus_7Plus_8Plus = "iPhone 6 Plus, iPhone 6S Plus, iPhone 7 Plus or iPhone 8 Plus"
case iPhones_6Plus_6sPlus_7Plus_8Plus_Simulators = "iPhone 6 Plus, iPhone 6S Plus, iPhone 7 Plus or iPhone 8 Plus Simulators"
case iPhones_X_XS_12MiniSimulator = "iPhone X or iPhone XS or iPhone 12 Mini Simulator"
case iPhone_XR_11 = "iPhone XR or iPhone 11"
case iPhone_XSMax_ProMax = "iPhone XS Max or iPhone Pro Max"
case iPhone_11Pro = "iPhone 11 Pro"
case iPhone_12Mini = "iPhone 12 Mini"
case iPhone_12_12Pro = "iPhone 12 or iPhone 12 Pro"
case iPhone_12ProMax = "iPhone 12 Pro Max"
case unknown
}
var screenType: ScreenType {
switch UIScreen.main.nativeBounds.height {
case 1136: return .iPhones_5_5s_5c_SE
case 1334: return .iPhones_6_6s_7_8
case 1792: return .iPhone_XR_11
case 1920: return .iPhones_6Plus_6sPlus_7Plus_8Plus
case 2208: return .iPhones_6Plus_6sPlus_7Plus_8Plus_Simulators
case 2340: return .iPhone_12Mini
case 2426: return .iPhone_11Pro
case 2436: return .iPhones_X_XS_12MiniSimulator
case 2532: return .iPhone_12_12Pro
case 2688: return .iPhone_XSMax_ProMax
case 2778: return .iPhone_12ProMax
default: return .unknown
}
}
}
//this is here just to enable us to call this function in all the views that use a slide up/down
extension UIViewController{
@objc func dismissMyself(){
}
}