Permalink
Browse files

Get building with PSPDFKit by avoiding redefinition of certain enums …

…that wern't changed when steipete changed the class prefix from PS to PST (unfortunately another library has the same prefix a day before public release)
  • Loading branch information...
1 parent dd6fe14 commit eca794b9ea24ec0915a23cd7a61491299b7f0010 Lawrence Lomax committed Sep 20, 2012
@@ -61,15 +61,15 @@ typedef NS_ENUM(NSInteger, UICollectionViewScrollDirection) {
@end
// @steipete addition, private API in UICollectionViewFlowLayout
-NSString *const PSFlowLayoutCommonRowHorizontalAlignmentKey;
-NSString *const PSFlowLayoutLastRowHorizontalAlignmentKey;
-NSString *const PSFlowLayoutRowVerticalAlignmentKey;
-
-typedef NS_ENUM(NSInteger, PSFlowLayoutHorizontalAlignment) {
- PSFlowLayoutHorizontalAlignmentLeft,
- PSFlowLayoutHorizontalAlignmentCentered,
- PSFlowLayoutHorizontalAlignmentRight,
- PSFlowLayoutHorizontalAlignmentJustify // 3; default except for the last row
+NSString *const PSTFlowLayoutCommonRowHorizontalAlignmentKey;
+NSString *const PSTFlowLayoutLastRowHorizontalAlignmentKey;
+NSString *const PSTFlowLayoutRowVerticalAlignmentKey;
+
+typedef NS_ENUM(NSInteger, PSTFlowLayoutHorizontalAlignment) {
+ PSTFlowLayoutHorizontalAlignmentLeft,
+ PSTFlowLayoutHorizontalAlignmentCentered,
+ PSTFlowLayoutHorizontalAlignmentRight,
+ PSTFlowLayoutHorizontalAlignmentJustify // 3; default except for the last row
};
// TODO: settings for UIFlowLayoutRowVerticalAlignmentKey
@@ -16,9 +16,9 @@
NSString *const PSTCollectionElementKindSectionFooter = @"UICollectionElementKindSectionFooter";
// this is not exposed in UICollectionViewFlowLayout
-NSString *const PSFlowLayoutCommonRowHorizontalAlignmentKey = @"UIFlowLayoutCommonRowHorizontalAlignmentKey";
-NSString *const PSFlowLayoutLastRowHorizontalAlignmentKey = @"UIFlowLayoutLastRowHorizontalAlignmentKey";
-NSString *const PSFlowLayoutRowVerticalAlignmentKey = @"UIFlowLayoutRowVerticalAlignmentKey";
+NSString *const PSTFlowLayoutCommonRowHorizontalAlignmentKey = @"UIFlowLayoutCommonRowHorizontalAlignmentKey";
+NSString *const PSTFlowLayoutLastRowHorizontalAlignmentKey = @"UIFlowLayoutLastRowHorizontalAlignmentKey";
+NSString *const PSTFlowLayoutRowVerticalAlignmentKey = @"UIFlowLayoutRowVerticalAlignmentKey";
@interface PSTCollectionViewFlowLayout() {
@@ -80,10 +80,10 @@ - (id)init {
// set default values for row alignment.
_rowAlignmentsOptionsDictionary = @{
- PSFlowLayoutCommonRowHorizontalAlignmentKey : @(PSFlowLayoutHorizontalAlignmentJustify),
- PSFlowLayoutLastRowHorizontalAlignmentKey : @(PSFlowLayoutHorizontalAlignmentLeft),
+ PSTFlowLayoutCommonRowHorizontalAlignmentKey : @(PSTFlowLayoutHorizontalAlignmentJustify),
+ PSTFlowLayoutLastRowHorizontalAlignmentKey : @(PSTFlowLayoutHorizontalAlignmentLeft),
// TODO: those values are some enum. find out what what is.
- PSFlowLayoutRowVerticalAlignmentKey : @(1),
+ PSTFlowLayoutRowVerticalAlignmentKey : @(1),
};
}
return self;
@@ -100,7 +100,7 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
if (CGRectIntersectsRect(section.frame, rect)) {
// if we have fixed size, calculate item frames only once.
- // this also uses the default PSFlowLayoutCommonRowHorizontalAlignmentKey alignment
+ // this also uses the default PSTFlowLayoutCommonRowHorizontalAlignmentKey alignment
// for the last row. (we want this effect!)
NSArray *itemRects = _cachedItemRects;
if (!_cachedItemRects && section.fixedItemSize && [section.rows count]) {
@@ -60,7 +60,7 @@ - (NSArray *)layoutRowAndGenerateRectArray:(BOOL)generateRectArray {
// properties for aligning
BOOL isHorizontal = self.section.layoutInfo.horizontal;
BOOL isLastRow = self.section.indexOfImcompleteRow == self.index;
- PSFlowLayoutHorizontalAlignment horizontalAlignment = [self.section.rowAlignmentOptions[isLastRow ? PSFlowLayoutLastRowHorizontalAlignmentKey : PSFlowLayoutCommonRowHorizontalAlignmentKey] integerValue];
+ PSTFlowLayoutHorizontalAlignment horizontalAlignment = [self.section.rowAlignmentOptions[isLastRow ? PSTFlowLayoutLastRowHorizontalAlignmentKey : PSTFlowLayoutCommonRowHorizontalAlignmentKey] integerValue];
// calculate space that's left over if we would align it from left to right.
CGFloat leftOverSpace = self.section.layoutInfo.dimension;
@@ -83,9 +83,9 @@ - (NSArray *)layoutRowAndGenerateRectArray:(BOOL)generateRectArray {
}
}
CGPoint itemOffset = CGPointZero;
- if (horizontalAlignment == PSFlowLayoutHorizontalAlignmentRight) {
+ if (horizontalAlignment == PSTFlowLayoutHorizontalAlignmentRight) {
itemOffset.x += leftOverSpace;
- }else if(horizontalAlignment == PSFlowLayoutHorizontalAlignmentCentered) {
+ }else if(horizontalAlignment == PSTFlowLayoutHorizontalAlignmentCentered) {
itemOffset.x += leftOverSpace/2;
}
@@ -101,13 +101,13 @@ - (NSArray *)layoutRowAndGenerateRectArray:(BOOL)generateRectArray {
if (isHorizontal) {
itemFrame.origin.y = itemOffset.y;
itemOffset.y += itemFrame.size.height + self.section.verticalInterstice;
- if (horizontalAlignment == PSFlowLayoutHorizontalAlignmentJustify) {
+ if (horizontalAlignment == PSTFlowLayoutHorizontalAlignmentJustify) {
itemOffset.y += leftOverSpace/(CGFloat)(self.itemCount-1);
}
}else {
itemFrame.origin.x = itemOffset.x;
itemOffset.x += itemFrame.size.width + self.section.horizontalInterstice;
- if (horizontalAlignment == PSFlowLayoutHorizontalAlignmentJustify) {
+ if (horizontalAlignment == PSTFlowLayoutHorizontalAlignmentJustify) {
itemOffset.x += leftOverSpace/(CGFloat)(self.itemCount-1);
}
}

0 comments on commit eca794b

Please sign in to comment.