|
| 1 | +// The MIT License (MIT) |
| 2 | +// |
| 3 | +// Copyright (C) 2024-2025 Tommy van der Vorst |
| 4 | +// Copyright (C) 2026 The syncthing-macos Authors. All rights reserved. |
| 5 | +// |
| 6 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +// of this software and associated documentation files (the "Software"), to deal |
| 8 | +// in the Software without restriction, including without limitation the rights |
| 9 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +// copies of the Software, and to permit persons to whom the Software is |
| 11 | +// furnished to do so, subject to the following conditions: |
| 12 | + |
| 13 | +// The above copyright notice and this permission notice shall be included in all |
| 14 | +// copies or substantial portions of the Software. |
| 15 | + |
| 16 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +// SOFTWARE. |
| 23 | +import Foundation |
| 24 | +import SwiftUI |
| 25 | + |
| 26 | +struct FeatureView: View { |
| 27 | + var image: String |
| 28 | + var title: String |
| 29 | + var description: String |
| 30 | + |
| 31 | + var body: some View { |
| 32 | + HStack(alignment: .top, spacing: 15) { |
| 33 | + Image(systemName: image).foregroundColor(.accentColor) |
| 34 | + .font(.system(size: 38, weight: .light)) |
| 35 | + VStack(alignment: .leading, spacing: 5) { |
| 36 | + Text(self.title).bold() |
| 37 | + Text(self.description) |
| 38 | + Spacer() |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +struct OnboardingView: View { |
| 45 | + @Environment(\.dismiss) private var dismiss |
| 46 | + |
| 47 | + var body: some View { |
| 48 | + ScrollView(.vertical) { |
| 49 | + VStack(alignment: .leading, spacing: 20) { |
| 50 | + self.title |
| 51 | + |
| 52 | + HStack(alignment: .center) { |
| 53 | + Text("Synchronize your files securely with your other devices.") |
| 54 | + .bold() |
| 55 | + .multilineTextAlignment(.leading) |
| 56 | + .fixedSize(horizontal: false, vertical: true) |
| 57 | + }.frame( |
| 58 | + minWidth: 0, |
| 59 | + minHeight: 0, |
| 60 | + maxHeight: .infinity, |
| 61 | + alignment: .topLeading |
| 62 | + ) |
| 63 | + |
| 64 | + Text("Before we start, we need to go over a few things:").multilineTextAlignment( |
| 65 | + .leading) |
| 66 | + |
| 67 | + FeatureView( |
| 68 | + image: "bolt.horizontal.circle", |
| 69 | + title: String(localized: "Synchronization is not back-up"), |
| 70 | + description: String( |
| 71 | + localized: |
| 72 | + "When you synchronize files, all changes, including deleting files, also happen on your other devices. Do not use Syncthing for back-up purposes, and always keep a back-up of your data." |
| 73 | + )) |
| 74 | + |
| 75 | + FeatureView( |
| 76 | + image: "hand.raised.circle", |
| 77 | + title: String(localized: "Your devices, your data, your responsibility"), |
| 78 | + description: String( |
| 79 | + localized: |
| 80 | + "You decide with which devices you share which files. Syncthing is a selfhosted secure Peer-to-peer app without a central server or cloud service. This also means the app makers cannot help you access or recover any lost files." |
| 81 | + ) |
| 82 | + ) |
| 83 | + |
| 84 | + FeatureView( |
| 85 | + image: "gear.circle", |
| 86 | + title: String(localized: "Powered by Syncthing"), |
| 87 | + description: String( |
| 88 | + localized: |
| 89 | + "This app is powered by the official Open source Syncthing." |
| 90 | + ) |
| 91 | + ) |
| 92 | + |
| 93 | + self.footer.padding(.bottom).padding(10) |
| 94 | + |
| 95 | + }.padding(.all).padding(20) |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + var title: some View { |
| 100 | + Text( |
| 101 | + "Welcome to Syncthing for macOS!" |
| 102 | + ) |
| 103 | + .font(.largeTitle.bold()) |
| 104 | + .multilineTextAlignment(.center) |
| 105 | + } |
| 106 | + |
| 107 | + var footer: some View { |
| 108 | + Color.blue |
| 109 | + .frame( |
| 110 | + minHeight: 48, maxHeight: .infinity |
| 111 | + ) |
| 112 | + .cornerRadius(9.0) |
| 113 | + .overlay(alignment: .center) { |
| 114 | + Text("I understand, let's get started!").bold().foregroundColor(.white) |
| 115 | + }.onTapGesture { |
| 116 | + self.dismiss() |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +#Preview { |
| 122 | + OnboardingView() |
| 123 | +} |
0 commit comments