Commit Graph

170 Commits

Author SHA1 Message Date
Davide De Rosa d10edc69fe Restore truncated VPN footer workaround 2022-08-19 08:34:55 +02:00
Davide De Rosa 80f71507e3 Do not navigate to active profile on launch 2022-08-05 12:50:12 +02:00
Davide De Rosa 2c5f3d0bf0 Send app to background in OrganizerView handler
Keep handler in a single place.
2022-07-17 14:47:15 +02:00
Davide De Rosa 9458c4f3a3 Fix server description and sorting
- Name (countries, area)
- Index
- Tags

Also use short description in menu (without country prefix).
2022-07-16 17:39:42 +02:00
Davide De Rosa 58e375ec41 Attach @MainActor where needed
Some methods were updating UI from non-main thread.
2022-07-16 17:39:42 +02:00
Davide De Rosa 0a2d1e9d37 Mitigate fatalError() in properties, fail gracefully
Do not trigger fatalError() on properties too much because
SwiftUI may read them at any unpredictable time.
2022-07-08 20:01:53 +02:00
Davide De Rosa ebe8ae3d29 Retain profiles order, no active on top 2022-07-04 00:32:06 +02:00
Davide De Rosa 9a8477225e Refactor library into domain + impl 2022-06-23 23:31:01 +02:00
Davide De Rosa 10b4c321c8 Separate context responsibilities
- Split Core and App context

- Move .shared instantiation to extension

Context may differ by target.
2022-06-16 13:42:53 +02:00
Davide De Rosa 14b42fbea5 Persist managers state to generic key-value store
Move all persisted state out of AppManager to where it really
belongs. To do that, inject a shared KeyValueStore object into
managers that need to persist part of their state in a strongly
typed manner.

Below are persisted states:

- PersistenceManager
    - persistenceAuthor

- ProfileManager
    - activeProfileId

- UpgradeManager (formerly AppManager)
    - didMigrateToV2 (migrate former value)

- VPNManager
    - tunnelLogFormat
    - masksPrivateData

A similar approach is used for app-specific preferences, by using
a strongly typed enum (AppPreference) together with SwiftUI
@AppStorage property wrapper.

Worth moving logging logic into a specific LogManager.

Finally, drop any former view dependency on AppManager, as states
are now accessed through specific managers.
2022-06-16 13:42:37 +02:00
Davide De Rosa f752594d3c Refactor no autocorrection into raw text style 2022-05-24 08:25:34 +02:00
Davide De Rosa 02213a7c50 Drop truncation hack 2022-05-23 10:10:02 +02:00
Davide De Rosa a2d4ed370e Revisit sidebar with per-profile VPN toggles 2022-05-21 19:15:37 +02:00
Davide De Rosa f0c5ecd84f Handle configuration errors out of VPN status
On configuration error, retain information about the profile that
triggered the error. For now, present an alert, but with this
information the UI can be easily changed later.
2022-05-21 19:01:49 +02:00
Davide De Rosa 46a8fb8a74 Delay presentation of imported file modal
Fixes navigation bug on iOS 14 preventing modal from dismissing
via close button.
2022-05-20 16:35:45 +02:00
Davide De Rosa d6866e8e95 Fix iPad multitasking condition 2022-05-20 11:58:25 +02:00
Davide De Rosa c88dfc28c4 Simplify a few things of CopySavingButton
- Make saving handler more readable

- Drop unnecessary protocol
2022-05-18 14:10:11 +02:00
Davide De Rosa ddce671c62 Move theme extensions to non-reusable 2022-05-18 11:33:29 +02:00
Davide De Rosa 7196aeab0d Trust Ethernet on Mac 2022-05-16 11:19:33 +02:00
Davide De Rosa 16d618df0e Show info menu in ProfileView on iPad/Mac
Use .navigationBarTrailing to avoid artifact on Catalyst (item
relocates when first clicked).

Rename menu files too.
2022-05-16 11:18:58 +02:00
Davide De Rosa 6fddbb8bfc Decouple menus from OrganizerView
Could move .sheet() from parent View to Menu, but no luck with
.fileImporter()
2022-05-16 11:18:58 +02:00
Davide De Rosa d89130bc3a Reorganize profile menu into computed properties 2022-05-16 11:18:58 +02:00
Davide De Rosa e87ad06c5d Drop old observables from profiles list
List was being reloaded e.g. on ProductManager receipt updates,
but profile in-app eligibility is not a thing anymore.
2022-05-16 10:59:12 +02:00
Davide De Rosa 137bacb542 Add contextual profile delete
Without confirmation alert though.
2022-05-15 22:24:36 +02:00
Davide De Rosa 743facca6b Improve Catalyst appearance
- Revert to more "stable" iPad idiom

- Set accent color the proper way

- Use .tint when available

- Unify navigation style by idiom

- Retain navigation bars in sidebar/detail

- Lighten sidebar appearance

- Fix Menu style (dropdown -> button)

- Use native Picker (dropdown)

- Use switch toggles rather than checkboxes

- Replace .actionSheet with .alert

- Increase minimum row height

CAVEAT: on Mac with iPad idiom, having a Section in .sidebar
produces artifacts. Header keeps changing height for no reason.
Retain Section on iPad multitasking only to not break navigation.
2022-05-15 22:24:36 +02:00
Davide De Rosa eaaa1fe260 Move device checks to Theme
Drop unused code along the way.
2022-05-15 22:24:36 +02:00
Davide De Rosa d558edf665 Assume test build if appType == .beta 2022-05-15 21:03:32 +02:00
Davide De Rosa 6c87e0a15b Use gray for profile subtitle 2022-05-15 21:03:32 +02:00
Davide De Rosa 9984c56084 Drop unnecessary async from migration code
Providers are not fetched at migration time, they only are after
opening a profile (marked non-ready until then).

Still retain Task for migration to be executed asynchronously.
2022-05-05 11:04:12 +02:00
Davide De Rosa 15a4cc8f75 Change some icons in extra menu
- Main icon

- Review icon
2022-05-05 09:58:53 +02:00
Davide De Rosa cca2dca047 Export providers database in beta 2022-05-05 09:46:12 +02:00
Davide De Rosa abb23e8234 Fix missing animation loading non-ready profile
When there is no initial active profile.
2022-05-05 08:57:02 +02:00
Davide De Rosa 92caf67876 Replace dimming with different icon 2022-05-03 19:24:46 +02:00
Davide De Rosa 4cb18965c9 Set duplicate as current inside ProfileManager
When setting duplicate as current, batch save original profile and
duplicate in a single call via profilesToSave. This is to avoid a
double call to willUpdateProfiles() when saving Core Data context.

In order to set current profile to one that has not been persisted
yet (the duplicate), we need to resort to a pendingProfiles map
where to look the duplicate up when setting currentProfileId.

Either way, iOS 14 cannot handle updating a "hot" change in a
presented NavigationLink. Changing currentProfileId binding while
in ProfileView messes up navigation completely (multiple push and
pop events). Avoid.
2022-05-03 18:35:19 +02:00
Davide De Rosa 943bce5515 Bind navigation to ProfileManager directly
- Do the profile loading inside the model

- Allow setting current profile to a transient profile

- Check .placeholder before saving current profile

XXX: avoid loading active profile on iPad portrait.
2022-05-03 18:35:17 +02:00
Davide De Rosa 7036ca5f41 Fix handling of non-ready profiles
- Omit title while isLoading, to not show former profile name

- Animate on isLoading
2022-05-03 15:54:19 +02:00
Davide De Rosa b9248cbb89 Animate profile removal
Fade into WelcomeView.
2022-05-03 15:44:47 +02:00
Davide De Rosa ca49d8bfc6 Increase vertical padding in profile rows 2022-05-03 15:43:55 +02:00
Davide De Rosa 8230666ab2 Only use wrapping Section to fix iPad multitasking 2022-05-03 15:43:15 +02:00
Davide De Rosa 3c0e511e84 Split again OrganizerView and ProfilesList
On iOS 14, Organizer scrolls abruptly on profile selection. It
looks like this was introduced by merging ProfilesList into
OrganizerView.

Try to revert merge to split observation responsibilities.

Drop unused AppManager in +Scene along the way.
2022-05-03 14:40:41 +02:00
Davide De Rosa 93abaf538b Simplify redundant parts of ProfileManager
- Drop overthought activeHeader

- Drop willUpdateCurrentProfile, use observable

- Drop willUpdateActiveId, observe value publisher
2022-05-03 14:36:55 +02:00
Davide De Rosa d3bd41b251 Do not blink circle while connected 2022-05-02 10:56:40 +02:00
Davide De Rosa cc681dfeab Refine profile icons and animate if connected
Assume 3 different profile states:

- Active and connected
- Active
- Inactive
2022-05-02 10:48:12 +02:00
Davide De Rosa 576eb1512a Fix slow active profile selection on launch
Regression due to missing .stack navigation style basically.

Restore .onAppear() on NavigationLink.
2022-05-02 09:53:18 +02:00
Davide De Rosa 472b5e4b41 Fix active profile flickering on first launch
Move .onAppear() handler to main view.
2022-05-01 20:16:05 +02:00
Davide De Rosa 3571c7db35 Reduce vertical padding in profile rows 2022-05-01 20:06:03 +02:00
Davide De Rosa 48d499569b Use block versions of Section header/footer 2022-05-01 19:48:24 +02:00
Davide De Rosa 171c1e1dd4 Omit wrapping Section on Mac 2022-05-01 19:30:56 +02:00
Davide De Rosa cfc0d4f572 Restore active profile on top
Flashing on activation was caused by VPNManager.disable() in
ProfileView+VPN, because by setting lastError to nil it would
notify a change to ProfileRow (via VPNStateView) during the
profile row activation animation. That caused the flicker.

Instead, disable VPN first, then start the animation.

Anyway, avoid clearing a nil lastError.
2022-05-01 19:19:43 +02:00
Davide De Rosa edc7cdf045 Merge List into OrganizerView
- Restore wrapping Section as it seems to fix multitasking

- Hide profiles section if empty
2022-05-01 19:19:31 +02:00
Davide De Rosa 8003b4a92d Observe currentProfile in ProfileView
ProfileView is not interested in changes in other profiles
notified by ProfileManager. Set isLoading inside
ObservableObject for observable to be self-contained.

Loses observation of profile deletion, but dismiss on removal is
actually handled by OrganizerView, not ProfileView.

Also drop unused presentationMode.
2022-05-01 19:14:34 +02:00
Davide De Rosa 9af67e12ce Drop profiles Section wrapper 2022-04-29 19:51:18 +02:00
Davide De Rosa 0047d095fb Adjust navigation style to all devices
- Mac
    - Drop all styles
    - Tweak hide title bar
    - Hide navigation bar

- Restore single section for all profiles
    - Allows using NavigationLink safely
    - Indirectly fixes multitasking
    - Retains selection on profile activation
    - Clean up presentActiveProfile

- Leave active profile in its position
    - Fixes Mac flashing row selection on profile activation

- Unify profile row appearance
    - Use fixed .headline font
    - Add subtitles to inactive profiles
    - Use padding rather than fixed row height

CAVEATS:

- Do not preselect active profile on iPad launch, as doing so
seems to present two ProfileView on top of each other, one from
MainView and one from the NavigationLink.

- Do not touch .listStyle() of master view, as it seems to break
navigation esp. in iPad multitasking.
2022-04-29 19:29:47 +02:00
Davide De Rosa 4d13d8bf6b Do not observe AppManager, just use for migrations 2022-04-29 18:58:07 +02:00
Davide De Rosa 2c2e794b00 Revert async loadCurrentProfile()
Make action sync, but internally async (makeProfileReady). If not
doing so, UI on launch will not be able to show active profile
immediately. WelcomeView would appear for a moment.

Observe isReloadingCurrentProfile.

See 2b1efb8fec
2022-04-28 19:00:36 +02:00
Davide De Rosa 03cb05da7e Do not disable providers while updating index 2022-04-27 23:08:46 +02:00
Davide De Rosa 2aa4008a08 Animate profile removal
Could only notice difference on iPad.
2022-04-27 18:32:44 +02:00
Davide De Rosa d4484f3307 Simplify layout of in-app products 2022-04-27 18:32:44 +02:00
Davide De Rosa 2b1efb8fec Make load*Profile() async
- Handle Task in consumers

- Drop makeReady, always make loaded profile ready

- Rename misleading loadProfile() to profileEx()
2022-04-27 17:13:03 +02:00
Davide De Rosa 02b2e3194e Add duplicate to profile menu
Contextually switch current profile to duplicate.
2022-04-27 16:59:33 +02:00
Davide De Rosa 496abc6c89 Move Siri on top of menu 2022-04-27 16:54:07 +02:00
Davide De Rosa 49a1f1b55c Address VPN toggle losing sync with internal state
- Update TunnelKit

- Receive TunnelKit notifications on main queue

- Bind VPN toggle to VPNManager directly (implicit animations)

- Update state on VPN didFail

- Set isEnabled = false after uninstalling VPN (not notified)
2022-04-27 15:53:31 +02:00
Davide De Rosa cd854f8ebf Group profile actions into menus
- Organizer
    - Duplicate

- Profile
    - Rename
    - Siri
    - Uninstall (+ confirmation)
    - Delete (+ confirmation)
2022-04-27 09:53:42 +02:00
Davide De Rosa 1c047b9ce2 Retain profile name (disabled) after importing
Works around a crash in iPadOS 14 portrait when removing section
containing first responder (profile name TextField). It happened
when submitting profile name via keyboard rather than "Save".
2022-04-26 22:56:41 +02:00
Davide De Rosa 4a0245d757 Rename AddHostView to .NameView
In preparation of future additions to flow.
2022-04-26 22:44:34 +02:00
Davide De Rosa 03fdab4833 Duplicate profile from context menu 2022-04-26 22:39:47 +02:00
Davide De Rosa 1ea380312a Update providers index on add provider appearance 2022-04-26 22:15:39 +02:00
Davide De Rosa 4b8cff1bb3 Disable padding around LongContentView
It should actually be an inset. Do it later.
2022-04-26 21:39:21 +02:00
Davide De Rosa 99e48119f7 Encapsulate calculation of former products
Use an interface (BuildProducts) that makes understandable and
easily extensibile how some in-app products are inferred by build
number.
2022-04-26 20:55:18 +02:00
Davide De Rosa f4714dec58 Fix VPN toggle enabling despite errors 2022-04-26 19:02:12 +02:00
Davide De Rosa 4973a19fda Drop unused method 2022-04-26 10:59:48 +02:00
Davide De Rosa 1ff19b331f Move VPNToggle to standalone view 2022-04-26 10:40:46 +02:00
Davide De Rosa ccde6a30cf Fix issues with VPN toggle
- Move rate limit to UI only

- Keep caption constant to "Enabled"
2022-04-25 23:12:45 +02:00
Davide De Rosa 58cf401883 Share prefix for validating theme methods 2022-04-25 22:44:24 +02:00
Davide De Rosa 5c0e053e7d Review requirements of DNS over TLS (DoT)
- Make DNS servers optional in TunnelKit

- Allow IP address as DoT server name
2022-04-25 22:40:09 +02:00
Davide De Rosa efb9760d6b Redo VPN toggle properly
- Use local @State for appearance

- On binding set, control VPNManager
2022-04-25 16:36:07 +02:00
Davide De Rosa 6434008ebd Make destructive buttons standalone
- Uninstall VPN

- Remove profile (add to ProfileView)

Create DestructiveButton with iOS 15 .role when available.
2022-04-25 16:34:22 +02:00
Davide De Rosa ac1239daa8 Add headers to active/inactive profile sections
Hide inactive section if empty.
2022-04-25 16:34:13 +02:00
Davide De Rosa 29629c5147 Use lighter font for non-active profiles 2022-04-25 15:35:21 +02:00
Davide De Rosa 84790080be Disable autocorrection on profile name 2022-04-25 15:28:55 +02:00
Davide De Rosa 886d0271ea Restore 'Add' button in NetworkSettings
Makes it clear that added fields must be submitted in order to
be saved.
2022-04-23 15:47:02 +02:00
Davide De Rosa 0b1e465143 Share animation type in theme 2022-04-23 12:11:01 +02:00
Davide De Rosa 7eb2b3bd0e Drop button accent on Organizer rows 2022-04-23 11:48:43 +02:00
Davide De Rosa 6aee88e69a Refactor theme styles
- Hide colors behind styles

- Add "Style" suffix
2022-04-23 11:48:43 +02:00
Davide De Rosa dc66f514d9 Restore presentation conditions of active profile
On iPad it's already loaded in MainView().
2022-04-23 10:25:31 +02:00
Davide De Rosa c507c739bd Move WelcomeView to its own view 2022-04-23 10:25:31 +02:00
Davide De Rosa ad1539023e Split VPN status and data count 2022-04-23 10:25:31 +02:00
Davide De Rosa 1083941eeb Increase font size in Organizer 2022-04-23 10:25:31 +02:00
Davide De Rosa 4037b983cb Move active profile on top to its own section 2022-04-23 10:25:31 +02:00
Davide De Rosa b37ff03e4b Refactor hidden navlinks and send behind in ZStack 2022-04-23 10:25:31 +02:00
Davide De Rosa 2432f0d97a Rewrite ProfileView as a view of currentProfile
Do not load profile in View, instead:

- Load active profile on app launch

- Load selected profile on organizer selection
2022-04-23 10:25:31 +02:00
Davide De Rosa 8838e9d130 Strip a few unnecessary publishers
- Drop unused AppManager from OrganizerView

- Do not notify ProfileManager subscribers on activeProfileId

Saved active profile is already notified by:

- Core Data
- AppManager
2022-04-23 10:25:31 +02:00
Davide De Rosa d8e47cb7c0 Refactor strings and add new ones
- Move Localizable.strings above to share *.lproj folders

- Reorg menus into contextual/system

- Shorten titles of contextual menus

- Update sharing message with WireGuard

- Drop AlternativeTo

7 phrases left to translate into 9 languages.
2022-04-22 13:12:42 +02:00
Davide De Rosa 322bdf2993 Serialize active profile immediately
Otherwise:

- Switch from former active profile A to B
- Connect to now active profile B
- Kill app
- Reopen app
- App shows connected to profile A

Because active profile was not saved immediately on switch.

Unnecessary now to also save it on background persist().
2022-04-22 10:05:28 +02:00
Davide De Rosa 7095791428 Extend styles for VPN status description 2022-04-22 09:57:13 +02:00
Davide De Rosa 867b415b6b Fix double add menu in Organizer
Seems to happen when launching with active profile.

Use explicit position.
2022-04-22 09:52:10 +02:00
Davide De Rosa c9dfed676e Move VPN status below active profile
Rather than on the side. Similar to old subtitle table view cell.

Restore data count as well (when available).
2022-04-22 09:52:10 +02:00
Davide De Rosa 46050e0141 Refactor ProfileView a little bit
- Make welcome a computed property

- Reuse first header for consistency when loading

- Convert isDeleted to better isExisting (inverted)
2022-04-21 19:11:22 +02:00
Davide De Rosa fd7c232ecc Unroll ProfileView toolbar items
Also leave them visible when disabled.
2022-04-21 19:03:14 +02:00
Davide De Rosa 992178bcd6 Move toolbar content inline
For consistency, can search with "toolbar {".
2022-04-21 16:24:08 +02:00