Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes and optimisations to onboarding message and others. #12

Merged
merged 9 commits into from
Feb 9, 2024
6 changes: 3 additions & 3 deletions Mythic/Views/Navigation/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct HomeView: View {
}
}
.background(.background)
.cornerRadius(20)
.cornerRadius(10)

// MARK: - Side Views
VStack {
Expand All @@ -179,7 +179,7 @@ struct HomeView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.background)
.cornerRadius(20)
.cornerRadius(10)

// MARK: View 2 (Bottom)
VStack {
Expand All @@ -188,7 +188,7 @@ struct HomeView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.background)
.cornerRadius(20)
.cornerRadius(10)
}
}
.navigationTitle("Home")
Expand Down
42 changes: 38 additions & 4 deletions Mythic/Views/Sheets/Onboarding/Onboarding.swift
Copy link
Member

Choose a reason for hiding this comment

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

Good implementation, but it would be ideal to move the NSColor extension to a separate file in Mythic/Extensions

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
import SwiftUI
import Combine

// Add hex support for gradient overlay for "Mythic" text.
extension NSColor {
convenience init?(hex: String) {
var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")

var rgb: UInt64 = 0

guard Scanner(string: hexSanitized).scanHexInt64(&rgb) else { return nil }

let red = CGFloat((rgb & 0xFF0000) >> 16) / 255.0
let green = CGFloat((rgb & 0x00FF00) >> 8) / 255.0
let blue = CGFloat(rgb & 0x0000FF) / 255.0

self.init(srgbRed: red, green: green, blue: blue, alpha: 1.0)
}
}

// MARK: - OnboardingView Struct
/// A view providing onboarding experience for first-time users.
struct OnboardingView: View {
Expand All @@ -27,12 +45,15 @@ struct OnboardingView: View {
// MARK: - State Variables
@State private var isAuthViewPresented = false
@State private var authSuccessful: Bool?

// MARK: - Body
var body: some View {
VStack {
Text("Welcome to Mythic!")
Text("Welcome to ")
.font(.title)

Text("Mythic!")
.font(.title)
.overlay(gradientOverlay)

Divider()

Expand Down Expand Up @@ -67,7 +88,7 @@ struct OnboardingView: View {
isPresented = false
isInstallViewPresented = true
}
.buttonStyle(.borderedProminent)
.buttonStyle(.bordered)
}
}
.padding()
Expand All @@ -78,10 +99,23 @@ struct OnboardingView: View {
AuthView(isPresented: $isAuthViewPresented, authSuccessful: $authSuccessful)
}
}

// MARK: - Gradient Overlay
var gradientOverlay: some View {
LinearGradient(
gradient: Gradient(colors: [
Color(NSColor(hex: "#7e0cef")!),
Color(NSColor(hex: "#8b01dda")!)
]),
startPoint: .leading,
endPoint: .trailing
)
.mask(Text("Mythic!").font(.title))
}
}

// MARK: - Preview
#Preview {
#Preview {
OnboardingView(
isPresented: .constant(true),
isInstallViewPresented: .constant(false)
Expand Down