Skip to content

Commit

Permalink
Added support for memory classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszj committed Jul 3, 2016
1 parent 24b5179 commit 379f0b3
Show file tree
Hide file tree
Showing 40 changed files with 483 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Images.xcassets/memory/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
41 changes: 41 additions & 0 deletions Images.xcassets/memory/m_1gb.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "blue.png",
"memory" : "1GB",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "1GB",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "1GB",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Images.xcassets/memory/m_1gb.imageset/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images.xcassets/memory/m_1gb.imageset/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Images.xcassets/memory/m_2gb.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "blue.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "cyan.png",
"memory" : "2GB",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "2GB",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "2GB",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Images.xcassets/memory/m_2gb.imageset/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images.xcassets/memory/m_2gb.imageset/cyan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Images.xcassets/memory/m_4gb.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "cyan.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "green.png",
"memory" : "4GB",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "4GB",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"memory" : "4GB",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Images.xcassets/memory/m_4gb.imageset/cyan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images.xcassets/memory/m_4gb.imageset/green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Images.xcassets/memory/m_no.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "green.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Images.xcassets/memory/m_no.imageset/green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Support Mac, iOS and AppleWatch assets. Can extract PNG and PDF files.
| 4 inch iPhone ||
| Size classes ||
| Slicing ||
| Memory class | |
| Memory class | |
| Graphics class ||
| Data ||
| PDF ||
Expand Down
12 changes: 6 additions & 6 deletions Templates.xcassets/colors/cyan.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "cyan.png"
"filename" : "cyan.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "[email protected]"
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
Expand Down
4 changes: 4 additions & 0 deletions acextract.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
96A84A5D1D0DF0D500B79D25 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A84A5B1D0DF0D500B79D25 /* Main.storyboard */; };
96A84A5F1D0DF0D500B79D25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A84A5E1D0DF0D500B79D25 /* Assets.xcassets */; };
96A84A661D0DF0EF00B79D25 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9625C14A1A48C24A00EE5162 /* Images.xcassets */; };
96CB28C51D29411C003B94BB /* MemoryClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CB28C41D29411C003B94BB /* MemoryClassTests.swift */; };
96D010831D173194000553B1 /* CorrectnessTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D010821D173194000553B1 /* CorrectnessTests.swift */; };
96E36DDB1D2472CB00985687 /* GraphicalClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */; };
96E9F6AA1D0DD320001588FF /* AssetsCatalogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E9F6A91D0DD320001588FF /* AssetsCatalogTests.swift */; };
Expand Down Expand Up @@ -170,6 +171,7 @@
96A84A5C1D0DF0D500B79D25 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
96A84A5E1D0DF0D500B79D25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A84A601D0DF0D500B79D25 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96CB28C41D29411C003B94BB /* MemoryClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MemoryClassTests.swift; sourceTree = "<group>"; };
96D010821D173194000553B1 /* CorrectnessTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CorrectnessTests.swift; sourceTree = "<group>"; };
96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphicalClassTests.swift; sourceTree = "<group>"; };
96E9F6A71D0DD31F001588FF /* acextractTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = acextractTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -400,6 +402,7 @@
96D010821D173194000553B1 /* CorrectnessTests.swift */,
96F446651D15DB6F00F30964 /* DeviceTests.swift */,
96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */,
96CB28C41D29411C003B94BB /* MemoryClassTests.swift */,
96F52BFB1D1FFB89006CAD7B /* SizeClassTests.swift */,
9666CE241D21B363009C9402 /* SlicesTests.swift */,
9669A6351D20332D0037654D /* TemplateRenderingTests.swift */,
Expand Down Expand Up @@ -779,6 +782,7 @@
9673B97A1D205CE900F3C684 /* AlignmentTests.swift in Sources */,
96D010831D173194000553B1 /* CorrectnessTests.swift in Sources */,
9666CE251D21B363009C9402 /* SlicesTests.swift in Sources */,
96CB28C51D29411C003B94BB /* MemoryClassTests.swift in Sources */,
961427121D1F1186005831AA /* Assets.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
11 changes: 9 additions & 2 deletions acextract/CoreUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ typedef NS_ENUM(NSInteger, CUIGraphicalClass) {
CUIGraphicalClassMetal3v1 = 3,
};

typedef NS_ENUM(NSInteger, CUIMemoryClass) {
CUIMemoryClassDefault = 0,
CUIMemoryClassMemory1GB = 1,
CUIMemoryClassMemory2GB = 2,
CUIMemoryClassMemory4GB = 3,
};

@class CUIRenditionSliceInformation;

@interface CUIRenditionKey : NSObject <NSCopying, NSCoding>

- (CUIGraphicalClass)themeGraphicsClass;
- (long long)themeMemoryClass;
- (CUIMemoryClass)themeMemoryClass;

@end

Expand Down Expand Up @@ -182,7 +189,7 @@ typedef NS_ENUM(NSInteger, CUIGraphicalClass) {

- (nonnull CUIRenditionKey *)baseKey;
- (CUIGraphicalClass)graphicsClass;
- (long long)memoryClass;
- (CUIMemoryClass)memoryClass;


@end
Expand Down
39 changes: 38 additions & 1 deletion acextract/CoreUI_Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,40 @@ extension CUIGraphicalClass: CustomStringConvertible {
}
}

// MARK: CUIMemoryClass
extension CUIMemoryClass: NameStringConvertible {
var name: String {
switch self {
case .Default: return ""
case .Memory1GB: return "1gb"
case .Memory2GB: return "2gb"
case .Memory4GB: return "4gb"
}
}
}

extension CUIMemoryClass: ValueCorrectness, IncorrectValueAssertion {
var correct: Bool {
switch self {
case .Default: return rawValue == Default.rawValue
case .Memory1GB: return rawValue == Memory1GB.rawValue
case .Memory2GB: return rawValue == Memory2GB.rawValue
case .Memory4GB: return rawValue == Memory4GB.rawValue
}
}
}

extension CUIMemoryClass: CustomStringConvertible {
public var description: String {
switch self {
case .Default: return "default"
case .Memory1GB: return "1GB"
case .Memory2GB: return "2GB"
case .Memory4GB: return "4GB"
}
}
}

// MARK: CUINamedImage
extension CUINamedImage {
var acScale: ScaleFactor {
Expand Down Expand Up @@ -324,6 +358,9 @@ extension CUINamedImage {
// Graphical class
let graphics = self.graphicsClass().name

// Memory class
let memory = self.memoryClass().name

// Size class suffix
let sizeClassSuffix = acSizeClassString

Expand All @@ -339,6 +376,6 @@ extension CUINamedImage {
// File extension
let fileExtension = acFileExtension

return "\(self.name)\(graphics)\(sizeClassSuffix)\(subtype)\(scale)\(idiom).\(fileExtension)"
return "\(self.name)\(graphics)\(memory)\(sizeClassSuffix)\(subtype)\(scale)\(idiom).\(fileExtension)"
}
}
12 changes: 6 additions & 6 deletions acextract/PrintInformationOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extension CUIRenderMode: InformationPrintable { }
extension CUIResizingMode: InformationPrintable { }
extension CUIImageType: InformationPrintable { }
extension CUIGraphicalClass: InformationPrintable { }
extension CUIMemoryClass: InformationPrintable { }

// MARK: - PrintInformationOperation
struct PrintInformationOperation: Operation {
Expand Down Expand Up @@ -176,7 +177,7 @@ struct PrintInformationOperation: Operation {
// renditionKey() -> CUIRenditionKey
// printProperty("rendition key", value: namedImage.renditionKey())
namedImage.renditionKey().themeGraphicsClass().printWithLabel("rendition key graphical class")
printProperty("rendition key memory class", value: namedImage.renditionKey().themeMemoryClass())
namedImage.renditionKey().themeMemoryClass().printWithLabel("rendition key memory class")

// _rendition() -> CUIThemeRendition
printProperty("rendition name", value: namedImage._rendition().name())
Expand All @@ -202,8 +203,8 @@ struct PrintInformationOperation: Operation {
printProperty("scale", value: namedImage.acScale.informationName)
namedImage.sizeClassHorizontal().printWithLabel("size vlass horizontal")
namedImage.sizeClassVertical().printWithLabel("size vlass vertical")
namedImage.graphicsClass().printWithLabel("graphics Class")
printProperty("memory Class", value: namedImage.memoryClass())
namedImage.graphicsClass().printWithLabel("graphics class")
namedImage.memoryClass().printWithLabel("memory class")
printProperty("opacity", value: namedImage.opacity)
printProperty("size", value: namedImage.size)
printProperty("blend mode", value: namedImage.blendMode)
Expand All @@ -220,8 +221,7 @@ struct PrintInformationOperation: Operation {

// baseKey -> CUIRenditionKey
// printProperty("base key", value: namedImage.baseKey())
printProperty("base key graphical class", value: namedImage.baseKey().themeGraphicsClass())
printProperty("base key memory class", value: namedImage.baseKey().themeMemoryClass())

namedImage.baseKey().themeGraphicsClass().printWithLabel("base key graphical class")
namedImage.baseKey().themeMemoryClass().printWithLabel("base key memory class")
}
}
Loading

0 comments on commit 379f0b3

Please sign in to comment.