Commit baaa8f3d authored by Wei Han's avatar Wei Han

code update

parent f38dff39
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
//QmsPlugin.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QmsPluginUI : NSObject
+ (UIViewController *)makeViewController;
@end
NS_ASSUME_NONNULL_END
//
// QmsPluginFramework.h
// QmsPluginFramework
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
//! Project version number for QmsPluginFramework.
FOUNDATION_EXPORT double QmsPluginFrameworkVersionNumber;
//! Project version string for QmsPluginFramework.
FOUNDATION_EXPORT const unsigned char QmsPluginFrameworkVersionString[];
// Public headers
#import <QmsPluginFramework/QmsPlugin.h>
framework module QmsPluginFramework {
umbrella header "QmsPluginFramework.h"
export *
module * { export * }
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
46196FWEMwEuy8Dd/6jLyvdFEok=
</data>
<key>Headers/QmsPluginFramework.h</key>
<data>
jlHmWnGf08fskfPJb//4vaShDlo=
</data>
<key>Info.plist</key>
<data>
w/Rc8R+JLx3x4AhZWV+3tG1CxCM=
</data>
<key>Modules/module.modulemap</key>
<data>
BD9YnWBkeFmDcuOl4cAjALd/7yw=
</data>
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
<data>
uuQ2Omt7lnrShVFriPpMiXZhx8kx6Km97GxC3m1ro+A=
</data>
</dict>
<key>Headers/QmsPluginFramework.h</key>
<dict>
<key>hash2</key>
<data>
/9Qe6QJ19ZC61+OfPl2+OZK1DI2Wa1lS++m7D41g3zI=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash2</key>
<data>
e+P6RtiuicqWfZ3H2B43r960DPkFwUWqXKWU+w7OVD0=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
//QmsPlugin.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QmsPluginUI : NSObject
+ (UIViewController *)makeViewController;
@end
NS_ASSUME_NONNULL_END
//
// QmsPluginFramework.h
// QmsPluginFramework
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
//! Project version number for QmsPluginFramework.
FOUNDATION_EXPORT double QmsPluginFrameworkVersionNumber;
//! Project version string for QmsPluginFramework.
FOUNDATION_EXPORT const unsigned char QmsPluginFrameworkVersionString[];
// Public headers
#import <QmsPluginFramework/QmsPlugin.h>
framework module QmsPluginFramework {
umbrella header "QmsPluginFramework.h"
export *
module * { export * }
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
46196FWEMwEuy8Dd/6jLyvdFEok=
</data>
<key>Headers/QmsPluginFramework.h</key>
<data>
jlHmWnGf08fskfPJb//4vaShDlo=
</data>
<key>Info.plist</key>
<data>
bbhIYcGh7MnGD7V1rEns5GGhP1g=
</data>
<key>Modules/module.modulemap</key>
<data>
BD9YnWBkeFmDcuOl4cAjALd/7yw=
</data>
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
<data>
uuQ2Omt7lnrShVFriPpMiXZhx8kx6Km97GxC3m1ro+A=
</data>
</dict>
<key>Headers/QmsPluginFramework.h</key>
<dict>
<key>hash2</key>
<data>
/9Qe6QJ19ZC61+OfPl2+OZK1DI2Wa1lS++m7D41g3zI=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash2</key>
<data>
e+P6RtiuicqWfZ3H2B43r960DPkFwUWqXKWU+w7OVD0=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
NSLog(@"in viewDidLoad ClientID: %@, ClientCode: %@, user_token: %@", self.ClientID, self.ClientCode, self.user_token); NSLog(@"in viewDidLoad ClientID: %@, ClientCode: %@, user_token: %@", self.ClientID, self.ClientCode, self.user_token);
NSLog(@"dashboard.drawerController = %@", self.drawerController); NSLog(@"dashboard.drawerController = %@", self.drawerController);
// [[OfflineSyncManager shared] clearOfflineQueue]; // [[OfflineSyncManager shared] clearOfflineQueue];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
@property (nonatomic, assign) BOOL isEditMode; @property (nonatomic, assign) BOOL isEditMode;
@property (nonatomic, strong) NSMutableArray *existingImages; @property (nonatomic, strong) NSMutableArray *existingImages;
@property (nonatomic, strong) NSMutableArray *addedImages; @property (nonatomic, strong) NSMutableArray *addedImages;
@property (nonatomic, strong) NSString *catName;
@property (nonatomic, strong) NSString *issueName;
@end @end
...@@ -75,10 +77,10 @@ ...@@ -75,10 +77,10 @@
} }
if (self.categories.count > 0) { if (self.categories.count > 0) {
NSDictionary *firstCat = self.categories.firstObject; NSDictionary *firstCat = self.categories.firstObject;
NSString *catName = firstCat[@"cat_name"]; self.catName = firstCat[@"cat_name"];
UIButton *catBtn = [self.view viewWithTag:2000]; UIButton *catBtn = [self.view viewWithTag:2000];
if ([catBtn isKindOfClass:[UIButton class]] && catName) { if ([catBtn isKindOfClass:[UIButton class]] && self.catName) {
[catBtn setTitle:catName forState:UIControlStateNormal]; [catBtn setTitle:self.catName forState:UIControlStateNormal];
[catBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [catBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
} }
} }
...@@ -110,16 +112,16 @@ ...@@ -110,16 +112,16 @@
} }
// 🏷 Prefill dropdown titles // 🏷 Prefill dropdown titles
NSString *catName = issue[@"category"]; self.catName = issue[@"category"];
NSString *typeName = issue[@"type"]; NSString *typeName = issue[@"type"];
NSString *issueName = issue[@"issue"]; self.issueName = issue[@"issue"];
UIButton *catBtn = [self.view viewWithTag:2000]; // Category UIButton *catBtn = [self.view viewWithTag:2000]; // Category
UIButton *typeBtn = [self.view viewWithTag:2001]; // Type UIButton *typeBtn = [self.view viewWithTag:2001]; // Type
UIButton *issueBtn = [self.view viewWithTag:2002]; // Issue UIButton *issueBtn = [self.view viewWithTag:2002]; // Issue
if ([catBtn isKindOfClass:[UIButton class]] && catName.length > 0) { if ([catBtn isKindOfClass:[UIButton class]] && self.catName.length > 0) {
[catBtn setTitle:catName forState:UIControlStateNormal]; [catBtn setTitle:self.catName forState:UIControlStateNormal];
[catBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [catBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
} }
...@@ -129,8 +131,8 @@ ...@@ -129,8 +131,8 @@
self.selectedTypeName = typeName; self.selectedTypeName = typeName;
} }
if ([issueBtn isKindOfClass:[UIButton class]] && issueName.length > 0) { if ([issueBtn isKindOfClass:[UIButton class]] && self.issueName.length > 0) {
[issueBtn setTitle:issueName forState:UIControlStateNormal]; [issueBtn setTitle:self.issueName forState:UIControlStateNormal];
[issueBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [issueBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
self.selectedIssueID = [NSString stringWithFormat:@"%@", issue[@"issue_id"] ?: @""]; self.selectedIssueID = [NSString stringWithFormat:@"%@", issue[@"issue_id"] ?: @""];
} }
...@@ -430,8 +432,9 @@ ...@@ -430,8 +432,9 @@
NSArray *categories = self.locationData[@"category"]; NSArray *categories = self.locationData[@"category"];
if (categories.count > 0) { if (categories.count > 0) {
NSDictionary *firstCategory = categories.firstObject; NSDictionary *firstCategory = categories.firstObject;
NSString *categoryName = locationField.text ?: @""; NSDictionary *cat = self.categories.firstObject;
[dropdown setTitle:categoryName forState:UIControlStateNormal]; self.catName = cat[@"cat_name"] ?: @"-";
[dropdown setTitle:self.catName forState:UIControlStateNormal];
[dropdown setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [dropdown setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
} else { } else {
[dropdown setTitle:@"(No Category)" forState:UIControlStateNormal]; [dropdown setTitle:@"(No Category)" forState:UIControlStateNormal];
...@@ -626,8 +629,8 @@ ...@@ -626,8 +629,8 @@
// Category (fixed) // Category (fixed)
if (self.categories.count > 0) { if (self.categories.count > 0) {
NSDictionary *cat = self.categories.firstObject; NSDictionary *cat = self.categories.firstObject;
NSString *catName = cat[@"cat_name"] ?: @"-"; self.catName = cat[@"cat_name"] ?: @"-";
[sender setTitle:catName forState:UIControlStateNormal]; [sender setTitle:self.catName forState:UIControlStateNormal];
[sender setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [sender setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
} }
return; return;
...@@ -664,6 +667,7 @@ ...@@ -664,6 +667,7 @@
if ([issueName isEqualToString:opt]) { if ([issueName isEqualToString:opt]) {
self.selectedIssueID = [NSString stringWithFormat:@"%@", issue[@"issue_id"]]; self.selectedIssueID = [NSString stringWithFormat:@"%@", issue[@"issue_id"]];
NSLog(@"✅ Selected Issue: %@ (ID: %@)", issueName, self.selectedIssueID); NSLog(@"✅ Selected Issue: %@ (ID: %@)", issueName, self.selectedIssueID);
self.issueName = issueName;
break; break;
} }
} }
...@@ -895,6 +899,15 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> * ...@@ -895,6 +899,15 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *
} }
- (void)performSubmit { - (void)performSubmit {
NSLog(@"Location: %@\nCategory: %@\nType: %@\nIssue: %@", self.locationField.text, self.catName, self.selectedTypeName, self.issueName);
NSDictionary *fieldNames = @{
@"locationName": self.locationField.text ?: @"",
@"categoryName": self.catName ?: @"",
@"typeName": self.selectedTypeName ?: @"",
@"issueName": self.issueName ?: @"",
};
if (self.isEditMode) { if (self.isEditMode) {
NSLog(@"📝 Updating existing issue instead of adding new one"); NSLog(@"📝 Updating existing issue instead of adding new one");
...@@ -927,7 +940,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> * ...@@ -927,7 +940,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *
[[OfflineSyncManager shared] queueUpdateIssue:updateData [[OfflineSyncManager shared] queueUpdateIssue:updateData
display:displayData display:displayData
images:self.addedImages]; images:self.addedImages
fieldNames:fieldNames];
[self showAlertWithTitle:@"Saved Offline" [self showAlertWithTitle:@"Saved Offline"
message:@"This will be synced when you're back online."]; message:@"This will be synced when you're back online."];
...@@ -1012,7 +1026,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> * ...@@ -1012,7 +1026,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *
[[OfflineSyncManager shared] queueAddIssue:issueData [[OfflineSyncManager shared] queueAddIssue:issueData
display:displayData display:displayData
images:self.uploadedImages]; images:self.uploadedImages
fieldNames:fieldNames];
[self showAlertWithTitle:@"Saved Offline" [self showAlertWithTitle:@"Saved Offline"
message:@"This will be synced when you're back online."]; message:@"This will be synced when you're back online."];
......
...@@ -15,21 +15,15 @@ ...@@ -15,21 +15,15 @@
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = UIColor.systemBackgroundColor; self.view.backgroundColor = UIColor.systemBackgroundColor;
NSString *unitName = self.itemData[@"unitName"]; NSLog(@"📦 Received History Data: %@", self.itemData);
NSString *createdBy = self.itemData[@"createdBy"]; NSString *plainText = [NSString stringWithFormat:@"%@", self.itemData];
NSString *createdOn = self.itemData[@"createdOn"]; NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
NSString *uploadedOn = self.itemData[@"uploadedOn"]; NSString *filePath = [docsPath stringByAppendingPathComponent:@"pendingDetail.txt"];
NSString *actionMade = self.itemData[@"type"]; [plainText writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSString *status = self.itemData[@"status"]; NSLog(@"📁 history details saved to %@", filePath);
NSLog(@"Unit: %@", unitName);
NSLog(@"Created by: %@", createdBy);
NSLog(@"Created on: %@", createdOn);
NSLog(@"Uploaded on: %@", uploadedOn);
NSLog(@"Action: %@", actionMade);
NSLog(@"Status: %@", status);
[self setupHeader]; [self setupHeader];
[self setupDetailContent];
} }
#pragma mark - Header Setup #pragma mark - Header Setup
...@@ -95,7 +89,6 @@ ...@@ -95,7 +89,6 @@
[container.widthAnchor constraintEqualToAnchor:scroll.widthAnchor], [container.widthAnchor constraintEqualToAnchor:scroll.widthAnchor],
]]; ]];
// Create vertical stack for labels
UIStackView *stack = [[UIStackView alloc] init]; UIStackView *stack = [[UIStackView alloc] init];
stack.axis = UILayoutConstraintAxisVertical; stack.axis = UILayoutConstraintAxisVertical;
stack.spacing = 12; stack.spacing = 12;
...@@ -108,14 +101,71 @@ ...@@ -108,14 +101,71 @@
[stack.trailingAnchor constraintEqualToAnchor:container.trailingAnchor constant:-16], [stack.trailingAnchor constraintEqualToAnchor:container.trailingAnchor constant:-16],
[stack.bottomAnchor constraintLessThanOrEqualToAnchor:container.bottomAnchor constant:-16], [stack.bottomAnchor constraintLessThanOrEqualToAnchor:container.bottomAnchor constant:-16],
]]; ]];
UILabel *unitLabel = [[UILabel alloc] init];
unitLabel.text = self.itemData[@"unitName"];
unitLabel.font = [UIFont boldSystemFontOfSize:22];
unitLabel.textColor = UIColor.labelColor;
unitLabel.numberOfLines = 0;
[stack addArrangedSubview:unitLabel];
// Create labels for each field // spacing
[stack addArrangedSubview:[self makeDetailLabel:@"Unit" value:self.itemData[@"unitName"]]]; UIView *spacer = [[UIView alloc] init];
[stack addArrangedSubview:[self makeDetailLabel:@"Created On" value:self.itemData[@"createdAt"]]]; [spacer.heightAnchor constraintEqualToConstant:12].active = YES;
[stack addArrangedSubview:[self makeDetailLabel:@"Created By" value:self.itemData[@"createdBy"]]]; [stack addArrangedSubview:spacer];
[stack addArrangedSubview:[self makeDetailLabel:@"Uploaded On" value:self.itemData[@"uploadedOn"] ?: @"-"]];
[stack addArrangedSubview:[self makeDetailLabel:@"Action" value:self.itemData[@"type"]]]; NSString *status = self.itemData[@"status"];
[stack addArrangedSubview:[self makeDetailLabel:@"Status" value:self.itemData[@"status"] ?: @"-"]]; UIColor *statusColor = [self colorForStatus:status];
// Add rows
[stack addArrangedSubview:[self makeRow:@"Created Date" value:self.itemData[@"createdOn"] color:nil]];
[stack addArrangedSubview:[self makeRow:@"Created By" value:self.itemData[@"createdBy"] color:nil]];
[stack addArrangedSubview:[self makeRow:@"Uploaded On" value:self.itemData[@"raw"][@"syncedAt"] color:statusColor]];
[stack addArrangedSubview:[self makeRow:@"Action Made" value:self.itemData[@"type"] color:nil]];
[stack addArrangedSubview:[self makeRow:@"Location" value:self.itemData[@"raw"][@"fieldNames"][@"locationName"] ?: @"-" color:nil]];
[stack addArrangedSubview:[self makeRow:@"Category" value:self.itemData[@"raw"][@"category"][@"categoryName"] ?: @"-" color:nil]];
[stack addArrangedSubview:[self makeRow:@"Type" value:self.itemData[@"raw"][@"type"][@"typeName"] color:nil]];
[stack addArrangedSubview:[self makeRow:@"Issue" value:self.itemData[@"raw"][@"issueDisplay"][@"issueName"] ?: @"-" color:nil]];
[stack addArrangedSubview:[self makeRow:@"Comment" value:self.itemData[@"raw"][@"remarks"] ?: @"-" color:nil]];
}
- (UIView *)makeRow:(NSString *)title
value:(NSString *)value
color:(UIColor *)color {
UIView *row = [[UIView alloc] init];
row.translatesAutoresizingMaskIntoConstraints = NO;
UILabel *left = [[UILabel alloc] init];
left.text = [NSString stringWithFormat:@"%@ :", title];
left.font = [UIFont systemFontOfSize:15];
left.textColor = UIColor.secondaryLabelColor;
left.translatesAutoresizingMaskIntoConstraints = NO;
UILabel *right = [[UILabel alloc] init];
right.text = value ?: @"-";
right.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
right.textColor = color ?: UIColor.labelColor;
right.numberOfLines = 0;
right.translatesAutoresizingMaskIntoConstraints = NO;
[row addSubview:left];
[row addSubview:right];
[NSLayoutConstraint activateConstraints:@[
[left.leadingAnchor constraintEqualToAnchor:row.leadingAnchor],
[left.topAnchor constraintEqualToAnchor:row.topAnchor],
[left.widthAnchor constraintEqualToConstant:120],
[right.leadingAnchor constraintEqualToAnchor:left.trailingAnchor constant:8],
[right.trailingAnchor constraintEqualToAnchor:row.trailingAnchor],
[right.topAnchor constraintEqualToAnchor:row.topAnchor],
[right.bottomAnchor constraintEqualToAnchor:row.bottomAnchor],
]];
return row;
} }
#pragma mark - Helper #pragma mark - Helper
...@@ -123,38 +173,20 @@ ...@@ -123,38 +173,20 @@
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
- (UIView *)makeDetailLabel:(NSString *)title value:(NSString *)value { - (UIColor *)colorForStatus:(NSString *)status {
UIView *view = [[UIView alloc] init]; if (!status) return UIColor.labelColor;
view.translatesAutoresizingMaskIntoConstraints = NO;
if ([status isEqualToString:@"FAILED"]) {
UILabel *titleLabel = [[UILabel alloc] init]; return [UIColor systemRedColor];
titleLabel.font = [UIFont boldSystemFontOfSize:16]; }
titleLabel.textColor = UIColor.labelColor;
titleLabel.text = title; if ([status isEqualToString:@"SUCCESS"] ||
titleLabel.translatesAutoresizingMaskIntoConstraints = NO; [status isEqualToString:@"SYNCED"] ||
[status isEqualToString:@"COMPLETED"]) {
UILabel *valueLabel = [[UILabel alloc] init]; return [UIColor systemGreenColor];
valueLabel.font = [UIFont systemFontOfSize:16]; }
valueLabel.textColor = UIColor.secondaryLabelColor;
valueLabel.text = value; return UIColor.labelColor;
valueLabel.numberOfLines = 0;
valueLabel.translatesAutoresizingMaskIntoConstraints = NO;
[view addSubview:titleLabel];
[view addSubview:valueLabel];
[NSLayoutConstraint activateConstraints:@[
[titleLabel.topAnchor constraintEqualToAnchor:view.topAnchor],
[titleLabel.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
[titleLabel.trailingAnchor constraintEqualToAnchor:view.trailingAnchor],
[valueLabel.topAnchor constraintEqualToAnchor:titleLabel.bottomAnchor constant:4],
[valueLabel.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
[valueLabel.trailingAnchor constraintEqualToAnchor:view.trailingAnchor],
[valueLabel.bottomAnchor constraintEqualToAnchor:view.bottomAnchor],
]];
return view;
} }
@end @end
...@@ -450,7 +450,7 @@ typedef NS_ENUM(NSInteger, HistorySyncStatus) { ...@@ -450,7 +450,7 @@ typedef NS_ENUM(NSInteger, HistorySyncStatus) {
[self.syncAgainButton.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], [self.syncAgainButton.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[self.syncAgainButton.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], [self.syncAgainButton.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[self.syncAgainButton.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], [self.syncAgainButton.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor],
[self.syncAgainButton.heightAnchor constraintEqualToConstant:50], [self.syncAgainButton.heightAnchor constraintEqualToConstant:30],
]]; ]];
} }
......
...@@ -335,6 +335,7 @@ typedef NS_ENUM(NSInteger, SyncPendingViewMode) { ...@@ -335,6 +335,7 @@ typedef NS_ENUM(NSInteger, SyncPendingViewMode) {
self.sections[indexPath.section][@"items"][indexPath.row]; self.sections[indexPath.section][@"items"][indexPath.row];
NSDictionary *raw = item[@"raw"] ?: item; NSDictionary *raw = item[@"raw"] ?: item;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self showDetailsForItem:raw]; [self showDetailsForItem:raw];
} }
......
...@@ -7,15 +7,20 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -7,15 +7,20 @@ NS_ASSUME_NONNULL_BEGIN
@interface OfflineSyncManager : NSObject @interface OfflineSyncManager : NSObject
+ (instancetype)shared; + (instancetype)shared;
- (NSMutableArray *)safeLoadQueue;
- (void)saveQueue:(NSArray *)queue;
// Queue actions // Queue actions
- (void)queueAddIssue:(NSDictionary *)payload - (void)queueAddIssue:(NSDictionary *)payload
display:(NSDictionary *)display display:(NSDictionary *)display
images:(NSArray<UIImage *> *)images; images:(NSArray<UIImage *> *)images
fieldNames:(NSDictionary *)fieldNames;
- (void)queueUpdateIssue:(NSDictionary *)payload - (void)queueUpdateIssue:(NSDictionary *)payload
display:(NSDictionary *)display display:(NSDictionary *)display
images:(NSArray<UIImage *> *)images; images:(NSArray<UIImage *> *)images
fieldNames:(NSDictionary *)fieldNames;
- (void)queueAddInfo:(NSString *)issueID - (void)queueAddInfo:(NSString *)issueID
remarks:(NSString *)remarks remarks:(NSString *)remarks
...@@ -40,8 +45,6 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -40,8 +45,6 @@ NS_ASSUME_NONNULL_BEGIN
// Retry failed history item // Retry failed history item
- (void)retryHistoryItem:(NSDictionary *)historyItem; - (void)retryHistoryItem:(NSDictionary *)historyItem;
- (void)retryAllFailedHistoryItems;
// Download Units // Download Units
- (void)startDownloadUnitImagesWithProgress:(void (^)(NSInteger completed, NSInteger total))progress - (void)startDownloadUnitImagesWithProgress:(void (^)(NSInteger completed, NSInteger total))progress
completion:(void (^)(BOOL success))completion; completion:(void (^)(BOOL success))completion;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment