Skip to content

Commit

Permalink
Fix some bugs and update AppIcon...
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyyoung committed Sep 28, 2016
1 parent 7eeead3 commit 8195c9a
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 562 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/256x256-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/32x32-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/512x512-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AppleReserver/Assets.xcassets/AppIcon.appiconset/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "adsf.png",
"filename" : "1024x1024.png",
"scale" : "2x"
}
],
Expand Down
Binary file not shown.
524 changes: 0 additions & 524 deletions AppleReserver/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Binary file added AppleReserver/Icon.icns
Binary file not shown.
8 changes: 5 additions & 3 deletions AppleReserver/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>zh_CN</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand All @@ -28,5 +28,7 @@
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>
</dict>
</plist>
78 changes: 44 additions & 34 deletions AppleReserver/Module/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@

@interface HomeViewController () <NSTableViewDataSource, NSTableViewDelegate>

// TableViews
@property (weak) IBOutlet NSTableView *storeTableView;
@property (weak) IBOutlet NSTableView *availabilityTableView;
// Buttons
@property (weak) IBOutlet NSButton *onlyAvailabilityButton;
@property (weak) IBOutlet NSButton *notificationButton;
@property (weak) IBOutlet NSPopUpButton *timerIntervalButton;
@property (weak) IBOutlet NSButton *fireButton;

// Properties
@property (nonatomic, copy) NSArray<Store *> *storeArray;
@property (nonatomic, copy) NSDictionary *deviceDictionary;
@property (nonatomic, copy) NSDictionary *availabilityDictionary;
@property (nonatomic, strong) NSMutableArray *selectedModelArray;

@property (nonatomic, strong) Store *selectedStore;
@property (nonatomic, strong) NSTimer *pollingTimer;

Expand All @@ -32,39 +37,7 @@ @implementation HomeViewController

- (void)viewDidLoad {
[super viewDidLoad];
[self reloadStore];
}

- (void)reloadStore {
__weak typeof(self) weakSelf = self;
[self.selectedModelArray removeAllObjects];
[StoreRequest requestSuccess:^(NSArray<Store *> *storeArray) {
weakSelf.storeArray = storeArray;
[weakSelf.storeTableView reloadData];
} failure:nil];
}

- (void)reloadAvailability {
__weak typeof(self) weakSelf = self;
[AvailabilityRequest requestWithType:self.onlyAvailabilityButton.state
storeNumber:self.selectedStore.storeNumber
success:^(NSDictionary *availabilityDictionary) {
weakSelf.availabilityDictionary = availabilityDictionary;
[weakSelf.availabilityTableView reloadData];
[weakSelf checkAndMakeNotification];
} failure:nil];
}

- (void)checkAndMakeNotification {
for (NSString *model in self.selectedModelArray) {
if ([self.availabilityDictionary[model] isEqualToString:@"ALL"]) {
Device *device = [Device deviceDictionary][model];
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.informativeText = [NSString stringWithFormat:@"%@ 有货了!!!", device.productDescription];
notification.soundName = NSUserNotificationDefaultSoundName;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
}
[self loadStoreAndDevice];
}

#pragma mark - TableView DataSource
Expand All @@ -84,7 +57,7 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
return self.storeArray[row].storeName;
} else if (tableView == self.availabilityTableView) {
NSString *model = self.availabilityDictionary.allKeys[row];
Device *device = [Device deviceDictionary][model];
Device *device = self.deviceDictionary[model];
if ([tableColumn.identifier isEqualToString:@"Monitoring"]) {
return @([self.selectedModelArray containsObject:model]);
} else if ([tableColumn.identifier isEqualToString:@"Model"]) {
Expand All @@ -108,10 +81,47 @@ - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol
[object boolValue]?[self.selectedModelArray addObject:model]:[self.selectedModelArray removeObject:model];
}

#pragma mark - Reload method

- (void)loadStoreAndDevice {
self.deviceDictionary = [Device deviceDictionary];
__weak typeof(self) weakSelf = self;
[StoreRequest requestSuccess:^(NSArray<Store *> *storeArray) {
weakSelf.storeArray = storeArray;
[weakSelf.storeTableView reloadData];
} failure:nil];
}

- (void)reloadAvailability {
__weak typeof(self) weakSelf = self;
[AvailabilityRequest requestWithType:self.onlyAvailabilityButton.state
storeNumber:self.selectedStore.storeNumber
success:^(NSDictionary *availabilityDictionary) {
weakSelf.availabilityDictionary = availabilityDictionary;
[weakSelf.availabilityTableView reloadData];
if (weakSelf.notificationButton.state) {
[weakSelf checkAndMakeNotification];
}
} failure:nil];
}

- (void)checkAndMakeNotification {
for (NSString *model in self.selectedModelArray) {
if ([self.availabilityDictionary[model] isEqualToString:@"ALL"]) {
Device *device = self.deviceDictionary[model];
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.informativeText = [NSString stringWithFormat:@"%@ 有货了!!!", device.productDescription];
notification.soundName = NSUserNotificationDefaultSoundName;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
}
}

#pragma mark - Event Response

- (IBAction)storeTableViewAction:(NSTableView *)sender {
self.selectedStore = self.storeArray[sender.selectedRow];
[self.selectedModelArray removeAllObjects];
[self reloadAvailability];
}

Expand Down

0 comments on commit 8195c9a

Please sign in to comment.