Skip to content

Instantly share code, notes, and snippets.

View kovs705's full-sized avatar
👽

Eugene Kovs kovs705

👽
View GitHub Profile
@kovs705
kovs705 / AppInfo.swift
Created May 14, 2024 07:27
iOS App Info
/// Wrapper to get some app related strings at one place.
struct AppInfo {
/// Returns the official app name, defined in your project data.
var appName: String {
return readFromInfoPlist(withKey: "CFBundleName") ?? "(unknown app name)"
}
/// Return the official app display name, eventually defined in your 'infoplist'.
var displayName: String {
@kovs705
kovs705 / Condition-2.swift
Last active May 30, 2024 17:56
`If` condition for views in SwiftUI
extension View {
@ViewBuilder
func applyIfTrue<Content: View>(_ condition: @autoclosure () -> Bool,
ifTrue applyTrue: (Self) -> Content) -> some View {
if condition() {
applyTrue(self)
} else {
self
}
@kovs705
kovs705 / Requirements.md
Last active May 31, 2024 22:16
RU, AppStore requirements

Требования для AppStore

Иконка

  1. Размер иконки - один универсальный 1024х1024
  2. Без альфа-каналов
  3. Квадрат
  4. Избегать маленьких деталей
  5. Сохранять простоту и иконки чтобы избегать "замусоренности" на фоне других иконок
  6. Текст может быть если только это не одна из основных функций приложения (Первые буквы приложения не в счет)
  7. Можно сделать простой фон и необязательно заполнять контентом всю иконку
@kovs705
kovs705 / Color+Ext.swift
Created March 25, 2024 06:17
Color+Ext
//
// Color+Ext.swift
// YourApp
//
// Created by Eugene Kovs on 06.03.2024.
// https://github.com/kovs705
//
import SwiftUI
@kovs705
kovs705 / OTPTextField.swift
Created February 22, 2024 12:21
OTPTextField - modifiable view for receiving and typing OTP codes
import SwiftUI
import Combine
struct OTPTextFieldView: View {
private enum FocusField: Hashable {
case field
}
@State var text = ""
@kovs705
kovs705 / Reducer.swift
Created February 12, 2024 09:12
Composable Architecture reducer template
import Foundation
import ComposableArchitecture
struct Main: Reducer {
var body: some Reducer<Main.State, Main.Action> {
Reduce { state, action in
return .none}
}
enum Action: Equatable {
@kovs705
kovs705 / GenerateLocalization.kts
Created December 28, 2023 12:50
Gradle script to generate localization from Android strings.xml to iOS Localizable.strings
val generateLocalization: TaskProvider<Task> by tasks.registering {
dependsOn("linkPodDebugFrameworkIosArm64")
fun generateIOSLocalizableStrings(androidStrings: String): String {
val regex = Regex("<string name=\"(.*?)\">(.*?)</string>")
val matches = regex.findAll(androidStrings)
val iosStrings = StringBuilder()
for (match in matches) {
val key = match.groupValues[1]
@kovs705
kovs705 / generateIOS.kts
Created December 28, 2023 12:46
Gradle script for XcodeGen
val generateIos: TaskProvider<Task> by tasks.registering {
if (isFamily(FAMILY_MAC)) {
val xcodeGenPath = "/usr/local/bin/xcodegen"
val specPath = "${project.rootDir}/_____IOS___FOLDER____/Project.yml"
doLast {
exec {
commandLine(xcodeGenPath, "generate", "--spec", specPath)
}
}
} else {
@kovs705
kovs705 / CombinePublisher.swift
Last active December 23, 2023 10:13
Combine function to observe parameters in @observableobject
// MARK: - Combine
/// Combine function to observe parameters in @ObservableObject
///
/// Example:
/// _ = newBindChangePublisher(for: <yourState object>, publisher: <yourStateObject>.$<parameter>.eraseToAnyPublisher(), keyPath: \.<parameter>, with: 0.4, handleAction: { [weak self] <nameOfParametersValue> in
/// guard let self = self else { return }
/// // perform action with the <nameOfParametersValue>
/// })
///
/// - Parameters:
@kovs705
kovs705 / SVGWebView.swift
Last active October 4, 2023 14:36 — forked from helje5/SVGWebView.swift
A SwiftUI View to display SVGs using WKWebView
// Created by Helge Heß on 06.04.21.
// Modified by Kovs705 on 04.10.2023
// Also available as a package: https://github.com/ZeeZide/SVGWebView
import SwiftUI
import WebKit
/**
* Display an SVG using a `WKWebView`.
*
* Used by [SVG Shaper for SwiftUI](https://zeezide.de/en/products/svgshaper/)