Skip to content

Commit

Permalink
Merge pull request #62 from dbukowski/feature/first_refactoring_to_sw…
Browse files Browse the repository at this point in the history
…ift_and_swift_ui

Feature/first refactoring to swift and swift UI
  • Loading branch information
gamada-de authored Feb 11, 2022
2 parents ebe00b1 + 28b4b7d commit 73abf16
Show file tree
Hide file tree
Showing 64 changed files with 2,585 additions and 3,459 deletions.
43 changes: 0 additions & 43 deletions DBDebugToolkit/Classes/Console/DBConsoleViewController.h

This file was deleted.

127 changes: 0 additions & 127 deletions DBDebugToolkit/Classes/Console/DBConsoleViewController.m

This file was deleted.

4 changes: 2 additions & 2 deletions DBDebugToolkit/Classes/CustomActions/DBCustomAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef void(^DBCustomActionBody)(void);
/**
Name of the action presented in the menu. Read-only.
*/
@property (nonatomic, readonly, nullable) NSString * name;
@property (nonatomic, readonly, nonnull) NSString * name;

///---------------------
/// @name Initialization
Expand All @@ -44,7 +44,7 @@ typedef void(^DBCustomActionBody)(void);
@param name The name of the action that will be presented in the menu.
@param body The block containing the code that should be run when the user selects the created custom action.
*/
+ (nonnull instancetype)customActionWithName:(nullable NSString *)name body:(nullable DBCustomActionBody)body;
+ (nonnull instancetype)customActionWithName:(nonnull NSString *)name body:(nullable DBCustomActionBody)body;

///-----------------
/// @name Performing
Expand Down
6 changes: 3 additions & 3 deletions DBDebugToolkit/Classes/CustomActions/DBCustomAction.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@interface DBCustomAction ()

@property (nonatomic, strong, nullable) NSString *name;
@property (nonatomic, strong, nonnull) NSString *name;
@property (nonatomic, copy, nullable) DBCustomActionBody body;

@end
Expand All @@ -33,7 +33,7 @@ @implementation DBCustomAction

#pragma mark - Initialization

