Skip to content

Commit

Permalink
站点跳转到路线
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnWong committed Jan 18, 2015
1 parent b5287bf commit bd34710
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
29 changes: 25 additions & 4 deletions BusRider/Controller/JWBusLineViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "JWFormatter.h"
#import "JWNavigationCenterView.h"
#import "AHKActionSheet.h"
#import "JWStopTableViewController.h"

#define kJWButtonHeight 50
#define kJWButtonBaseTag 2000
Expand All @@ -43,6 +44,10 @@ @interface JWBusLineViewController() <JWNavigationCenterDelegate>

@property (nonatomic, strong) JWNavigationCenterView *navigationCenterView;
@property (nonatomic, strong) JWLineRequest *lineRequest;
/**
* Pass to JWBusLineViewController
*/
@property (nonatomic, strong) JWSearchStopItem *selectedStopItem;

@end

Expand All @@ -52,6 +57,7 @@ @implementation JWBusLineViewController
- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.contentView.layer.cornerRadius = 4;
self.contentView.layer.borderWidth = kOnePixel;
self.contentView.layer.borderColor = HEXCOLOR(0xD7D8D9).CGColor ;
Expand All @@ -61,7 +67,6 @@ - (void)viewDidLoad {
JWStopItem *stopItem = [[JWStopItem alloc] initWithStopId:collectItem.stopId stopName:collectItem.stopName];
self.selectedStopId = stopItem.stopId;
}
// [self setNavigationItemCenter:nil];
self.navigationItem.titleView = self.navigationCenterView;

/**
Expand Down Expand Up @@ -89,6 +94,13 @@ - (void)viewWillDisappear:(BOOL)animated {
[self.navigationController cancelSGProgress];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:JWSeguePushStop]) {
JWStopTableViewController *stopViewController = segue.destinationViewController;
stopViewController.stopItem = self.selectedStopItem;
}
}

- (void)updateViews {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:[JWUserDefaultsUtil collectItemForLineId:self.lineId] ? @"JWIconCollectOn" : @"JWIconCollectOff"] style:UIBarButtonItemStylePlain target:self action:@selector(collect:)];

Expand Down Expand Up @@ -129,7 +141,9 @@ - (void)updateViews {
if (scrollTo < - self.scrollView.contentInset.top) {
scrollTo = - self.scrollView.contentInset.top;
}
self.scrollView.contentOffset = CGPointMake(0, scrollTo);
[UIView animateWithDuration:0.25 + 0.002 * scrollTo animations:^{
self.scrollView.contentOffset = CGPointMake(0, scrollTo);
}];
}

[self.contentView addSubview:stopButton];
Expand Down Expand Up @@ -269,12 +283,19 @@ - (void)setOn:(BOOL)isOn {
if (isOn) {
AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithTitle:@"选择站点"];
actionSheet.cancelButtonTitle = @"取消";
__weak typeof(self) weakSelf = self;
actionSheet.cancelHandler = ^(AHKActionSheet *actionSheet) {
[self.navigationCenterView setOn:NO];
[weakSelf.navigationCenterView setOn:NO];
};
for (JWStopItem *stopItem in self.busLineItem.stopItems) {
__weak typeof(self) weakSelf = self;
[actionSheet addButtonWithTitle:stopItem.stopName image:[UIImage imageNamed:@"JWIconBusThin"] type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *actionSheet) {
NSLog(@"%@", stopItem.stopName);
[weakSelf.navigationCenterView setOn:NO];
JWSearchStopItem *searchStopItem = [[JWSearchStopItem alloc] init];
searchStopItem.stopId = stopItem.stopId;
searchStopItem.stopName = stopItem.stopName;
weakSelf.selectedStopItem = searchStopItem;
[weakSelf performSegueWithIdentifier:JWSeguePushStop sender:weakSelf];
}];
}
[actionSheet show];
Expand Down
2 changes: 2 additions & 0 deletions BusRider/Item/SearchList/JWSearchStopItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
*/
@property (nonatomic, strong) NSString *stopName;

- (instancetype)initWithStopId:(NSString *)stopId stopName:(NSString *)stopName;

@end
8 changes: 8 additions & 0 deletions BusRider/Item/SearchList/JWSearchStopItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

@implementation JWSearchStopItem

- (instancetype)initWithStopId:(NSString *)stopId stopName:(NSString *)stopName {
if (self = [super init]) {
self.stopId = stopId;
self.stopName = stopName;
}
return self;
}

- (void)setFromDictionary:(NSDictionary *)dict {
self.stopId = dict[@"stopId"];
self.stopName = dict[@"stopName"];
Expand Down
1 change: 1 addition & 0 deletions BusRider/JWBusRider-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
#define JWSeguePushLineWithId @"JWSeguePushLineWithId"
#define JWSeguePushStopList @"JWSeguePushStopList"
#define JWSeguePushLineWithIdStop @"JWSeguePushLineWithIdStop"
#define JWSeguePushStop @"JWSeguePushStop"

#endif
Binary file modified BusRider/Resource/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions BusRider/Supporting Files/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,12 @@
<outlet property="todayButton" destination="eyO-Ni-QJW" id="kll-uM-5dR"/>
<outlet property="unitLabel" destination="GYn-wc-OIZ" id="zpq-GX-sxQ"/>
<outlet property="updateLabel" destination="ble-G6-1bG" id="qHM-5i-FNW"/>
<segue destination="wuS-za-bCw" kind="push" identifier="JWSeguePushStop" id="BPd-eC-Cbi"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FiO-zI-V4K" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="409" y="717"/>
<point key="canvasLocation" x="433" y="614"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="67g-oX-tOw">
Expand Down Expand Up @@ -402,7 +403,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ig9-5u-5MC" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-41" y="1034"/>
<point key="canvasLocation" x="-2" y="1331"/>
</scene>
</scenes>
<resources>
Expand All @@ -419,6 +420,7 @@
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
<segue reference="jwN-Vj-vCx"/>
<segue reference="BPd-eC-Cbi"/>
<segue reference="bKI-le-Ue2"/>
</inferredMetricsTieBreakers>
</document>

0 comments on commit bd34710

Please sign in to comment.