Skip to content

Instantly share code, notes, and snippets.

View rudrankriyam's full-sized avatar
🎵
Living.

Rudrank Riyam rudrankriyam

🎵
Living.
View GitHub Profile
@rudrankriyam
rudrankriyam / GradientGameNewTabView.swift
Last active October 9, 2020 19:53
The new tab view of gradient Game
import SwiftUI
struct TabView {
static let rgbTabName = "rgb"
static let rgbImageName = "circle.grid.hex"
static let hsbTabName = "hsb"
static let hsbImageName = "circle.grid.2x2"
static let historyTabName = "history"
@rudrankriyam
rudrankriyam / GradientGameNewMainView.swift
Created October 9, 2020 20:05
The new main view of gradient Game Raw
import SwiftUI
struct GGMainView: View {
@State private var showSheet = false
var body: some View {
VStack(spacing: 0) {
ZStack(alignment: .center) {
Text(RGBViewText.mainTitleText)
.tracking(1.0)
struct RGBView: View {
@State var leftTargetGradientRed = random()
@State var leftTargetGradientGreen = random()
@State var leftTargetGradientBlue = random()
@State var rightTargetGradientRed = random()
@State var rightTargetGradientGreen = random()
@State var rightTargetGradientBlue = random()
// @State var leftTargetGradientRed: Double = 65/255
@rudrankriyam
rudrankriyam / GradientGameColorProtocol.swift
Created October 9, 2020 20:21
Protocols of Gradient Game
import SwiftUI
protocol ColorProtocol {
var red: Double { get set }
var green: Double { get set }
var blue: Double { get set }
func newColor() -> Color
}
@rudrankriyam
rudrankriyam / WidgetsGuide.md
Last active October 16, 2020 13:47
A list of resources I found helpful while creating Widgets for iOS 14.

WidgetKit Resources

I recently got the chance to work with WidgetKit, and wanted to share my experience of the resources I used for the same.

First and foremost, the documentation is solid this year. "No overview available" is rarely there. So, going through the documentation before starting with WWDC sessions really gave me a gist of what Widgets are, and how they work.

The second resource I really liked was great WWDC sessions. The order in which I followed them -

@rudrankriyam
rudrankriyam / WidgetAccessibilityLargeCategory.swift
Last active October 25, 2020 11:21
Accessibility in iOS 14 Widgets With SwiftUI
import SwiftUI
struct SimpleEntryView: View {
var entry: Provider.Entry
@Environment(\.sizeCategory) var category
var body: some View {
if category >= .extraExtraLarge {
// Handle design for large text sizes
} else {
@rudrankriyam
rudrankriyam / WidgetAccessibilitySizeCategory.swift
Last active October 25, 2020 11:19
Accessibility in iOS 14 Widgets With SwiftUI
import SwiftUI
struct SimpleEntryView: View {
var entry: Provider.Entry
@Environment(\.sizeCategory) var category
var body: some View {
if category.isAccessibilityCategory {
// Handle design for accessibility text sizes
} else {
@rudrankriyam
rudrankriyam / WidgetLegibilityWeight.swift
Created October 25, 2020 11:20
Accessibility in iOS 14 Widgets With SwiftUI
import SwiftUI
struct SimpleEntryView : View {
var entry: Provider.Entry
@Environment(\.legibilityWeight) var legibilityWeight
var body: some View {
Text("Bold Text")
.fontWeight(legibilityWeight == .bold ? .bold : .light)
.font(.body)
@rudrankriyam
rudrankriyam / MainView.swift
Last active November 7, 2020 14:53
Gradient Game: TabView and SidebarView
import SwiftUI
struct MainView: View {
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
var body: some View {
#if os(macOS)
SidebarMainView().frame(minWidth: 200, idealWidth: 250, maxWidth: 300)
@rudrankriyam
rudrankriyam / AYImage.swift
Last active November 13, 2020 15:23
AYImage for creating accessible SF symbols!
import SwiftUI
@available(macOS 11.0, *)
struct AYImage: View {
private var isHidden = false
private var systemName: String
private var label: Text = Text("")
/// Creates a labeled system symbol image that you can use as
/// content for controls, with the specified label for accessibility.