This file contains 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 [ $# -eq 0 ]; then | |
echo "Неправильное использование скрипта. Корректный формат: ./repeat.sh --task task.md --every week|month|year" | |
exit 1 | |
fi | |
# Проверка первых двух аргументов | |
if [ -z "$1" ] || [ -z "$2" ]; then |
This file contains 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 LogSizes: Layout { | |
var label: String | |
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | |
assert(subviews.count == 1) | |
print(String(format: "предлагают _%@_: →%.2f x ↓%.2f", label, proposal.width ?? 0, proposal.height ?? 0)) | |
let result = subviews[0].sizeThatFits(proposal) | |
print(String(format: "ответ от _%@_: →%.2f x ↓%.2f", label, result.width, result.height)) | |
return result | |
} |
This file contains 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 DynamicTextColoring: View { | |
var body: some View { | |
VStack { | |
// только с 16 оси | |
Text("1) Коллеги и платформа \(Text("поздравляют Вас").foregroundColor(.teal))!") | |
Text(attributedCongratulationString) | |
} | |
} | |
This file contains 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 SwiftUI | |
// Extension to handle boolean conditions | |
extension View { | |
@ViewBuilder | |
public func `if`<Transform: View>( | |
_ value: Bool, | |
transform: (Self) -> Transform | |
) -> some View { | |
if value { |
This file contains 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
extension FocusedValues { | |
var myKey: Binding<String>? { | |
get { self[MyFocusKey.self] } | |
set { self[MyFocusKey.self] = newValue } | |
} | |
struct MyFocusKey: FocusedValueKey { | |
typealias Value = Binding<String> | |
} | |
} |
This file contains 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, "тыс.", "млн", "млрд", "трлн", "квадрлн"] | |
This file contains 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 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 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 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 = { |
NewerOlder