I have the same issue on my MacOS. I try to compile the code and the preview gives an error.
Post
Replies
Boosts
Views
Activity
Thank you for your answers.
How do I #define AdvancedSettingsView in my code ?
My issue is the following : "I want to program a function and I receive a 'scope' error". How do I declare a scope and were in my programming code to allow the variable to function in accordance with the iOS Mobile App that I want to develop these year ?
There is not other method to declare the scope beside creating a new SwiftUI view file ?
Kind Regards
HexagonParamaters.swift
//
// HexagonParameters.swift
// Landmarks
//
// Created by Besleaga Alexandru Marian on 5/11/21.
//
import Foundation
import CoreGraphics
struct HexagonParamaters{
struct Segment {
let line: CGPoint
let curve: CGPoint
let control: CGPoint
}
static let adjustment: CGFloat = 0.085
static let segments = [
Segment(
line: CGPoint(x: 0.60, y: 0.05),
curve: CGPoint(x: 0.40, y: 0.05),
control: CGPoint(x: 0.50, y: 0.00)
),
Segment(
line: CGPoint(x: 0.05, y: 0.20),
curve: CGPoint(x: 0.00, y: 0.30),
control: CGPoint(x: 0.00, y: 0.25)
),
Segment(
line: CGPoint(x: 0.00, y: 0.70),
curve: CGPoint(x: 0.05, y: 0.80),
control: CGPoint(x: 0.00, y: 0.75)
),
Segment(
line: CGPoint(x: 0.40, y: 0.95),
curve: CGPoint(x: 0.60, y: 0.95),
control: CGPoint(x: 0.50, y: 1.00)
),
Segment(
line: CGPoint(x: 0.95, y: 0.80),
curve: CGPoint(x: 1.00, y: 0.70),
control: CGPoint(x: 1.00, y: 0.75)
),
Segment(
line: CGPoint(x: 1.00, y: 0.30),
curve: CGPoint(x: 0.95, y: 0.20),
control: CGPoint(x: 1.00, y: 0.25)
)
]
}
BadgeBackground.swift
//
// BadgeBackground.swift
// Landmarks
//
// Created by Besleaga Alexandru Marian on 5/11/21.
//
import SwiftUI
struct BadgeBackground: View {
var body: some View {
Path { path in
var width: CGFloat = 100.0
let height = width
path.move(
to: CGPoint(
x: width * 0.95,
y: height * (0.20 + HexagonParameters.adjustment)
)
)
HexagonParameters.segments.forEach { segment in
path.addLine(
to: CGPoint(
x: width * segment.line.x,
y: height * segment.line.y
)
)
path.addQuadCurve(
to: CGPoint(
x: width * segment.curve.x,
y: height * segment.curve.y
),
control: CGPoint(
x: width * segment.control.x,
y: height * segment.control.y
)
)
}
}
.fill(Color.black)
}
}
struct BadgeBackground_Previews: PreviewProvider {
static var previews: some View {
BadgeBackground()
}
}
Cannot find 'HexagonParameters' in scope
What should I do ?
//
// BadgeBackground.swift
// Landmarks
//
// Created by Besleaga Alexandru Marian on 5/11/21.
//
import SwiftUI
struct BadgeBackground: View {
var body: some View {
Path { path in
var width: CGFloat = 100.0
let height = width
path.move(
to: CGPoint(
x: width * 0.95,
y: height * 0.20
)
)
HexagonParameters.segments.forEach { segment in
path.addLine(
to: CGPoint(
x: width * segment.line.x,
y: height * segment.line.y
)
)
}
}
.fill(Color.black)
}
}
struct BadgeBackground_Previews: PreviewProvider {
static var previews: some View {
BadgeBackground()
}
}
And I receive the following error "Cannot find 'HexagonParameters' in scope"
How do I code the the scope for HexagonParameters ?
I will learn to code it myself and if I will obtain a negative result, I will learn with your example.
Kind Regards
I have just finish reading your examples and I know that they are right.
I want to add a Button in my tutorial with a screen touch to see if the mobile device recognizes the touch for the button and receive a scope 'declare' error from the complier.
Do you have time to give me a example of a button with a declared scope ?
Kind Regards
Thank you for your answer "msjg".