Skip to content

Instantly share code, notes, and snippets.

View indyfromoz's full-sized avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
@indyfromoz
indyfromoz / AMAlbumDetailsView.swift
Created October 28, 2024 20:12 — forked from tarrouye/AMAlbumDetailsView.swift
Sample code replicating the album details / track list screen from Apple Music
struct AMAlbumDetailsView: View {
let albumArt: Image
let title: String
let artist: String
let genre: String
let releaseYear: String
let quality: String
let tracks: [String]
@State private var playingTrack: String?
@indyfromoz
indyfromoz / LICENSE
Created June 26, 2022 01:36 — forked from zach-klippenstein/SegmentedControl.kt
iOS-style segmented control in Compose
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
@indyfromoz
indyfromoz / DotsLoaders.kt
Created March 19, 2021 08:15 — forked from EugeneTheDev/DotsLoaders.kt
Dots loading animations with Jetpack Compose
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@indyfromoz
indyfromoz / PreviewProviderModifier.swift
Created October 20, 2020 22:28 — forked from davidsteppenbeck/PreviewProviderModifier.swift
A SwiftUI view modifier for simple preview providers.
#if DEBUG
import SwiftUI
struct PreviewProviderModifier: ViewModifier {
/// Whether or not a basic light mode preview is included in the group.
var includeLightMode: Bool
/// Whether or not a basic dark mode preview is included in the group.
var includeDarkMode: Bool
import SwiftUI
import UIKit
private struct ColorConversionError: Swift.Error {
let reason: String
}
extension Color {
var uiColor: UIColor {
struct ContentView: View {
@State var tab = 0
@State var selections: [Int:Int] = [:]
var body: some View {
ZStack {
TabView(selection: $tab) {
NavigationView {
PageView(n: 0, selections: $selections)
}.navigationViewStyle(StackNavigationViewStyle()).tabItem { Text("Pages") }.tag(0)
import Cocoa
extension Collection {
func firstMap<T>(_ transform: @escaping (Element) -> T?) -> T? {
for element in self {
if let transformed = transform(element) {
return transformed
}
}
return nil
@indyfromoz
indyfromoz / Example_Complex.swift
Created July 30, 2020 09:32 — forked from IanKeen/Example_Complex.swift
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
struct User: Equatable {
var firstName: String
var lastName: String
}
@main
struct MyApp: App {
@State var value = User(firstName: "", lastName: "")
@State var showEdit = false
import SwiftUI
struct ConditionalContent<TrueContent: View, FalseContent: View>: View {
let value: Bool
let trueContent: () -> TrueContent
let falseContent: () -> FalseContent
var body: some View {
if value {
return AnyView(trueContent())
@indyfromoz
indyfromoz / iPod.swift
Created July 28, 2020 03:39 — forked from jordansinger/iPod.swift
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}