Skip to content

Instantly share code, notes, and snippets.

View archieedwards's full-sized avatar

Archie archieedwards

View GitHub Profile
@archieedwards
archieedwards / a_simple_alert.swift
Last active May 25, 2020 14:17
Simple Alert in SwiftUI
struct ContentView: View {
@State var showAlert = false
var body: some View {
Button(action: {
self.showAlert.toggle()
}, label: {
Text("SHOW ALERT")
struct ContentView: View {
@State var showAlert = false
var body: some View {
Button(action: {
self.showAlert.toggle()
}, label: {
Text("SHOW ALERT")
struct ContentView: View {
@State var showAlert = false
var body: some View {
Button(action: {
self.showAlert.toggle()
}, label: {
Text("SHOW ALERT")
struct ContentView: View {
@State var showAlertOne = false
@State var showAlertTwo = false
var body: some View {
VStack{
/// button 1
struct AlertItem: Identifiable {
var id = UUID()
var title = Text("")
var message: Text?
var dismissButton: Alert.Button?
var primaryButton: Alert.Button?
var secondaryButton: Alert.Button?
}
struct ContentView: View {
@State var alertItem : AlertItem?
var body: some View {
VStack{
/// button 1
Button(action: {
struct ContentView: View {
@State var alertItem : AlertItem?
var body: some View {
/// button
Button(action: {
self.alertItem = AlertItem(title: Text("I'm an alert"), message: Text("Are you sure about this?"), primaryButton: .default(Text("Yes"), action: {
@archieedwards
archieedwards / CategoryTextView_SpotifySwiftUI.swift
Last active June 9, 2020 21:04
View to show Music and Podcasts ...
struct CategoryText: View {
@Binding var currentCategoryIndex : Int
@Binding var nestedPages : [Int]
var body: some View {
HStack(spacing: 20){
Text("Music")
.font(.largeTitle).bold()
.foregroundColor(self.currentCategoryIndex == 0 ? .primary : .secondary)
.onTapGesture {
self.nestedPages = [0,0]
@archieedwards
archieedwards / SubCategoryTextView_SpotifySwiftUI.swift
Last active June 9, 2020 10:58
View to show sub categories and green indicator bar
struct SubCategoryText: View {
var subCategorys : [String]
@Binding var currentSubCategoryIndex : Int
@Binding var indicatorOffset : CGFloat
var body: some View {
HStack{
subCategory(index: 0, parent: self)
subCategory(index: 1, parent: self)
subCategory(index: 2, parent: self)
@archieedwards
archieedwards / MediaContentView_SpotifySwiftUI.swift
Created June 9, 2020 11:27
a view to simulate common sub category views..
struct MediaContentView: View {
var colours : [Color] = [.red, .orange, .green, .pink, .purple, .yellow]
var body: some View {
ScrollView(.vertical, showsIndicators: true){
ForEach(0..<10) {_ in
HStack{
Rectangle()
.frame(width: UIScreen.main.bounds.size.width/6 , height: UIScreen.main.bounds.size.height/12)
.foregroundColor(self.colours[Int.random(in: 0 ... 5 )])
VStack(alignment: .leading){