Skip to content

Commit

Permalink
Make new chat view configurable via debug menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Dec 24, 2024
1 parent 4c31afa commit 27061c9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
43 changes: 36 additions & 7 deletions Monal/Classes/ActiveChatsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "MLIQProcessor.h"
#import "Quicksy_Country.h"
#import <Monal-Swift.h>
#import "chatViewController.h"

#define prependToViewQueue(firstArg, ...) metamacro_if_eq(0, metamacro_argcount(__VA_ARGS__))([self prependToViewQueue:firstArg withId:MLViewIDUnspecified andFile:(char*)__FILE__ andLine:__LINE__ andFunc:(char*)__func__])(_prependToViewQueue(firstArg, __VA_ARGS__))
#define _prependToViewQueue(ownId, block) [self prependToViewQueue:block withId:ownId andFile:(char*)__FILE__ andLine:__LINE__ andFunc:(char*)__func__]
Expand Down Expand Up @@ -1057,19 +1058,37 @@ -(void) presentChatWithContact:(MLContact*) contact andCompletion:(monal_id_bloc
};
[self scrollToContact:contact];
[self showDetailViewController:chatView sender:self];
if(completion != nil)
completion(@YES);
};

//open chat (make sure we have an active buddy for it and add it to our ui, if needed)
//but don't animate this if the contact is already present in our list
[[DataLayer sharedInstance] addActiveBuddies:contact.contactJid forAccount:contact.accountID];
if([[self getChatArrayForSection:pinnedChats] containsObject:contact] || [[self getChatArrayForSection:unpinnedChats] containsObject:contact])
presentator();
{
if([[HelperTools defaultsDB] boolForKey:@"showNewChatView"])
presentator();
else
{
[self scrollToContact:contact];
[self performSegueWithIdentifier:@"showConversation" sender:contact];
}
if(completion != nil)
completion(@YES);
}
else
{
[self insertOrMoveContact:contact completion:^(BOOL finished __unused) {
presentator();
if([[HelperTools defaultsDB] boolForKey:@"showNewChatView"])
presentator();
else
{
[self scrollToContact:contact];
[self performSegueWithIdentifier:@"showConversation" sender:contact];
}
if(completion != nil)
completion(@YES);
}];
}
}];
}];
}
Expand Down Expand Up @@ -1106,6 +1125,16 @@ -(void) performSegueWithIdentifier:(NSString*) identifier sender:(id) sender
-(void) prepareForSegue:(UIStoryboardSegue*) segue sender:(id) sender
{
DDLogInfo(@"Got segue identifier '%@'", segue.identifier);

if([segue.identifier isEqualToString:@"showConversation"])
{
UINavigationController* nav = segue.destinationViewController;
chatViewController* chatVC = (chatViewController*)nav.topViewController;
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = barButtonItem;
[chatVC setupWithContact:sender];
}

if([segue.identifier isEqualToString:@"showDetails"])
{
UIViewController* detailsViewController = [[SwiftuiInterface new] makeContactDetails:sender];
Expand Down Expand Up @@ -1523,16 +1552,16 @@ -(void) dismissRecursorWithViewControllers:(NSMutableArray*) viewControllers ani
-(chatViewController* _Nullable) currentChatView
{
//TODO: this has to be adapted to the new chatui
return nil;
/*
if([[HelperTools defaultsDB] boolForKey:@"showNewChatView"])
return nil;

NSArray* controllers = ((UINavigationController*)self.splitViewController.viewControllers[0]).viewControllers;
chatViewController* chatView = nil;
if(controllers.count > 1)
chatView = [((UINavigationController*)controllers[1]).viewControllers firstObject];
if(![chatView isKindOfClass:NSClassFromString(@"chatViewController")])
chatView = nil;
return chatView;
*/
}

-(void) scrollToContact:(MLContact*) contact
Expand Down
7 changes: 7 additions & 0 deletions Monal/Classes/DebugView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class DebugDefaultDB: ObservableObject {

@defaultsDB("hasCompletedOnboarding")
var hasCompletedOnboarding: Bool

@defaultsDB("showNewChatView")
var showNewChatView: Bool
}

struct LogFilesView: View {
Expand Down Expand Up @@ -123,6 +126,10 @@ struct CrashTestingView: View {
Toggle(isOn: $defaultDB.hasCompletedOnboarding) {
Text("Don't show onboarding")
}

Toggle(isOn: $defaultDB.showNewChatView) {
Text("Show new SwiftUI ChatView")
}
}

Text("The following buttons allow you to forcefully crash the app using several different methods to test the crash handling.")
Expand Down
2 changes: 2 additions & 0 deletions Monal/Classes/MLXMPPManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ -(void) defaultSettings

[self upgradeBoolUserSettingsIfUnset:@"showAdvancedUI" toDefault:NO];

[self upgradeBoolUserSettingsIfUnset:@"showNewChatView" toDefault:YES];

// //always show onboarding on simulator for now
// #if TARGET_OS_SIMULATOR
// [[HelperTools defaultsDB] setBool:NO forKey:@"hasCompletedOnboarding"];
Expand Down

0 comments on commit 27061c9

Please sign in to comment.