Permalink
Browse files

Renamed some methods to make them more consistent & minor changes

  • Loading branch information...
1 parent 1fcbaef commit e1aeb5899b7cb5ab80eb2181a5411292648f51eb @gmoledina committed Oct 10, 2011
Showing with 115 additions and 81 deletions.
  1. +8 −0 .gitignore
  2. +0 −15 GMGridView.xcodeproj/project.pbxproj
  3. +36 −18 GMGridView/API/GMGridView.h
  4. +32 −14 GMGridView/API/GMGridView.m
  5. +32 −33 GMGridView/ViewController.m
  6. +7 −1 README
View
@@ -0,0 +1,8 @@
+.DS_Store
+Thumbs.db
+xcuserdata/
+*.xcodeproj/*.pbxuser
+*.xcodeproj/*.perspectivev3
+*.xcodeproj/xcuserdata/
+*.xcodeproj/project.xcworkspace/xcuserdata/
+*.xcuserstate
@@ -7,15 +7,13 @@
objects = {
/* Begin PBXBuildFile section */
- 1691D7A11442CFA800F472BF /* GMGridView-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1691D7A01442CFA800F472BF /* GMGridView-Info.plist */; };
1691D7A41442CFC300F472BF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A31442CFC300F472BF /* main.m */; };
1691D7AA1442D01F00F472BF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A71442D01F00F472BF /* AppDelegate.m */; };
1691D7AB1442D01F00F472BF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A91442D01F00F472BF /* ViewController.m */; };
1691D7AE1442D02C00F472BF /* GMGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7AD1442D02C00F472BF /* GMGridView.m */; };
16924B0C144156FE00E6E556 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0B144156FE00E6E556 /* UIKit.framework */; };
16924B0E144156FE00E6E556 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0D144156FE00E6E556 /* Foundation.framework */; };
16924B10144156FE00E6E556 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0F144156FE00E6E556 /* CoreGraphics.framework */; };
- 16924B16144156FE00E6E556 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 16924B14144156FE00E6E556 /* InfoPlist.strings */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -160,8 +158,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 16924B16144156FE00E6E556 /* InfoPlist.strings in Resources */,
- 1691D7A11442CFA800F472BF /* GMGridView-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -181,17 +177,6 @@
};
/* End PBXSourcesBuildPhase section */
-/* Begin PBXVariantGroup section */
- 16924B14144156FE00E6E556 /* InfoPlist.strings */ = {
- isa = PBXVariantGroup;
- children = (
- );
- name = InfoPlist.strings;
- path = "/Users/gmoledina/Documents/iOS Projects/GMGridView/DraggableGridView";
- sourceTree = "<absolute>";
- };
-/* End PBXVariantGroup section */
-
/* Begin XCBuildConfiguration section */
16924B26144156FE00E6E556 /* Debug */ = {
isa = XCBuildConfiguration;
@@ -3,19 +3,37 @@
// GMGridView
//
// Created by Gulam Moledina on 11-10-09.
-// Copyright (c) 2011 GMoledina.ca. All rights reserved.
+// Copyright (C) 2011 by Gulam Moledina.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
//
#import <UIKit/UIKit.h>
-@protocol DraggableGridViewDelegate;
-@protocol DraggableGridViewDataSource;
+@protocol GMGridViewDelegate;
+@protocol GMGridViewDataSource;
typedef enum
{
- DraggableGridViewStylePush = 0,
- DraggableGridViewStyleSwap
-} DraggableGridViewStyle;
+ GMGridViewStylePush = 0,
+ GMGridViewStyleSwap
+} GMGridViewStyle;
//////////////////////////////////////////////////////////////
@@ -27,11 +45,11 @@ typedef enum
}
-@property (nonatomic, weak) id<DraggableGridViewDataSource> dataSource;
-@property (nonatomic, weak) id<DraggableGridViewDelegate> delegate;
+@property (nonatomic, weak) id<GMGridViewDataSource> dataSource;
+@property (nonatomic, weak) id<GMGridViewDelegate> delegate;
@property (nonatomic, assign) NSInteger itemPadding;
-@property (nonatomic, assign) DraggableGridViewStyle style;
+@property (nonatomic, assign) GMGridViewStyle style;
@property (nonatomic) CFTimeInterval minimumPressDuration; // If set to 0, the scrollView will not be scrollable
- (void)reloadData;
@@ -47,12 +65,12 @@ typedef enum
#pragma mark Protocol DraggableGridViewDataSource
//////////////////////////////////////////////////////////////
-@protocol DraggableGridViewDataSource
+@protocol GMGridViewDataSource
-- (NSInteger)numberOfItemsInDraggableView:(GMGridView *)draggableView;
-- (NSInteger)widthForItemsInDraggableView:(GMGridView *)draggableView;
-- (NSInteger)heightForItemsInDraggableView:(GMGridView *)draggableView;
-- (UIView *)draggableView:(GMGridView *)draggableView viewForItemAtIndex:(NSInteger)index;
+- (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView;
+- (NSInteger)widthForItemsInGMGridView:(GMGridView *)gridView;
+- (NSInteger)heightForItemsInGMGridView:(GMGridView *)gridView;
+- (UIView *)GMGridView:(GMGridView *)gridView viewForItemAtIndex:(NSInteger)index;
@end
@@ -61,10 +79,10 @@ typedef enum
#pragma mark Protocol DraggableGridViewDelegate
//////////////////////////////////////////////////////////////
-@protocol DraggableGridViewDelegate
+@protocol GMGridViewDelegate
-- (void)draggableView:(GMGridView *)draggableView didStartMovingView:(UIView *)view;
-- (void)draggableView:(GMGridView *)draggableView didEndMovingView:(UIView *)view;
-- (void)draggableView:(GMGridView *)draggableView itemAtIndex:(NSInteger)oldIndex movedToIndex:(NSInteger)newIndex;
+- (void)GMGridView:(GMGridView *)gridView didStartMovingView:(UIView *)view;
+- (void)GMGridView:(GMGridView *)gridView didEndMovingView:(UIView *)view;
+- (void)GMGridView:(GMGridView *)gridView itemAtIndex:(NSInteger)oldIndex movedToIndex:(NSInteger)newIndex;
@end
@@ -3,7 +3,25 @@
// GMGridView
//
// Created by Gulam Moledina on 11-10-09.
-// Copyright (c) 2011 GMoledina.ca. All rights reserved.
+// Copyright (C) 2011 by Gulam Moledina.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
//
#import "GMGridView.h"
@@ -96,7 +114,7 @@ - (id)initWithFrame:(CGRect)frame
[self addSubview:m_scrollView];
self.itemPadding = 10;
- self.style = DraggableGridViewStylePush;
+ self.style = GMGridViewStylePush;
self.minimumPressDuration = 0.2;
m_futurePosition = -1;
@@ -132,7 +150,7 @@ - (void)layoutSubviews
#pragma mark Setters / getters
//////////////////////////////////////////////////////////////
-- (void)setDataSource:(NSObject<DraggableGridViewDataSource> *)dataSource
+- (void)setDataSource:(NSObject<GMGridViewDataSource> *)dataSource
{
mw_dataSource = dataSource;
[self reloadData];
@@ -254,7 +272,7 @@ - (void)movingDidStartAtPoint:(CGPoint)point
m_futurePosition = m_movingItem.tag;
- [self.delegate draggableView:self didStartMovingView:m_movingItem];
+ [self.delegate GMGridView:self didStartMovingView:m_movingItem];
}
- (void)movingDidContinueToPoint:(CGPoint)point
@@ -278,7 +296,7 @@ - (void)movingDidContinueToPoint:(CGPoint)point
{
switch (self.style)
{
- case DraggableGridViewStylePush:
+ case GMGridViewStylePush:
{
if (position > m_futurePosition)
{
@@ -302,7 +320,7 @@ - (void)movingDidContinueToPoint:(CGPoint)point
}
break;
}
- case DraggableGridViewStyleSwap:
+ case GMGridViewStyleSwap:
default:
{
UIView *v = [m_scrollView viewWithTag:position];
@@ -325,7 +343,7 @@ - (void)movingDidStopAtPoint:(CGPoint)point
[self updateIndexOfItem:m_movingItem toIndex:m_movingItem.tag - GMGV_POSITION_AND_TAG_OFFSET];
m_futurePosition = -1;
- [self.delegate draggableView:self didEndMovingView:m_movingItem];
+ [self.delegate GMGridView:self didEndMovingView:m_movingItem];
[UIView animateWithDuration:0.2 animations:^() {
m_movingItem.transform = CGAffineTransformIdentity;
@@ -347,13 +365,13 @@ - (void)reloadData
[m_orderedSubviews removeAllObjects];
- NSUInteger numberItems = [self.dataSource numberOfItemsInDraggableView:self];
- NSUInteger width = [self.dataSource widthForItemsInDraggableView:self];
- NSUInteger height = [self.dataSource heightForItemsInDraggableView:self];
+ NSUInteger numberItems = [self.dataSource numberOfItemsInGMGridView:self];
+ NSUInteger width = [self.dataSource widthForItemsInGMGridView:self];
+ NSUInteger height = [self.dataSource heightForItemsInGMGridView:self];
for (int i = 0; i < numberItems; i++)
{
- UIView *itemView = [self.dataSource draggableView:self viewForItemAtIndex:i];
+ UIView *itemView = [self.dataSource GMGridView:self viewForItemAtIndex:i];
itemView.frame = CGRectMake(0, 0, width, height);
itemView.tag = i + GMGV_POSITION_AND_TAG_OFFSET;
@@ -371,7 +389,7 @@ - (void)reloadObjectAtIndex:(NSInteger)index
UIView *currentView = [m_orderedSubviews objectAtIndex:index];
- UIView *view = [self.dataSource draggableView:self viewForItemAtIndex:index];
+ UIView *view = [self.dataSource GMGridView:self viewForItemAtIndex:index];
view.frame = currentView.frame;
view.tag = currentView.tag;
view.alpha = 0;
@@ -394,7 +412,7 @@ - (void)insertObjectAtIndex:(NSInteger)index
{
NSAssert((index >= 0 && index <= [m_orderedSubviews count]), @"Invalid index specified");
- UIView *view = [self.dataSource draggableView:self viewForItemAtIndex:index];
+ UIView *view = [self.dataSource GMGridView:self viewForItemAtIndex:index];
view.frame = CGRectMake(-20, -20, m_itemSize.width, m_itemSize.height);
view.tag = index + GMGV_POSITION_AND_TAG_OFFSET;
@@ -461,7 +479,7 @@ - (void)updateIndexOfItem:(UIView *)view toIndex:(NSInteger)index
if (index >= 0 && oldIndex != index && oldIndex < [m_orderedSubviews count])
{
[m_orderedSubviews moveObjectsAtIndexes:[NSIndexSet indexSetWithIndex:oldIndex] toIndex:index];
- [self.delegate draggableView:self itemAtIndex:oldIndex movedToIndex:index];
+ [self.delegate GMGridView:self itemAtIndex:oldIndex movedToIndex:index];
}
}
Oops, something went wrong.

0 comments on commit e1aeb58

Please sign in to comment.