Skip to content

Commit

Permalink
Merged PR 15362: [GraphNotificationsSample][iOS][UI change]Change to …
Browse files Browse the repository at this point in the history
…make dismiss work correctly

What's Changed:

1. Dismiss button now grays out and disables correctly once the Notification is dismissed.

2. The read button now grays out and dissabled correctly once the Notification is read.

3. The notification list now updates notification's in place instead of sending updated notifications (read, dismissed, etc) to the front of the listview.

4. Main menu improvements to center login and label button across all iOS devices. Now displays correctly.

5. Fixed login and logout scenarios for MSA. The new UI updates properly depending on the status of whether you're logged in or not.

----------------------

How verified:

1. Clicked dismiss and saw the notification update correctly in place.

2. Clicked read and saw the notification update correctly in place.

3. Ran the application on both iPhone and iPad to make sure it displayed correctly on both.

4. Logged in with MSA, observed UI update correctly. Logged out of MSA, observed UI update correctly. Logged back in and saw the UI update correctly.

Screenshots of UI running on iPad.

https://microsoft-my.sharepoint.com/:i:/p/adcrabtr/EV5rE1zE2lhDicbM56araegBx7H7TXKGQ1eM92oDFiZVPA?e=xmhDbS

https://microsoft-my.sharepoint.com/:i:/p/adcrabtr/EfklkqSwrzhCkjw1t2z_t5UB5-uB4WHwTIWR9ZRQBe71Xg?e=zRXzbE
  • Loading branch information
AdamCrabtreeMSFT committed May 23, 2019
1 parent 5760478 commit 107ea24
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="703-4V-yAM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="703-4V-yAM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -33,9 +33,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nW6-tV-2PU">
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nW6-tV-2PU">
<rect key="frame" x="64" y="263" width="236" height="48"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="Login with MSA">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -44,32 +43,39 @@
<action selector="loginMSA" destination="S4R-Ja-viH" eventType="touchUpInside" id="JLQ-Q2-VCr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz1-y2-7rY">
<rect key="frame" x="64" y="318" width="236" height="48"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="Login with AAD">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="loginAAD" destination="S4R-Ja-viH" eventType="touchUpInside" id="jIC-Q3-hja"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Graph Notifications Sample" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MiM-ed-uOi">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Graph Notifications Sample" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MiM-ed-uOi">
<rect key="frame" x="0.0" y="76" width="375" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Status" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ho4-ZN-PVf">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Status" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ho4-ZN-PVf">
<rect key="frame" x="16" y="438" width="343" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz1-y2-7rY">
<rect key="frame" x="64" y="319" width="236" height="48"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="Login with AAD">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="loginAAD" destination="S4R-Ja-viH" eventType="touchUpInside" id="jIC-Q3-hja"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="nW6-tV-2PU" firstAttribute="centerX" secondItem="K9I-jD-KjA" secondAttribute="centerX" id="8gA-iU-zlW"/>
<constraint firstItem="fz1-y2-7rY" firstAttribute="top" secondItem="nW6-tV-2PU" secondAttribute="bottom" constant="8" id="9oF-6X-ybB"/>
<constraint firstItem="nW6-tV-2PU" firstAttribute="top" secondItem="MiM-ed-uOi" secondAttribute="bottom" constant="166" id="Dhx-SE-Bav"/>
<constraint firstItem="nW6-tV-2PU" firstAttribute="centerY" secondItem="K9I-jD-KjA" secondAttribute="centerY" id="ECz-ip-gnS"/>
<constraint firstItem="fz1-y2-7rY" firstAttribute="centerX" secondItem="K9I-jD-KjA" secondAttribute="centerX" id="FHG-lw-Uc9"/>
<constraint firstItem="ho4-ZN-PVf" firstAttribute="centerX" secondItem="K9I-jD-KjA" secondAttribute="centerX" id="sXg-Ml-qeD"/>
<constraint firstItem="MiM-ed-uOi" firstAttribute="centerX" secondItem="K9I-jD-KjA" secondAttribute="centerX" id="wdg-HC-qDx"/>
<constraint firstItem="ho4-ZN-PVf" firstAttribute="top" secondItem="fz1-y2-7rY" secondAttribute="bottom" constant="71" id="wzK-oL-qer"/>
</constraints>
<viewLayoutGuide key="safeArea" id="K9I-jD-KjA"/>
</view>
<connections>
Expand Down Expand Up @@ -173,6 +179,11 @@
<state key="normal" title="Dismiss">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="tag">
<integer key="value" value="5"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" tag="6" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7jd-9p-7fJ">
<rect key="frame" x="216" y="78" width="99" height="30"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ - (void)viewDidLoad {

_platformManager = [ConnectedDevicesPlatformManager sharedInstance];

[self _setButtonTextForState:[self _getState]];
[self _setButtonTextAndVisibilityForState:[self _getState]];
}

- (IBAction)loginMSA {
Expand All @@ -32,15 +32,15 @@ - (IBAction)loginMSA {
// Perform MSA sign-in
[_platformManager signInMsaAsync].then(^{
[self _setStatusText:[NSString stringWithFormat:@"Currently signed in"]];
[self _setButtonTextForState:MSA];
[self _setButtonTextAndVisibilityForState:MSA];
}).catch(^(NSError* error){
NSLog(@"%@", error);
[self _setStatusText:[NSString stringWithFormat:@"MSA sign-in failed!"]];
});
} else {
[_platformManager signOutAsync:_platformManager.accounts[0]].then(^{
[self _setStatusText:[NSString stringWithFormat:@"Currently signed out"]];
[self _setButtonTextForState:SIGNED_OUT];
[self _setButtonTextAndVisibilityForState:SIGNED_OUT];
}).catch(^(NSError* error){
NSLog(@"%@", error);
[self _setStatusText:[NSString stringWithFormat:@"MSA sign-out failed!"]];
Expand All @@ -57,15 +57,15 @@ - (IBAction)loginAAD {
// Perform AAD sign-in
[_platformManager signInAadAsync].then(^{
[self _setStatusText:[NSString stringWithFormat:@"Currently signed in"]];
[self _setButtonTextForState:AAD];
[self _setButtonTextAndVisibilityForState:AAD];
}).catch(^(NSError* error){
NSLog(@"%@", error);
[self _setStatusText:[NSString stringWithFormat:@"AAD sign-in failed!"]];
});
} else {
[_platformManager signOutAsync:_platformManager.accounts[0]].then(^{
[self _setStatusText:[NSString stringWithFormat:@"Currently signed out"]];
[self _setButtonTextForState:SIGNED_OUT];
[self _setButtonTextAndVisibilityForState:SIGNED_OUT];
}).catch(^(NSError* error){
NSLog(@"%@", error);
[self _setStatusText:[NSString stringWithFormat:@"AAD sign-out failed!"]];
Expand Down Expand Up @@ -94,22 +94,26 @@ - (LoginState)_getState {
}
}

- (void)_setButtonTextForState:(LoginState)state {
- (void)_setButtonTextAndVisibilityForState:(LoginState)state {
dispatch_async(dispatch_get_main_queue(), ^{
switch (state) {
case SIGNED_OUT:
[self.aadButton setTitle:@"Login with AAD" forState:UIControlStateNormal];
[self.msaButton setTitle:@"Login with MSA" forState:UIControlStateNormal];
self.aadButton.hidden = FALSE;
self.msaButton.hidden = FALSE;
self.loginStatusLabel.text = @"Currently signed-out";
break;
case AAD:
[self.aadButton setTitle:@"Logout" forState:UIControlStateNormal];
[self.msaButton setTitle:@"" forState:UIControlStateNormal];
self.msaButton.hidden = TRUE;
self.loginStatusLabel.text = @"Currently signed-in with AAD";
break;
case MSA:
[self.aadButton setTitle:@"" forState:UIControlStateNormal];
[self.msaButton setTitle:@"Logout" forState:UIControlStateNormal];
self.aadButton.hidden = TRUE;
self.loginStatusLabel.text = @"Currently signed-in with MSA";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ - (void)_handleNotifications:(NSArray<MCDUserNotification*>*)notifications {

if (notification.status == MCDUserNotificationStatusActive) {
NSLog(@"Notification %@ is active", notification.notificationId);
[_notifications insertObject:notification atIndex:0];
if(index != NSNotFound) {
[_notifications insertObject:notification atIndex:index];
} else {
[_notifications insertObject:notification atIndex:0];
}

if ((notification.userActionState == MCDUserNotificationUserActionStateNoInteraction)
&& (notification.readState == MCDUserNotificationReadStateUnread)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ - (nonnull UITableViewCell*)tableView:(nonnull UITableView*)tableView cellForRow

UILabel* actionStateLabel = (UILabel*)[cell viewWithTag:3];
UIButton* dismissButton = (UIButton*)[cell viewWithTag:5];
[dismissButton setTag:indexPath.row];
[dismissButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[dismissButton setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];
if (notification.userActionState == MCDUserNotificationUserActionStateNoInteraction) {
[actionStateLabel setText:@"No Interaction"];
dismissButton.enabled = YES;
Expand All @@ -76,7 +77,8 @@ - (nonnull UITableViewCell*)tableView:(nonnull UITableView*)tableView cellForRow
}

UIButton* readButton = (UIButton*)[cell viewWithTag:4];
[readButton setTag:indexPath.row];
[readButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[readButton setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];
if (notification.readState == MCDUserNotificationReadStateUnread) {
[idLabel setTextColor:[UIColor greenColor]];
readButton.enabled = YES;
Expand All @@ -87,19 +89,23 @@ - (nonnull UITableViewCell*)tableView:(nonnull UITableView*)tableView cellForRow
}

UIButton* deleteButton = (UIButton*)[cell viewWithTag:6];
[deleteButton setTag:indexPath.row];
[deleteButton setTag:indexPath.row];
[deleteButton addTarget:self action:@selector(handleDelete:) forControlEvents:UIControlEventTouchUpInside];

return cell;
}

- (IBAction)handleRead:(UIButton*)button {
MCDUserNotification* selected = _notificationsManager.notifications[button.tag];
CGPoint touchPoint = [button convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *clickedButtonIndexPath = [self.tableView indexPathForRowAtPoint:touchPoint];
MCDUserNotification* selected = _notificationsManager.notifications[clickedButtonIndexPath.row];
[_notificationsManager markRead:selected];
}

- (IBAction)handleDismiss:(UIButton*)button {
MCDUserNotification* selected = _notificationsManager.notifications[button.tag];
CGPoint touchPoint = [button convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *clickedButtonIndexPath = [self.tableView indexPathForRowAtPoint:touchPoint];
MCDUserNotification* selected = _notificationsManager.notifications[clickedButtonIndexPath.row];
[_notificationsManager dismissNotification:selected];
}

Expand Down
Loading

0 comments on commit 107ea24

Please sign in to comment.