Added screens in sample app for notification
Summary:
Added a basic communication flows and a button to trigger notification
{F142016937}
Reviewed By: jknoxville
Differential Revision: D10492428
fbshipit-source-id: b65fc46b3be695852f9197771a253d9e8596f328
This commit is contained in:
committed by
Facebook Github Bot
parent
74c1a24b86
commit
12d2af38f7
@@ -8,7 +8,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <FlipperKit/FlipperPlugin.h>
|
||||
|
||||
@protocol FlipperKitExampleCommunicationResponderDelegate
|
||||
- (void)messageReceived:(NSString *)msg;
|
||||
@end
|
||||
|
||||
@interface FlipperKitExamplePlugin : NSObject<FlipperPlugin>
|
||||
@property (weak, nonatomic) id<FlipperKitExampleCommunicationResponderDelegate> delegate;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (void)sendMessage:(NSString *)msg;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#import <FlipperKit/FlipperResponder.h>
|
||||
|
||||
@interface FlipperKitExamplePlugin()
|
||||
@property (strong, nonatomic) NSMutableArray<NSString *> *messagesToDisplay;
|
||||
@property (strong, nonatomic) id<FlipperConnection> connection;
|
||||
@property (nonatomic) NSInteger triggerCount;
|
||||
|
||||
@@ -23,7 +22,6 @@
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_messagesToDisplay = @[].mutableCopy;
|
||||
_triggerCount = 0;
|
||||
}
|
||||
return self;
|
||||
@@ -44,7 +42,8 @@
|
||||
__weak FlipperKitExamplePlugin *weakSelf = self;
|
||||
self.connection = connection;
|
||||
[connection receive:@"displayMessage" withBlock:^(NSDictionary *params, id<FlipperResponder> responder) {
|
||||
[weakSelf.messagesToDisplay addObject:params[@"message"]];
|
||||
[weakSelf.delegate messageReceived:params[@"message"]];
|
||||
[responder success:@{@"greeting": @"Hello"}];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
13
iOS/Sample/CommunicationDemoViewController.h
Normal file
13
iOS/Sample/CommunicationDemoViewController.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CommunicationDemoViewController : UIViewController<UITableViewDataSource>
|
||||
|
||||
@end
|
||||
57
iOS/Sample/CommunicationDemoViewController.mm
Normal file
57
iOS/Sample/CommunicationDemoViewController.mm
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "CommunicationDemoViewController.h"
|
||||
#import <FlipperKitExamplePlugin/FlipperKitExamplePlugin.h>
|
||||
|
||||
@interface CommunicationDemoViewController()<FlipperKitExampleCommunicationResponderDelegate>
|
||||
@property (strong, nonatomic) NSMutableArray<NSString *> *messagesToDisplay;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *messageTextField;
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
@end
|
||||
|
||||
@implementation CommunicationDemoViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[FlipperKitExamplePlugin sharedInstance].delegate = self;
|
||||
}
|
||||
|
||||
- (IBAction)tappedTriggerNotification:(UIButton *)sender {
|
||||
[[FlipperKitExamplePlugin sharedInstance] triggerNotification];
|
||||
}
|
||||
|
||||
- (IBAction)tappedSendMessage:(UIButton *)sender {
|
||||
if (self.messageTextField.text.length > 0) {
|
||||
[[FlipperKitExamplePlugin sharedInstance] sendMessage:self.messageTextField.text];
|
||||
}
|
||||
}
|
||||
|
||||
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reusableCell"];
|
||||
cell.textLabel.text = self.messagesToDisplay[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.messagesToDisplay.count;
|
||||
}
|
||||
|
||||
- (void)messageReceived:(NSString *)msg {
|
||||
if (msg) {
|
||||
if (!self.messagesToDisplay) {
|
||||
self.messagesToDisplay = @[].mutableCopy;
|
||||
}
|
||||
[self.messagesToDisplay addObject:msg];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,138 @@
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Communication Demo View Controller-->
|
||||
<scene sceneID="fXi-jn-kzD">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="CommunicationDemoViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="z1Y-Sv-TMg" customClass="CommunicationDemoViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="tgr-jj-LKH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="sonarpattern" translatesAutoresizingMaskIntoConstraints="NO" id="nZu-Qc-d1K" customClass="sonarpattern">
|
||||
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
|
||||
</imageView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="x1C-Dt-Pk4">
|
||||
<rect key="frame" x="40" y="181" width="295" height="40"/>
|
||||
<color key="backgroundColor" red="0.89411764709999997" green="0.87450980389999999" blue="0.92941176469999998" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="40" id="Ts5-QY-Mre"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Send">
|
||||
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="tappedSendMessage:" destination="z1Y-Sv-TMg" eventType="touchUpInside" id="drc-2v-vx1"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Communication Demo" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JzA-PP-47Y">
|
||||
<rect key="frame" x="97.5" y="100" width="180" height="22"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zbr-hb-hlZ">
|
||||
<rect key="frame" x="40" y="40" width="295" height="40"/>
|
||||
<color key="backgroundColor" red="0.89411764709999997" green="0.87450980389999999" blue="0.92941176469999998" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="40" id="QxC-p0-gu5"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Trigger Notification">
|
||||
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="tappedTriggerNotification:" destination="z1Y-Sv-TMg" eventType="touchUpInside" id="FZD-pH-JiG"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ojx-lF-zQN">
|
||||
<rect key="frame" x="8" y="124" width="359" height="1"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="4oa-d3-ItX"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Send Message:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gJH-15-Ym5">
|
||||
<rect key="frame" x="8" y="142.5" width="117.5" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="S4S-a2-TjK">
|
||||
<rect key="frame" x="129.5" y="133" width="237.5" height="40"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="40" id="Fpa-hO-z4D"/>
|
||||
</constraints>
|
||||
<nil key="textColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Received Messages:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B2D-2U-1CG">
|
||||
<rect key="frame" x="8" y="237" width="157" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="EKF-y4-p6W">
|
||||
<rect key="frame" x="0.0" y="266" width="375" height="401"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="reusableCell" id="2nT-iG-vaG">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="2nT-iG-vaG" id="Ty1-Kg-SOf">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="z1Y-Sv-TMg" id="bur-8E-dwV"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstItem="JzA-PP-47Y" firstAttribute="top" secondItem="zbr-hb-hlZ" secondAttribute="bottom" constant="20" id="33e-Vu-y82"/>
|
||||
<constraint firstItem="JzA-PP-47Y" firstAttribute="centerX" secondItem="tgr-jj-LKH" secondAttribute="centerX" id="BWC-vN-tvY"/>
|
||||
<constraint firstItem="x1C-Dt-Pk4" firstAttribute="centerX" secondItem="tgr-jj-LKH" secondAttribute="centerX" id="CMH-Iy-SwE"/>
|
||||
<constraint firstItem="zbr-hb-hlZ" firstAttribute="top" secondItem="kIf-XC-I2s" secondAttribute="top" constant="20" id="Ef8-vF-zig"/>
|
||||
<constraint firstItem="Ojx-lF-zQN" firstAttribute="top" secondItem="JzA-PP-47Y" secondAttribute="bottom" constant="2" id="F7z-lu-UnO"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="zbr-hb-hlZ" secondAttribute="trailing" constant="40" id="Lgc-if-Nzz"/>
|
||||
<constraint firstItem="gJH-15-Ym5" firstAttribute="leading" secondItem="Ojx-lF-zQN" secondAttribute="leading" id="Mc2-SM-XHQ"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="Ojx-lF-zQN" secondAttribute="trailing" constant="8" id="NOW-P7-QNE"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="nZu-Qc-d1K" secondAttribute="trailing" id="PEn-u2-Iv8"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="bottom" secondItem="EKF-y4-p6W" secondAttribute="bottom" id="POW-ds-DJf"/>
|
||||
<constraint firstItem="Ojx-lF-zQN" firstAttribute="leading" secondItem="kIf-XC-I2s" secondAttribute="leading" constant="8" id="ZCN-L2-hVk"/>
|
||||
<constraint firstItem="B2D-2U-1CG" firstAttribute="top" secondItem="x1C-Dt-Pk4" secondAttribute="bottom" constant="16" id="aDW-e6-ItF"/>
|
||||
<constraint firstItem="S4S-a2-TjK" firstAttribute="top" secondItem="Ojx-lF-zQN" secondAttribute="bottom" constant="8" id="al8-qr-il0"/>
|
||||
<constraint firstItem="S4S-a2-TjK" firstAttribute="leading" secondItem="gJH-15-Ym5" secondAttribute="trailing" constant="4" id="bKW-VJ-IDY"/>
|
||||
<constraint firstItem="EKF-y4-p6W" firstAttribute="leading" secondItem="kIf-XC-I2s" secondAttribute="leading" id="cB9-2A-U0u"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="EKF-y4-p6W" secondAttribute="trailing" id="e3e-lT-N9x"/>
|
||||
<constraint firstItem="nZu-Qc-d1K" firstAttribute="leading" secondItem="kIf-XC-I2s" secondAttribute="leading" id="eHf-BE-vRY"/>
|
||||
<constraint firstItem="zbr-hb-hlZ" firstAttribute="centerX" secondItem="tgr-jj-LKH" secondAttribute="centerX" id="eLg-8D-IK1"/>
|
||||
<constraint firstItem="nZu-Qc-d1K" firstAttribute="top" secondItem="kIf-XC-I2s" secondAttribute="top" id="gig-Cm-6xQ"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="x1C-Dt-Pk4" secondAttribute="trailing" constant="40" id="go8-Kk-H6M"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="trailing" secondItem="S4S-a2-TjK" secondAttribute="trailing" constant="8" id="hAc-1Y-rTn"/>
|
||||
<constraint firstItem="gJH-15-Ym5" firstAttribute="centerY" secondItem="S4S-a2-TjK" secondAttribute="centerY" id="jbP-2k-fQa"/>
|
||||
<constraint firstItem="x1C-Dt-Pk4" firstAttribute="leading" secondItem="kIf-XC-I2s" secondAttribute="leading" constant="40" id="po2-e8-InK"/>
|
||||
<constraint firstItem="B2D-2U-1CG" firstAttribute="leading" secondItem="gJH-15-Ym5" secondAttribute="leading" id="qBx-0b-ukt"/>
|
||||
<constraint firstItem="x1C-Dt-Pk4" firstAttribute="top" secondItem="S4S-a2-TjK" secondAttribute="bottom" constant="8" id="rGT-jp-6RS"/>
|
||||
<constraint firstItem="EKF-y4-p6W" firstAttribute="top" secondItem="B2D-2U-1CG" secondAttribute="bottom" constant="8" id="uTx-wJ-9GT"/>
|
||||
<constraint firstItem="kIf-XC-I2s" firstAttribute="bottom" secondItem="nZu-Qc-d1K" secondAttribute="bottom" id="vhV-uW-dAx"/>
|
||||
<constraint firstItem="zbr-hb-hlZ" firstAttribute="leading" secondItem="kIf-XC-I2s" secondAttribute="leading" constant="40" id="z8Q-6c-Vmv"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="kIf-XC-I2s"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="messageTextField" destination="S4S-a2-TjK" id="m0e-QS-xhy"/>
|
||||
<outlet property="tableView" destination="EKF-y4-p6W" id="G1h-jY-cjY"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="wah-4c-bmr" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="653.60000000000002" y="-143.47826086956522"/>
|
||||
</scene>
|
||||
<!--Main View Controller-->
|
||||
<scene sceneID="bsE-tG-aac">
|
||||
<objects>
|
||||
@@ -62,6 +194,20 @@
|
||||
<action selector="tappedComponentKitLayout:" destination="2r2-64-LPh" eventType="touchUpInside" id="amo-e0-rJv"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="U2A-FV-duk">
|
||||
<rect key="frame" x="0.0" y="224" width="375" height="60"/>
|
||||
<color key="backgroundColor" red="0.89411764709999997" green="0.87450980389999999" blue="0.92941176469999998" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="60" id="Wk9-HK-qWQ"/>
|
||||
<constraint firstAttribute="height" constant="60" id="XIJ-cn-JAg"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Notifications/Communication Demo">
|
||||
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="tappedCommunicationDemo:" destination="2r2-64-LPh" eventType="touchUpInside" id="G2f-J0-1dg"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
@@ -72,19 +218,22 @@
|
||||
<constraint firstItem="R0E-21-TJB" firstAttribute="leading" secondItem="fhd-5r-dZW" secondAttribute="leading" id="7mG-cL-FY7"/>
|
||||
<constraint firstItem="xh0-Q4-60g" firstAttribute="leading" secondItem="fhd-5r-dZW" secondAttribute="leading" id="DPX-l5-Rca"/>
|
||||
<constraint firstItem="B57-dd-H6T" firstAttribute="leading" secondItem="fhd-5r-dZW" secondAttribute="leading" id="Hhd-in-vfk"/>
|
||||
<constraint firstItem="U2A-FV-duk" firstAttribute="top" secondItem="wdV-rw-8hy" secondAttribute="bottom" constant="8" id="N7B-ib-na4"/>
|
||||
<constraint firstItem="fhd-5r-dZW" firstAttribute="trailing" secondItem="B57-dd-H6T" secondAttribute="trailing" id="ODW-CJ-ean"/>
|
||||
<constraint firstItem="fhd-5r-dZW" firstAttribute="trailing" secondItem="R0E-21-TJB" secondAttribute="trailing" id="QyG-ez-XwS"/>
|
||||
<constraint firstItem="wdV-rw-8hy" firstAttribute="leading" secondItem="xh0-Q4-60g" secondAttribute="leading" id="ebs-Zh-KRL"/>
|
||||
<constraint firstItem="wdV-rw-8hy" firstAttribute="top" secondItem="xh0-Q4-60g" secondAttribute="bottom" constant="8" id="g0a-Kf-scc"/>
|
||||
<constraint firstItem="U2A-FV-duk" firstAttribute="trailing" secondItem="fhd-5r-dZW" secondAttribute="trailing" id="kCq-Gy-Opv"/>
|
||||
<constraint firstItem="fhd-5r-dZW" firstAttribute="bottom" secondItem="B57-dd-H6T" secondAttribute="bottom" id="kh1-ra-tzR"/>
|
||||
<constraint firstItem="B57-dd-H6T" firstAttribute="top" secondItem="fhd-5r-dZW" secondAttribute="top" id="vGA-oo-EGc"/>
|
||||
<constraint firstItem="U2A-FV-duk" firstAttribute="leading" secondItem="fhd-5r-dZW" secondAttribute="leading" id="zaZ-Bn-fhD"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="fhd-5r-dZW"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="d8y-kY-iPg" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="222" y="286"/>
|
||||
<point key="canvasLocation" x="-7" y="-143"/>
|
||||
</scene>
|
||||
<!--Network View Controller-->
|
||||
<scene sceneID="Zgm-Mh-TPB">
|
||||
@@ -173,7 +322,7 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="jLg-IP-htV" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="958" y="280"/>
|
||||
<point key="canvasLocation" x="1334" y="-143"/>
|
||||
</scene>
|
||||
<!--User Defaults View Controller-->
|
||||
<scene sceneID="WTQ-n4-t3v">
|
||||
@@ -244,10 +393,10 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="snT-Mu-i3U" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1613.5999999999999" y="278.41079460269867"/>
|
||||
<point key="canvasLocation" x="1985" y="-143"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="sonarpattern" width="843" height="1317"/>
|
||||
<image name="sonarpattern" width="421" height="658"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "NetworkViewController.h"
|
||||
#import "RootViewController.h"
|
||||
#import "UserDefaultsViewController.h"
|
||||
#import "CommunicationDemoViewController.h"
|
||||
|
||||
@interface MainViewController ()
|
||||
|
||||
@@ -43,4 +44,10 @@
|
||||
[self.navigationController pushViewController:userDefaultsViewController animated:true];
|
||||
}
|
||||
|
||||
- (IBAction)tappedCommunicationDemo:(UIButton *)sender {
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryBoard" bundle:nil];
|
||||
CommunicationDemoViewController *communicationDemoViewController = [storyboard instantiateViewControllerWithIdentifier:@"CommunicationDemoViewController"];
|
||||
[self.navigationController pushViewController:communicationDemoViewController animated:true];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
0D0B1CF0E859D91C55CC453B /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F97F4E8C3E28D8BFAAEE60F4 /* libPods-Sample.a */; };
|
||||
4E102341216AD7B400160734 /* UserDefaultsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E102340216AD7B400160734 /* UserDefaultsViewController.m */; };
|
||||
53B4A36B217E2B6200B36A53 /* CommunicationDemoViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53B4A36A217E2B6200B36A53 /* CommunicationDemoViewController.mm */; };
|
||||
53D59DB320ABA18400207065 /* NetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D59DAA20ABA18300207065 /* NetworkViewController.m */; };
|
||||
53D59DB420ABA18400207065 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53D59DAB20ABA18300207065 /* AppDelegate.mm */; };
|
||||
53D59DB520ABA18400207065 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D59DAD20ABA18300207065 /* MainViewController.m */; };
|
||||
@@ -22,6 +23,8 @@
|
||||
081A9FC23643CD21C7D61AA1 /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
||||
4E10233F216AD7B400160734 /* UserDefaultsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserDefaultsViewController.h; sourceTree = "<group>"; };
|
||||
4E102340216AD7B400160734 /* UserDefaultsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UserDefaultsViewController.m; sourceTree = "<group>"; };
|
||||
534252A9217DECCD0092D02B /* CommunicationDemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommunicationDemoViewController.h; sourceTree = "<group>"; };
|
||||
53B4A36A217E2B6200B36A53 /* CommunicationDemoViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommunicationDemoViewController.mm; sourceTree = "<group>"; };
|
||||
53D59DAA20ABA18300207065 /* NetworkViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkViewController.m; sourceTree = SOURCE_ROOT; };
|
||||
53D59DAB20ABA18300207065 /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = SOURCE_ROOT; };
|
||||
53D59DAC20ABA18300207065 /* NetworkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkViewController.h; sourceTree = SOURCE_ROOT; };
|
||||
@@ -54,6 +57,7 @@
|
||||
53D59DB920ABA19900207065 /* Sample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
53B4A36A217E2B6200B36A53 /* CommunicationDemoViewController.mm */,
|
||||
53D59DBA20ABA20300207065 /* AppDelegate.h */,
|
||||
53D59DAB20ABA18300207065 /* AppDelegate.mm */,
|
||||
53D59DB120ABA18400207065 /* Icons.xcassets */,
|
||||
@@ -68,6 +72,7 @@
|
||||
53D59DAF20ABA18300207065 /* RootViewController.mm */,
|
||||
53E0DE5220ABA0E4005682E1 /* Info.plist */,
|
||||
53E0DE5320ABA0E4005682E1 /* main.m */,
|
||||
534252A9217DECCD0092D02B /* CommunicationDemoViewController.h */,
|
||||
);
|
||||
name = Sample;
|
||||
sourceTree = "<group>";
|
||||
@@ -202,6 +207,7 @@
|
||||
4E102341216AD7B400160734 /* UserDefaultsViewController.m in Sources */,
|
||||
53D59DB320ABA18400207065 /* NetworkViewController.m in Sources */,
|
||||
53D59DB420ABA18400207065 /* AppDelegate.mm in Sources */,
|
||||
53B4A36B217E2B6200B36A53 /* CommunicationDemoViewController.mm in Sources */,
|
||||
53D59DB520ABA18400207065 /* MainViewController.m in Sources */,
|
||||
53D59DB620ABA18400207065 /* RootViewController.mm in Sources */,
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Button, Input, FlipperPlugin, FlexColumn, styled, Text} from 'flipper';
|
||||
|
||||
import type {Notification} from '../../plugin';
|
||||
type DisplayMessageResponse = {
|
||||
greeting: string,
|
||||
};
|
||||
@@ -18,7 +18,8 @@ type State = {
|
||||
};
|
||||
|
||||
type PersistedState = {
|
||||
currentNotificationId: number,
|
||||
currentNotificationIds: Array<number>,
|
||||
receivedMessage: ?string,
|
||||
};
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
@@ -32,6 +33,11 @@ export default class extends FlipperPlugin<*, State, PersistedState> {
|
||||
static id = 'Example';
|
||||
static icon = 'apps';
|
||||
|
||||
static defaultPersistedState = {
|
||||
currentNotificationIds: [],
|
||||
receivedMessage: null,
|
||||
};
|
||||
|
||||
state = {
|
||||
prompt: 'Type a message below to see it displayed on the mobile app',
|
||||
message: '',
|
||||
@@ -47,7 +53,16 @@ export default class extends FlipperPlugin<*, State, PersistedState> {
|
||||
): PersistedState => {
|
||||
if (method === 'triggerNotification') {
|
||||
return {
|
||||
currentNotificationId: payload.id,
|
||||
...persistedState,
|
||||
currentNotificationIds: persistedState.currentNotificationIds.concat([
|
||||
payload.id,
|
||||
]),
|
||||
};
|
||||
}
|
||||
if (method === 'displayMessage') {
|
||||
return {
|
||||
...persistedState,
|
||||
receivedMessage: payload.msg,
|
||||
};
|
||||
}
|
||||
return persistedState || {};
|
||||
@@ -56,15 +71,17 @@ export default class extends FlipperPlugin<*, State, PersistedState> {
|
||||
/*
|
||||
* Callback to provide the currently active notifications.
|
||||
*/
|
||||
static getActiveNotifications = (persistedState: PersistedState) => {
|
||||
return [
|
||||
{
|
||||
id: 'test-notification:' + persistedState.currentNotificationId,
|
||||
static getActiveNotifications = (
|
||||
persistedState: PersistedState,
|
||||
): Array<Notification> => {
|
||||
return persistedState.currentNotificationIds.map((x: number) => {
|
||||
return {
|
||||
id: 'test-notification:' + x,
|
||||
message: 'Example Notification',
|
||||
severity: 'warning',
|
||||
title: 'Notification: ' + persistedState.currentNotificationId,
|
||||
},
|
||||
];
|
||||
title: 'Notification: ' + x,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -83,14 +100,17 @@ export default class extends FlipperPlugin<*, State, PersistedState> {
|
||||
render() {
|
||||
return (
|
||||
<Container>
|
||||
<Text>{this.state.prompt}</Text>,
|
||||
<Text>{this.state.prompt}</Text>
|
||||
<Input
|
||||
placeholder="Message"
|
||||
onChange={event => {
|
||||
this.setState({message: event.target.value});
|
||||
}}
|
||||
/>,
|
||||
<Button onClick={this.sendMessage.bind(this)}>Send</Button>,
|
||||
/>
|
||||
<Button onClick={this.sendMessage.bind(this)}>Send</Button>
|
||||
{this.props.persistedState.receivedMessage && (
|
||||
<Text> {this.props.persistedState.receivedMessage} </Text>
|
||||
)}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user