SFSymbols Enum PowerUP

Symbols into Views

Try out some of this code... to power up your Swifty Views.

Turn an Enum into a powerful set of SF Symbol Views.

//

// SFSymbols_Enum.swift

// Toolbox

//

// Created by David on 2/16/21.

// Copyright © 2021 Life Works IQ Consulting. All rights reserved.

//


import SwiftUI


enum SFSymbols: String, View {

case close_no_circle = "xmark"

case close = "xmark.circle"

case back = "arrowshape.turn.up.backward.fill"

case tab_1 = "gearshape.fill"

case tab_2 = "magnifyingglass"

case tab_3 = "house"

case tab_4 = "folder.badge.gear"

case tab_5 = "square.and.arrow.up"

case swipe = "hand.draw"

case tap = "cursor.rays"

case shake = "waveform.path"

case selected = "checkmark.square"

var body: Image {

Image(systemName: rawValue)

}

}


struct SFSymbols_Enum: View {

@State var isPresented = true

var body: some View {

Button(action: {

self.isPresented = false // dismiss the Toolbox view

}, label: {

//Image(systemName: "xmark.circle" )

SFSymbols.close

.scaledFont(name: "Avenir Oblique", size: Const.titleText)

.minimumScaleFactor(0.3)

.foregroundColor(.black)

.padding(10)

})

}

}


struct SFSymbols_Enum_Previews: PreviewProvider {

static var previews: some View {

SFSymbols_Enum()

}

}


//

// SFSymbols_Tests.swift

// ToolboxTests

//

// Created by David on 2/16/21.

// Copyright © 2021 Life Works IQ Consulting. All rights reserved.

//


import XCTest


@testable import AgileCoachingToolbox


class SFSymbols_Tests: XCTestCase {


override func setUpWithError() throws {

// Put setup code here. This method is called before the invocation of each test method in the class.

}


override func tearDownWithError() throws {

// Put teardown code here. This method is called after the invocation of each test method in the class.

}


func testExample() throws {

let view = SFSymbols.close

XCTAssertEqual(view.rawValue, "xmark.circle") // name of symbol

// now use it in a sentence - e.g. context

// Button(action: {

// self.isPresented = false // dismiss the Toolbox view

// }, label: {

// //Image(systemName: "xmark.circle" )

// SFSymbols.close

// .scaledFont(name: "Avenir Oblique", size: Const.titleText)

// .minimumScaleFactor(0.3)

// .foregroundColor(.black)

// .padding(10)

// })

}

}