- (nonnull instancetype)initWithName:(nullable NSString *)name body:(nullable DBCustomActionBody)body {
- (nonnull instancetype)initWithName:(nonnull NSString *)name body:(nullable DBCustomActionBody)body {
self = [super init];
if (self) {
self.name = name;
Expand All @@ -43,7 +43,7 @@ - (nonnull instancetype)initWithName:(nullable NSString *)name body:(nullable DB
return self;
}

+ (nonnull instancetype)customActionWithName:(nullable NSString *)name body:(nullable DBCustomActionBody)body {
+ (nonnull instancetype)customActionWithName:(nonnull NSString *)name body:(nullable DBCustomActionBody)body {
return [[self alloc] initWithName:name body:body];
}

Expand Down
20 changes: 20 additions & 0 deletions DBDebugToolkit/Classes/DBDebugToolkit.m
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,26 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
}

- (DBMenuTableViewController *)menuViewController {
if (!_menuViewController) {
_menuViewController = [SwiftUIViewFactory
makeMenuListViewWithPerformanceToolkit:self.performanceToolkit
consoleOutputCaptor:self.consoleOutputCaptor
networkToolkit:self.networkToolkit
userInterfaceToolkit:self.userInterfaceToolkit
locationToolkit:self.locationToolkit
coreDataToolkit:self.coreDataToolkit
crashReportsToolkit:self.crashReportsToolkit
deviceInfoProvider:[DBDeviceInfoProvider new]
customVariables:self.customVariables
customActions:self.customActions
menuDismissAction:^{
[self closeMenu];
}
];
}

return _menuViewController;

if (!_menuViewController) {
NSBundle *bundle = [NSBundle debugToolkitBundle];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"DBMenuTableViewController" bundle:bundle];
Expand Down
2 changes: 2 additions & 0 deletions DBDebugToolkit/Classes/Extensions/Bundle+BuildInfo.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

@objc
public extension Bundle {
static var applicationName: String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

extension DBRequestModel {
var responseDescription: String {
var value = ""
if !finished {
let dateString = DateFormatter.localizedString(
from: sendingDate,
dateStyle: .medium,
timeStyle: .medium
)
value.append("Sent at \(dateString)...")
} else if didFinishWithError {
value.append("Error \(errorCode): \(localizedErrorDescription ?? "")")
} else {
let formattedValue = String(format: "%.2lfs", duration)
value.append("\(formattedValue)")
if let statusCode = statusCode {
value.append(", HTTP \(statusCode)")
}
if let localizedStatusCodeString = localizedStatusCodeString {
value.append(" - \(localizedStatusCodeString)")
}
}

return value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation

extension URLRequest.CachePolicy {
var readableDescription: String {
switch self {
case .reloadIgnoringLocalAndRemoteCacheData:
return "Reload ignoring local and remote cache data"
case .reloadIgnoringLocalCacheData:
return "Reload ignoring local cache data"
case .returnCacheDataElseLoad:
return "Return cache data else load"
case .reloadRevalidatingCacheData:
return "Reload revalidating cache data"
case .returnCacheDataDontLoad:
return "Return cache data, don't load"
case .useProtocolCachePolicy:
return "Use protocol cache policy"
case .reloadIgnoringCacheData:
return "Reload ignoring cache data"
@unknown default:
return "unknown"
}
}
}
9 changes: 0 additions & 9 deletions DBDebugToolkit/Classes/Menu/DBMenuTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#import "DBMenuTableViewController.h"
#import "DBPerformanceTableViewController.h"
#import "NSBundle+DBDebugToolkit.h"
#import "DBConsoleViewController.h"
#import "DBNetworkViewController.h"
#import "DBUserInterfaceTableViewController.h"
#import "DBLocationTableViewController.h"
#import "DBResourcesTableViewController.h"
Expand Down Expand Up @@ -97,13 +95,6 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([destinationViewController isKindOfClass:[DBPerformanceTableViewController class]]) {
DBPerformanceTableViewController *performanceTableViewController = (DBPerformanceTableViewController *)destinationViewController;
performanceTableViewController.performanceToolkit = self.performanceToolkit;
} else if ([destinationViewController isKindOfClass:[DBConsoleViewController class]]) {
DBConsoleViewController *consoleViewController = (DBConsoleViewController *)destinationViewController;
consoleViewController.consoleOutputCaptor = self.consoleOutputCaptor;
consoleViewController.deviceInfoProvider = self.deviceInfoProvider;
} else if ([destinationViewController isKindOfClass:[DBNetworkViewController class]]) {
DBNetworkViewController *networkViewController = (DBNetworkViewController *)destinationViewController;
networkViewController.networkToolkit = self.networkToolkit;
} else if ([destinationViewController isKindOfClass:[DBUserInterfaceTableViewController class]]) {
DBUserInterfaceTableViewController *userInterfaceTableViewController = (DBUserInterfaceTableViewController *)destinationViewController;
userInterfaceTableViewController.userInterfaceToolkit = self.userInterfaceToolkit;
Expand Down
8 changes: 2 additions & 6 deletions DBDebugToolkit/Classes/Network/DBNetworkToolkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import <DBRequestOutcome.h>

@class DBNetworkToolkit;
@class DBRequestModel;

/**
A protocol used for informing about changes in logging settings or in logged requests list.
Expand Down Expand Up @@ -70,11 +71,6 @@ extern Class DBNetworkURLProtocolClass;
*/
+ (instancetype)sharedInstance;

/**
This method registers NSURLProtocol a protocol class.
*/
+ (void)registerURLProtocolClass:(Class)protocolClass;

/**
Returns a string containing the path to the directory where the requests data is stored.
*/
Expand Down Expand Up @@ -108,6 +104,6 @@ extern Class DBNetworkURLProtocolClass;
/**
An array containing all the logged requests.
*/
@property (nonatomic, readonly) NSArray *savedRequests;
@property (nonatomic, readonly) NSArray<DBRequestModel *> *savedRequests;

@end
Loading

0 comments on commit 73abf16

Please sign in to comment.