Skip to content

Conversation

@lissine0
Copy link
Member

@lissine0 lissine0 commented Nov 30, 2024

I was going to link the UIKit AccountEdit view from the SwiftUI settings, so alpha users can use this PR, but it turned out to be ugly:

AccountEdit.mp4

As a result, the UIKit views rewritten in this PR are still being used. This should be the case until the account settings are in SwiftUI.
In order to test this PR, you need to revert lissine0@60839b8c

Notes:

  • The UIKit version of the settings is presented in a split view on iPads: the settings view on the left and the currently selected subview on the right. I didn't port that behavior. It currently looks on iPads like it does on macOS.
  • The UIKit version of the settings has in-app modals for accessing the mail app and the app store. I didn't port that behavior, and relied instead on normal links (mailto: and itms-apps://) which should open the relevant apps externally (I did not test this because it's not possible on the Simulator, but it should work).

Please indicate if you want these things added to the SwiftUI rewrite. I think the second one makes sense, as the modal is nicer than opening an app externally, but I'm not sure about the split view.

@tmolitor-stud-tu
Copy link
Member

That's really ugly and quite strange. I'd be curious what causes this distortion.

As for your PR itself: I just tried it and I'm okay with the mailto: and itms-apps://, but the split-view is broken now: opening the settings on ipad or iphone big enough to be in split-view will open the settings but don't show any back button or other means to close the settings again.

Even though I liked to have a split-view for our settings, I'm okay with removing that and only having a single-view in that case. But closing the settings should always be possible, split-view or not.

This fixes the back button being missing on big-screen iPhones
in landscape mode.

For more information, see the following commit messages:
8183703 and 009becf
@lissine0
Copy link
Member Author

lissine0 commented Dec 1, 2024

opening the settings on ipad or iphone big enough to be in split-view will open the settings but don't show any back button or other means to close the settings again.

On iPads (at least on the iPad 6th generation simulator), you can close the modal by clicking the area outside it, or by swiping it down.
On big-screen iPhones, this problem exists when in landscape mode;
It turns out that this was happening for all views using AddTopLevelNavigation.
I pushed a commit that fixes it.

@tmolitor-stud-tu
Copy link
Member

I don't like it if swiping down/tapping outside is the only method to close things. there should always be a button to do the same.

Copy link
Member

@tmolitor-stud-tu tmolitor-stud-tu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main point is: I'd like the xmpp class to be a data model just like the MLContact class is and then be used in conjunction with the ObservableKVOWrapper to get an auto-updating ui.

return MLXMPPManager.sharedInstance().connectedTime(for: self.accountID)
}
var avatar: UIImage {
return MLImageManager.sharedInstance().getIconFor(MLContact.createContact(fromJid: self.jid, andAccountID: self.accountID)) ?? UIImage(named: "noicon")!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the avatar property of MLContact to get auto-updates (wrap the MLContact in ObservableKVOWrapper.

Text(account.jid)
.frame(maxWidth: .infinity, alignment: .leading)

Text(self.connectionStatusString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

uptimeFormatter.doesRelativeDateFormatting = true
}

var connectionStatusString: String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the accountState of our xmpp object (in a ObservableKVOWrapper) and a switch statement to stringify the values of the xmppState enum.

return MLXMPPManager.sharedInstance().isAccount(forIdConnected: self.accountID)
}
var connectedTime: Date {
return MLXMPPManager.sharedInstance().connectedTime(for: self.accountID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use connectedTime property of our xmpp class, wrapped by a ObservableKVOWrapper.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the connectedTimeFor: method of MLXMPPManager can even be removed afterwards (no other code is using it if I don't miss something).

#endif
}
Section(header: Text("App")) {
NavigationLink(destination: LazyClosureView(GeneralSettings())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general settings should now be embedded in this settings rather than being a submenu (I only used a submenu because the settings weren't yet ported to swiftui).

UIPasteboard.general.setValue(HelperTools.appBuildVersionInfo(for: MLVersionType.IQ), forPasteboardType: UTType.utf8PlainText.identifier)
#if !DEBUG
tappedVersionInfo += 1
if tappedVersionInfo > 16 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tappedVersionInfo > 16 {
if tappedVersionInfo >= 16 {


struct Settings: View {
@State private var tappedVersionInfo = 0
@State private var showDebugEntry = HelperTools.defaultsDB().bool(forKey: "showLogInSettings")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a new class with @defaultsDB annotated properties to hold and autoupdate these settings, see the implementation of GeneralSettingsDefaultsDB in GeneralSettings.swift

#if !DEBUG
tappedVersionInfo += 1
if tappedVersionInfo > 16 {
HelperTools.defaultsDB().set(true, forKey: "showLogInSettings")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this, if you use the @defaultsDB annotation (see comment above).

}

@objc
func makeSettingsView() -> UIViewController {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since makeSettingsView does not need any special argument, you should add the settings view to our makeView function below.

}
}
}
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name(kMonalAccountStatusChanged)).receive(on: RunLoop.main)) { notification in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be needed anymore, once the xmpp class is a proper data model class used in conjunction with the ObservableKVOWrapper.

@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 10 times, most recently from 622ff1d to 7b95939 Compare December 29, 2024 09:43
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 9 times, most recently from b1bf422 to 3c4d40b Compare January 3, 2025 17:42
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 5 times, most recently from 518a17d to eaba046 Compare October 11, 2025 02:43
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 7 times, most recently from bc01177 to 6e8eeac Compare October 26, 2025 07:15
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 6 times, most recently from f5da846 to f31652b Compare November 15, 2025 03:31
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 7 times, most recently from 57224b1 to 3196274 Compare November 20, 2025 17:55
@tmolitor-stud-tu tmolitor-stud-tu force-pushed the develop branch 4 times, most recently from 130e72b to 3741841 Compare November 30, 2025 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants