This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Collection { | |
subscript(safe index: Index) -> Element? { | |
indices.contains(index) ? self[index] : nil | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <number_of_ips>" | |
exit 1 | |
fi | |
if ! [[ $1 =~ ^[0-9]+$ ]] || [ $1 -lt 0 ] || [ $1 -gt 255 ]; then | |
echo "Error: The argument must be a number in the range from 0 to 255." | |
exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@UIApplicationMain | |
final class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
// 1 начальная настройка перед завершением запуска | |
func application( | |
_ application: UIApplication, | |
willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let windowScene = (scene as? UIWindowScene) else { return } | |
// Настройка окна приложения | |
window = UIWindow(windowScene: windowScene) | |
let initialViewController = ViewController() | |
window?.rootViewController = initialViewController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ViewController: UIViewController { | |
private let name = "🖥️" | |
private let infoLabel: UILabel = { | |
let label = UILabel() | |
label.text = "AppDelegate Life Cycle" | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label | |
}() | |
private let switchButton: UIButton = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AnimationExample: View { | |
@ObservedObject var trace = AnimationTrace() | |
@State var animating: Bool = false | |
@State var selectedAnimationIndex: Int = 0 | |
@State var slowAnimations: Bool = false | |
var selectedAnimation: (String, Animation) { | |
return animations[selectedAnimationIndex] | |
} | |
var body: some View { | |
VStack { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BlurReplace, Identity, Move, Offset, | |
// Opacity, Push, Scale, Slide | |
// Asymmetric | |
struct ContentView: View { | |
@State private var showBlurReplace = false | |
@State private var showIdentity = false | |
@State private var showMove = false | |
@State private var showOffset = false | |
@State private var showOpacity = false | |
@State private var showPush = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct DefaultPopUps: View { | |
@State var onSheet = false | |
@State var onFullScreenCover = false | |
@State var onPopover = false | |
@State var onAlert = false | |
@State var onActionSheet = false | |
var body: some View { | |
VStack { | |
Button(action: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Double { | |
func humanFormatted( | |
groupingSeparator: String = " ", | |
roundingMode: NumberFormatter.RoundingMode = .halfEven, | |
fractionDigits: Int = 1, | |
threshold: Double = 9_999 | |
) -> (stringValue: String, postfix: String?) { | |
let dividerNames: [String?] = [nil, "тыс.", "млн", "млрд", "трлн", "квадрлн"] | |
OlderNewer