Commit 2ac4e245 authored by Wei Han's avatar Wei Han

UI code update

parent db23c5fb
...@@ -4,4 +4,7 @@ ...@@ -4,4 +4,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface AddIssueDetailsViewController : UIViewController @interface AddIssueDetailsViewController : UIViewController
@property (nonatomic, strong) NSString *selectedLocationName;
@property (nonatomic, strong) NSMutableArray<UIImage *> *uploadedImages;
@end @end
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
@property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIImageView *planImageView; @property (nonatomic, strong) UIImageView *planImageView;
@property (nonatomic, strong) NSString *selectedLocation;
@end @end
@implementation PlanViewController @implementation PlanViewController
...@@ -170,11 +172,115 @@ ...@@ -170,11 +172,115 @@
} }
- (void)handleNextScreen { - (void)handleNextScreen {
NSLog(@"➡️ Test button tapped — navigating to AddIssueDetailsViewController"); [self showAddIssuePopup];
}
- (void)showAddIssuePopup {
NSLog(@"🟢 Showing Add Issue popup");
// Background dim view
UIView *overlay = [[UIView alloc] initWithFrame:self.view.bounds];
overlay.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
overlay.alpha = 0.0;
overlay.tag = 999; // so we can find and remove it later
[self.view addSubview:overlay];
// Popup container
CGFloat safeBottom = self.view.safeAreaInsets.bottom;
CGFloat popupHeight = 180 + safeBottom;
UIView *popup = [[UIView alloc] initWithFrame:CGRectMake(0,
self.view.bounds.size.height,
self.view.bounds.size.width,
popupHeight)];
popup.backgroundColor = UIColor.whiteColor;
popup.layer.cornerRadius = 16;
popup.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
popup.clipsToBounds = YES;
popup.tag = 1000;
[self.view addSubview:popup];
// Label — “You have selected”
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, popup.bounds.size.width - 40, 20)];
label.text = @"You have selected:";
label.textColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
[popup addSubview:label];
// Mock location name
UILabel *locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, popup.bounds.size.width - 40, 24)];
locationLabel.text = @"Building A - 2nd Floor";
self.selectedLocation = locationLabel.text;
locationLabel.textColor = [UIColor blackColor];
locationLabel.font = [UIFont boldSystemFontOfSize:17];
[popup addSubview:locationLabel];
// Buttons row
CGFloat buttonWidth = (self.view.bounds.size.width - 48) / 2;
CGFloat buttonY = popupHeight - 60 - safeBottom; // ✅ push up above safe area
UIButton *reselectButton = [UIButton buttonWithType:UIButtonTypeSystem];
reselectButton.frame = CGRectMake(16, buttonY, buttonWidth, 44);
[reselectButton setTitle:@"Reselect" forState:UIControlStateNormal];
[reselectButton setTitleColor:[UIColor colorWithRed:0/255.0 green:109/255.0 blue:141/255.0 alpha:1]
forState:UIControlStateNormal];
reselectButton.layer.borderWidth = 1.0;
reselectButton.layer.borderColor = [UIColor colorWithRed:0/255.0 green:109/255.0 blue:141/255.0 alpha:1].CGColor;
reselectButton.layer.cornerRadius = 8;
[reselectButton addTarget:self action:@selector(dismissAddIssuePopup)
forControlEvents:UIControlEventTouchUpInside];
[popup addSubview:reselectButton];
UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeSystem];
nextButton.frame = CGRectMake(32 + buttonWidth, buttonY, buttonWidth, 44);
[nextButton setTitle:@"Next" forState:UIControlStateNormal];
[nextButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
nextButton.backgroundColor = [UIColor colorWithRed:0/255.0 green:109/255.0 blue:141/255.0 alpha:1];
nextButton.layer.cornerRadius = 8;
[nextButton addTarget:self action:@selector(handleConfirmAddIssue)
forControlEvents:UIControlEventTouchUpInside];
[popup addSubview:nextButton];
// Animate in
[UIView animateWithDuration:0.3 animations:^{
overlay.alpha = 1.0;
popup.frame = CGRectMake(0,
self.view.bounds.size.height - popupHeight,
self.view.bounds.size.width,
popupHeight);
}];
}
- (void)dismissAddIssuePopup {
NSLog(@"❌ Dismissing Add Issue popup");
UIView *overlay = [self.view viewWithTag:999];
UIView *popup = [self.view viewWithTag:1000];
[UIView animateWithDuration:0.25 animations:^{
overlay.alpha = 0.0;
popup.frame = CGRectMake(0,
self.view.bounds.size.height,
popup.bounds.size.width,
popup.bounds.size.height);
} completion:^(BOOL finished) {
[overlay removeFromSuperview];
[popup removeFromSuperview];
}];
}
- (void)handleConfirmAddIssue {
NSLog(@"✅ Confirm Add Issue pressed");
// Dismiss popup first
[self dismissAddIssuePopup];
// Then open AddIssueDetailsViewController after a short delay
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
AddIssueDetailsViewController *nextVC = [[AddIssueDetailsViewController alloc] init]; AddIssueDetailsViewController *nextVC = [[AddIssueDetailsViewController alloc] init];
nextVC.selectedLocationName = self.selectedLocation; // ✅ Pass it here
nextVC.modalPresentationStyle = UIModalPresentationFullScreen; nextVC.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nextVC animated:YES completion:nil]; [self presentViewController:nextVC animated:YES completion:nil];
});
} }
#pragma mark - Actions #pragma mark - Actions
......
// DashboardAPIClient.h
#import <Foundation/Foundation.h>
@interface DashboardAPIClient : NSObject
+ (void)fetchDashboardSummary:(void (^)(NSDictionary *data))completion;
+ (void)fetchAnnouncements:(void (^)(NSArray *data))completion;
+ (void)fetchAppointments:(void (^)(NSArray *data))completion;
+ (void)fetchIssues:(void (^)(NSArray *data))completion;
+ (void)fetchHeaderInfo:(void (^)(NSDictionary *data))completion;
@end
// DashbaordAPIClient.mm
#import "DashboardAPIClient.h"
@implementation DashboardAPIClient
+ (void)fetchDashboardSummary:(void (^)(NSDictionary *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/users/1"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { completion(nil); return; }
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
completion(json);
});
}] resume];
}
+ (void)fetchAnnouncements:(void (^)(NSArray *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/posts?_limit=5"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { completion(nil); return; }
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
completion(json);
});
}] resume];
}
+ (void)fetchAppointments:(void (^)(NSArray *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/todos?_limit=5"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { completion(nil); return; }
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
completion(json);
});
}] resume];
}
+ (void)fetchIssues:(void (^)(NSArray *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/comments?_limit=5"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { completion(nil); return; }
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
completion(json);
});
}] resume];
}
+ (void)fetchHeaderInfo:(void (^)(NSDictionary *data))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/photos/1"];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"❌ Header info fetch failed: %@", error);
if (completion) completion(@{});
return;
}
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
if (completion) completion(json);
}];
[task resume];
}
@end
//DashboardHeaderView.mm
#import "DashboardHeaderView.h" #import "DashboardHeaderView.h"
@implementation DashboardHeaderView @implementation DashboardHeaderView
......
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