Skip to content

Instantly share code, notes, and snippets.

View marybnq's full-sized avatar

Federica Benacquista marybnq

View GitHub Profile
@marybnq
marybnq / HScrollableGrid.swift
Last active August 17, 2022 06:56
Horizontal Scrollable Grid in SwiftUI - correct
var body: some View {
VStack{
ScrollView(.horizontal){
HStack {
ForEach(names, id: \.self) {name in
ZStack{
LinearGradient(colors: [.pink.opacity(0.5),.purple.opacity(0.7)], startPoint: .top, endPoint: .bottom)
.frame(width: 90, height: 90, alignment: .center)
.clipShape(RoundedRectangle(cornerRadius: 25))
@marybnq
marybnq / HScrollableGrid.swift
Last active August 17, 2022 06:55
A one-row scrollable LazyHGrid in SwiftUI
//Images' names
var names: [String] = ["heart.fill",
"star.fill",
"circle.hexagongrid.fill",
"leaf.fill",
"sun.max.fill",
"ladybug.fill",
"moon.fill",
"sparkles",
"snowflake"
@marybnq
marybnq / Calculator.swift
Created July 5, 2021 08:36
A class containing the actual dimensions of the iOS keyboard
class Calculator {
/**
@return height of the view containing the keyboard buttons
*/
static func getKeyboardHeight()->CGFloat{
if UIDevice.current.userInterfaceIdiom == .phone {
// Portrait Landscape
return getWidth() < getHeight() ? 216 : 162
@marybnq
marybnq / LocalizedStrings.swift
Last active June 9, 2021 16:52
A struct inside a String extension to store our app's localized strings
//
// LocalizedStrings.swift
// Localization
//
// Created by Federica Benacquista on 09/06/21.
//
import UIKit
extension String{
/*Here goes the previous code, you can find it at:
@marybnq
marybnq / LocalizedStrings.swift
Last active June 9, 2021 16:32
A String extension to quickly create NSLocalizedString in Swift
//
// LocalizedStrings.swift
// Localization
//
// Created by Federica Benacquista on 09/06/21.
//
import UIKit
extension String{
@marybnq
marybnq / KeyboardHeightDetector.swift
Last active March 10, 2025 06:21
Code to calculate height of current device's keyboard
struct ScreenSize {
static let width = UIScreen.main.bounds.size.width
static let height = UIScreen.main.bounds.size.height
static let maxLength = max(ScreenSize.width, ScreenSize.height) //Gets the Height
static let minLength = min(ScreenSize.width, ScreenSize.height) //Gets the Width
}
//Contains the dimensions of the devices
fileprivate struct KeybDimensions{
//iPod touch(7), iPhone 5, iPhone 5s, iPhone 5C, iPhone SE