Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Commit

Permalink
inlinable style (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ay42 authored Mar 26, 2020
1 parent 978cc2e commit e352376
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 11 deletions.
7 changes: 4 additions & 3 deletions GridDemo iOS/ModularGrid/ModularGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ struct ModularGridView: View {
Card(title: "\(item.number)", color: item.color)
}
.padding(8)
.gridStyle(
self.style
)

}
.navigationBarTitle("Modular Grid", displayMode: .inline)
.navigationBarItems(
Expand All @@ -32,6 +30,9 @@ struct ModularGridView: View {
.sheet(isPresented: $showSettings) {
ModularGridSettingsView(style: self.$style).accentColor(.purple)
}
.gridStyle(
self.style
)
}

func addMoreItems() {
Expand Down
6 changes: 3 additions & 3 deletions GridDemo iOS/StaggeredGrid/StaggeredGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ struct StaggeredGridView: View {
}

)
.gridStyle(
self.style
)
.sheet(isPresented: $showSettings) {
StaggeredGridSettingsView(style: self.$style).accentColor(.purple)
}
.gridStyle(
self.style
)
}

func shuffleImages() {
Expand Down
2 changes: 2 additions & 0 deletions GridDemo macOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainStoryboardFile</key>
Expand Down
56 changes: 55 additions & 1 deletion GridDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1130;
LastUpgradeCheck = 1130;
LastUpgradeCheck = 1140;
TargetAttributes = {
FAA2C96623DEAECC00FBDE39 = {
CreatedOnToolsVersion = 11.3.1;
Expand Down Expand Up @@ -786,12 +786,64 @@
FAA2C94023DEAD2600FBDE39 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
FAA2C94123DEAD2600FBDE39 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Release;
};
Expand Down Expand Up @@ -971,6 +1023,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "GridDemo macOS/GridDemo_macOS.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -1045,6 +1098,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "GridDemo macOS/GridDemo_macOS.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

extension EnvironmentValues {
public extension EnvironmentValues {
var gridStyle: GridStyle {
get {
return self[GridStyleKey.self]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Grid/Styles/Style/GridStyleKey.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftUI

struct GridStyleKey: EnvironmentKey {
static let defaultValue: GridStyle = ModularGridStyle(columns: .min(100), rows: .min(100))
static let defaultValue: GridStyle = ModularGridStyle(columns: .min(100), rows: .fixed(100))
}
4 changes: 2 additions & 2 deletions Sources/Grid/Styles/Style/View+GridStyle.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SwiftUI

extension View {
public extension View {
/// Sets the style for `Grid` within the environment of `self`.
public func gridStyle<S>(_ style: S) -> some View where S : GridStyle {
@inlinable func gridStyle<S>(_ style: S) -> some View where S : GridStyle {
self.environment(\.gridStyle, style)
}
}

0 comments on commit e352376

Please sign in to comment.