Skip to content

Commit

Permalink
example app nft views + config
Browse files Browse the repository at this point in the history
  • Loading branch information
VPhung24 committed May 23, 2023
1 parent 27e6fc9 commit df0da4b
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
BlueprintIdentifier = "0877BF8F2A1C18D500A236AB"
BuildableName = "SnowballSwiftExample.app"
BlueprintName = "SnowballSwiftExample"
ReferencedContainer = "container:SnowballSwiftExample.xcodeproj">
ReferencedContainer = "container:SnowballSwiftExample/SnowballSwiftExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SnowballSwiftKit"
BuildableName = "SnowballSwiftKit"
BlueprintName = "SnowballSwiftKit"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -37,7 +51,7 @@
BlueprintIdentifier = "0877BF9F2A1C18D600A236AB"
BuildableName = "SnowballSwiftExampleTests.xctest"
BlueprintName = "SnowballSwiftExampleTests"
ReferencedContainer = "container:SnowballSwiftExample.xcodeproj">
ReferencedContainer = "container:SnowballSwiftExample/SnowballSwiftExample.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
Expand All @@ -48,7 +62,7 @@
BlueprintIdentifier = "0877BFA92A1C18D600A236AB"
BuildableName = "SnowballSwiftExampleUITests.xctest"
BlueprintName = "SnowballSwiftExampleUITests"
ReferencedContainer = "container:SnowballSwiftExample.xcodeproj">
ReferencedContainer = "container:SnowballSwiftExample/SnowballSwiftExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
Expand All @@ -70,7 +84,7 @@
BlueprintIdentifier = "0877BF8F2A1C18D500A236AB"
BuildableName = "SnowballSwiftExample.app"
BlueprintName = "SnowballSwiftExample"
ReferencedContainer = "container:SnowballSwiftExample.xcodeproj">
ReferencedContainer = "container:SnowballSwiftExample/SnowballSwiftExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
Expand All @@ -87,7 +101,7 @@
BlueprintIdentifier = "0877BF8F2A1C18D500A236AB"
BuildableName = "SnowballSwiftExample.app"
BlueprintName = "SnowballSwiftExample"
ReferencedContainer = "container:SnowballSwiftExample.xcodeproj">
ReferencedContainer = "container:SnowballSwiftExample/SnowballSwiftExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# SnowballSwiftKit

Lots to do!! SwiftUI Component Kit supporting iOS 15.0+
Lots to do!! SwiftUI Component Kit supporting iOS 15.0+.

## Getting Started

