Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTA demo app #711

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Apps/MTA/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AppDelegate.h
// OBANetworking
//
// Copyright © Open Transit Software Foundation
// This source code is licensed under the Apache 2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

134 changes: 134 additions & 0 deletions Apps/MTA/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//
// AppDelegate.m
// OBANetworking
//
// Copyright © Open Transit Software Foundation
// This source code is licensed under the Apache 2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

#import "AppDelegate.h"
@import OBAKitCore;
@import OBAKit;
#import "App-Swift.h"

@interface AppDelegate ()<OBAApplicationDelegate>
@property(nonatomic,strong) OBAApplication *app;
@property(nonatomic,strong) NSUserDefaults *userDefaults;
@property(nonatomic,strong) OBAClassicApplicationRootController *rootController;
@end

@implementation AppDelegate

- (instancetype)init {
self = [super init];

if (self) {
NSURLCache *urlCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
[NSURLCache setSharedURLCache:urlCache];

NSString *appGroup = NSBundle.mainBundle.appGroup;
assert(appGroup);

_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:appGroup];

[_userDefaults registerDefaults:@{
OBAAnalyticsKeys.reportingEnabledUserDefaultsKey: @(NO)
}];

OBAAppConfig *appConfig = [[OBAAppConfig alloc] initWithAppBundle:NSBundle.mainBundle userDefaults:_userDefaults analytics:nil];

_app = [[OBAApplication alloc] initWithConfig:appConfig];
_app.delegate = self;
}

return self;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
[self.window makeKeyAndVisible];

// This method will call -applicationReloadRootInterface:, which creates the
// application's UI and attaches it to the window, so no need to do that here.
[self.app application:application didFinishLaunching:launchOptions];

return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
[self.app applicationDidBecomeActive:application];
}

- (void)applicationWillResignActive:(UIApplication *)application {
[self.app applicationWillResignActive:application];
}

#pragma mark - OBAApplicationDelegate

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [self.app application:app open:url options:options];
}

- (UIApplication*)uiApplication {
return [UIApplication sharedApplication];
}

- (void)performTestCrash {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
@[][1];
#pragma clang diagnostic pop
}

- (void)setIdleTimerDisabled:(BOOL)idleTimerDisabled {
UIApplication.sharedApplication.idleTimerDisabled = idleTimerDisabled;
}

- (BOOL)idleTimerDisabled {
return UIApplication.sharedApplication.idleTimerDisabled;
}

- (BOOL)registeredForRemoteNotifications {
return UIApplication.sharedApplication.registeredForRemoteNotifications;
}

- (void)applicationReloadRootInterface:(OBAApplication*)application {
void(^showRootController)(void) = ^{
self.rootController = [[OBAClassicApplicationRootController alloc] initWithApplication:application];
self.window.rootViewController = self.rootController;
};

if ([OBAOnboardingNavigationController needsToOnboardWithApplication:application]) {
self.window.rootViewController = [[OBAOnboardingNavigationController alloc] initWithApplication:application completion:^{
showRootController();
[UIView transitionWithView:self.window duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft animations:nil completion:nil];
}];
} else {
showRootController();
}
}

- (BOOL)canOpenURL:(NSURL*)url {
return [UIApplication.sharedApplication canOpenURL:url];
}

- (void)open:(NSURL * _Nonnull)url options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey,id> * _Nonnull)options completionHandler:(void (^ _Nullable)(BOOL))completion {
[UIApplication.sharedApplication openURL:url options:options completionHandler:completion];
}

- (NSDictionary<NSString*, NSString*>*)credits {
return @{@"Firebase": @"https://raw.githubusercontent.com/firebase/firebase-ios-sdk/master/LICENSE"};
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler {
return [self.app application:application continue:userActivity restorationHandler:restorationHandler];
}

#pragma mark - Push Notifications

- (BOOL)isRegisteredForRemoteNotifications {
return NO;
}

@end
20 changes: 20 additions & 0 deletions Apps/MTA/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xA6",
"green" : "0x39",
"red" : "0x00"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 14 additions & 0 deletions Apps/MTA/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "MTA-logo.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Apps/MTA/Assets.xcassets/Colors/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
20 changes: 20 additions & 0 deletions Apps/MTA/Assets.xcassets/Colors/brand.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xA6",
"green" : "0x39",
"red" : "0x00"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Apps/MTA/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
54 changes: 54 additions & 0 deletions Apps/MTA/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6ga-Gw-Qds">
<rect key="frame" x="0.0" y="813" width="414" height="49"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<items>
<tabBarItem title=" " image="map" catalog="system" id="n5N-fp-Tuq"/>
<tabBarItem title=" " image="clock" catalog="system" id="iPi-3C-xKn"/>
<tabBarItem title=" " image="bookmark" catalog="system" id="gVO-HH-2wA"/>
<tabBarItem title=" " image="ellipsis.circle" catalog="system" id="N5w-xu-YrQ"/>
</items>
</tabBar>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="6ga-Gw-Qds" firstAttribute="trailing" secondItem="6Tk-OE-BBY" secondAttribute="trailing" id="9id-g7-eJv"/>
<constraint firstItem="6ga-Gw-Qds" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="A2R-Ak-NFy"/>
<constraint firstItem="6ga-Gw-Qds" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="lq9-ZX-bgr"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="bookmark" catalog="system" width="112" height="128"/>
<image name="clock" catalog="system" width="128" height="121"/>
<image name="ellipsis.circle" catalog="system" width="128" height="121"/>
<image name="map" catalog="system" width="128" height="110"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading
Loading