Skip to content

Instantly share code, notes, and snippets.

View liudasbar's full-sized avatar

Liudas Baronas liudasbar

View GitHub Profile
@liudasbar
liudasbar / generate_strings.py
Created October 23, 2023 10:46
Localizable strings generator for Swift projects in Xcode
import os
def parse_input(input_path):
with open(input_path, 'r') as f:
lines = f.readlines()
translations = {}
for line in lines:
line = line.strip()
if not line.startswith('"') or '=' not in line:
@liudasbar
liudasbar / WeatherHazardType.swift
Created September 14, 2023 22:01
OpenWeatherMap (One Call API) Types of severe weather (tags) for decoding
enum WeatherHazardType: String, Codable {
case rain = "Rain"
case snowIce = "Snow/Ice"
case thunderstorm = "Thunderstorm"
case fog = "Fog"
case extremeTemperature = "Extreme temperature value"
case wind = "Wind"
case fireWarning = "Fire warning"
case coastalEvent = "Marine event"
case flooding = "Flood"
@liudasbar
liudasbar / CustomSegmentedControlWithAnimation.swift
Created September 27, 2021 19:00
SwiftUI Custom Segmented Control with animation
struct CustomSegmentedControl: View {
@Binding var arrayOfItems: [Item]
@Binding var selection: Item
@State private var frames: [CGRect] = Array(repeating: .zero, count: 3)
var body: some View {
ScrollView(.horizontal, showsIndicators: false, content: {
HStack(spacing: 0) {
ForEach(arrayOfItems.indices, id: \.self) { index in
Button(