- Easiest way to open [both the SnowballSwiftKit Package and SnowballSwiftKit Example App] is via the bash script `start` or open `SnowballSwiftKit/SnowballSwiftExample/SnowballSwiftExample.xcodeproj`
- Easiest way to open -- both the `SnowballSwiftKit` Package and `SnowballSwiftExample` App -- is via the bash script `start` or open `SnowballSwiftExample/SnowballSwiftExample.xcodeproj`
- [swiftlint](https://github.com/realm/SwiftLint)
- [apple package manager plugins](https://github.com/apple/swift-package-manager/blob/main/Documentation/Plugins.md)

Soon: (send me a tg @ vivianphung if u want anything sooner)
- [Custom SF Symbols Collection](https://www.david-smith.org/blog/2023/01/23/design-notes-18/)
- Snowball Component Kit documentation site
- SnowballKotlinKit (for [Jetpack](https://developer.android.com/jetpack))
### `Config.xcconfig`

For now, until an app wide `SnowballSettings` is arch, edit `Config.xcconfig` with API Keys to test out some of the custom views such as `SnowballNFTGridView` and `SnowballNFTListView`.

Read more on [Config / Dev Mode](https://nshipster.com/xcconfig/)

## Soon
(send me a telegram @vivianphung if u want anything sooner)
- 'SnowballSettings' for app wide configs
- Login with wallet / email flow
- [Custom SF Symbols Collection](https://www.david-smith.org/blog/2023/01/23/design-notes-18/)
- Snowball Kit documentation site
- 'SnowballKotlinKit' (for [Jetpack](https://developer.android.com/jetpack))
11 changes: 11 additions & 0 deletions SnowballSwiftExample/Config.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Config.xcconfig
// SnowballSwiftExample
//
// Created by Vivian Phung on 5/22/23.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

ALCHEMY_NFT_KEY = PasteNFTKeyHere
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
0877BFAF2A1C18D600A236AB /* SnowballSwiftExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877BFAE2A1C18D600A236AB /* SnowballSwiftExampleUITests.swift */; };
0877BFB12A1C18D600A236AB /* SnowballSwiftExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0877BFB02A1C18D600A236AB /* SnowballSwiftExampleUITestsLaunchTests.swift */; };
0877BFC02A1C195F00A236AB /* SnowballSwiftKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0877BFBF2A1C195F00A236AB /* SnowballSwiftKit */; };
08801CBD2A1C438500C98ADF /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 08801CBC2A1C438500C98ADF /* Config.xcconfig */; };
08801CBF2A1C484C00C98ADF /* SnowballSwiftExampleNFTView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08801CBE2A1C484C00C98ADF /* SnowballSwiftExampleNFTView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -50,6 +52,9 @@
0877BFAE2A1C18D600A236AB /* SnowballSwiftExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnowballSwiftExampleUITests.swift; sourceTree = "<group>"; };
0877BFB02A1C18D600A236AB /* SnowballSwiftExampleUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnowballSwiftExampleUITestsLaunchTests.swift; sourceTree = "<group>"; };
0877BFBD2A1C192600A236AB /* SnowballSwiftKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SnowballSwiftKit; path = ..; sourceTree = "<group>"; };
08801CBC2A1C438500C98ADF /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = SOURCE_ROOT; };
08801CBE2A1C484C00C98ADF /* SnowballSwiftExampleNFTView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnowballSwiftExampleNFTView.swift; sourceTree = "<group>"; };
08F1AAB32A1C405500BD4CC7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -81,6 +86,7 @@
084672F22A1C372600C7FB93 /* Example Views */ = {
isa = PBXGroup;
children = (
08801CBE2A1C484C00C98ADF /* SnowballSwiftExampleNFTView.swift */,
084672EE2A1C2B8B00C7FB93 /* SnowballSwiftExampleText.swift */,
084672F02A1C2FFF00C7FB93 /* SnowballSwiftExampleButtonsView.swift */,
);
Expand Down Expand Up @@ -115,6 +121,8 @@
0877BF952A1C18D500A236AB /* SnowballSwiftKitHomeView.swift */,
084672F22A1C372600C7FB93 /* Example Views */,
0877BF972A1C18D600A236AB /* Assets.xcassets */,
08801CBC2A1C438500C98ADF /* Config.xcconfig */,
08F1AAB32A1C405500BD4CC7 /* Info.plist */,
0877BF992A1C18D600A236AB /* Preview Content */,
);
path = SnowballSwiftExample;
Expand Down Expand Up @@ -253,6 +261,7 @@
buildActionMask = 2147483647;
files = (
0877BF9B2A1C18D600A236AB /* Preview Assets.xcassets in Resources */,
08801CBD2A1C438500C98ADF /* Config.xcconfig in Resources */,
0877BF982A1C18D600A236AB /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -280,6 +289,7 @@
files = (
0877BF962A1C18D500A236AB /* SnowballSwiftKitHomeView.swift in Sources */,
084672F12A1C2FFF00C7FB93 /* SnowballSwiftExampleButtonsView.swift in Sources */,
08801CBF2A1C484C00C98ADF /* SnowballSwiftExampleNFTView.swift in Sources */,
0877BF942A1C18D500A236AB /* SnowballSwiftExampleApp.swift in Sources */,
084672EF2A1C2B8B00C7FB93 /* SnowballSwiftExampleText.swift in Sources */,
);
Expand Down Expand Up @@ -320,6 +330,7 @@
/* Begin XCBuildConfiguration section */
0877BFB22A1C18D600A236AB /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 08801CBC2A1C438500C98ADF /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -434,6 +445,7 @@
};
0877BFB52A1C18D600A236AB /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 08801CBC2A1C438500C98ADF /* Config.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand All @@ -443,6 +455,7 @@
DEVELOPMENT_TEAM = 9SAQ42S589;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SnowballSwiftExample/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Snowball Swift Example App";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down Expand Up @@ -474,6 +487,7 @@
DEVELOPMENT_TEAM = 9SAQ42S589;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SnowballSwiftExample/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Snowball Swift Example App";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand All @@ -496,6 +510,7 @@
};
0877BFB82A1C18D600A236AB /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 08801CBC2A1C438500C98ADF /* Config.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
Expand Down Expand Up @@ -536,6 +551,7 @@
};
0877BFBB2A1C18D600A236AB /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 08801CBC2A1C438500C98ADF /* Config.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ import SnowballSwiftKit

struct SnowballSwiftExampleButtonsView: View {
@State var tappedButtonString: String = ""

var body: some View {
VStack(spacing: 15) {
Text("SnowballButton is just a convenient view! You can use buttons ButtonStyle (.danger, .plain, etc) on it to style")

Text("Tapped Button: \(tappedButtonString)")

SnowballButton(leftSystemIcon: "clipboard") {
self.tappedButtonString = "clipboard icon only"
}

SnowballButton(leftSystemIcon: "clipboard", text: "clipboard") {
self.tappedButtonString = "clipboard with *left* icon and text"
}

SnowballButton(text: "clipboard", rightSystemIcon: "clipboard") {
self.tappedButtonString = "clipboard with *right* icon and text"
}

SnowballButton(text: "clipboard") {
self.tappedButtonString = "clipboard text only"
}

Spacer()
VStack(alignment: .leading) {
Text("ex. ButtonStyle")
Expand All @@ -41,29 +41,29 @@ struct SnowballSwiftExampleButtonsView: View {
self.tappedButtonString = "danger"
})
.buttonStyle(.danger)

Button("plain", action: {
self.tappedButtonString = "plain"
})
.buttonStyle(.plain)

Button("bordered", action: {
self.tappedButtonString = "bordered"
})
.buttonStyle(.bordered)
}
}

Spacer()

VStack(alignment: .leading) {
Text("SwiftUI understands context")
HStack {
Button("styled 'Button'", action: {
self.tappedButtonString = "styled button"
})
.buttonStyle(.danger)

SnowballButton(text: "styled 'SnowballButton'") {
self.tappedButtonString = "styled snowball 'button'"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// SnowballSwiftExampleNFTGridView.swift
// SnowballSwiftExample
//
// Created by Vivian Phung on 5/22/23.
//

import SwiftUI
import SnowballSwiftKit

struct SnowballSwiftExampleNFTView: View {
// todo: Snowball Settings for app wide settings
var alchemyKey: String
var type: NFTViewType = .grid

var body: some View {
switch type {
case .grid:
SnowballNFTGridView(ethAddress: "vivianphung.eth", alchemyKey: alchemyKey)
case .list:
SnowballNFTListView(ethAddress: "vivianphung.eth", alchemyKey: alchemyKey)
}
}
}

enum NFTViewType: String {
case grid = "grid"
case list = "list"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ extension Font.TextStyle {
"Caption": .caption
]
}

8 changes: 8 additions & 0 deletions SnowballSwiftExample/SnowballSwiftExample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ALCHEMY_NFT_KEY</key>
<string>$(ALCHEMY_NFT_KEY)</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,33 @@ import SwiftUI
import SnowballSwiftKit

struct SnowballSwiftKitHomeView: View {
// todo: Snowball Settings for app wide settings
let alchemyKey: String = Bundle.main.infoDictionary?["ALCHEMY_NFT_KEY"] as? String ?? ""

var body: some View {
NavigationView {
List {
NavigationLink("Text") {
SnowballSwiftExampleText()
.navigationTitle("Text")
}

NavigationLink("Buttons") {
SnowballSwiftExampleButtonsView()
.navigationTitle("Buttons")
}

NavigationLink("NFT Grid View") {
SnowballSwiftExampleNFTView(alchemyKey: alchemyKey)
.navigationTitle("NFT Grid View")
}
.disabled(alchemyKey == "" || alchemyKey == "PasteNFTKeyHere")

NavigationLink("NFT List View") {
SnowballSwiftExampleNFTView(alchemyKey: alchemyKey, type: .list)
.navigationTitle("NFT List View")
}
.disabled(alchemyKey == "" || alchemyKey == "PasteNFTKeyHere")
}
.listStyle(.plain)
.navigationTitle("Snowball Example")
Expand Down
16 changes: 6 additions & 10 deletions Sources/SnowballSwiftKit/Views/SnowballNFTGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ public struct SnowballNFTGridView: View {
@StateObject private var viewModel = AlchemyNFTViewModel()
@State var ethAddress: String

// todo: snowball settings with api key
var alchemyKey: String

private var gridLayout: [GridItem] = [
GridItem(.flexible(), spacing: 10),
GridItem(.flexible(), spacing: 10)
]

public init(ethAddress: String) {
public init(ethAddress: String, alchemyKey: String) {
self.ethAddress = ethAddress
self.alchemyKey = alchemyKey
}

public var body: some View {
Expand All @@ -43,16 +47,8 @@ public struct SnowballNFTGridView: View {
.padding(10)
}
.onAppear {
viewModel.fetchNFTs(forAddress: self.ethAddress, key: "")
viewModel.fetchNFTs(forAddress: self.ethAddress, key: alchemyKey)
}
}
}
}

struct NFTGridView_Previews: PreviewProvider {
static var previews: some View {
Group {
SnowballNFTGridView(ethAddress: "vivianphung.eth")
}
}
}
Loading

0 comments on commit df0da4b

Please sign in to comment.