Button(action:
CardView() //here it show an error how to add the CardView Swift ui file in this button //
) {
Image(systemName: "creditcard")
.resizable()
.foregroundColor(Color("Icon Color"))
.frame(width:24, height: 24)
}
.padding(.top, 825.0)
.padding(.trailing, 125.0)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
im getting this error after this code, what module should Iimport here? or does it causes any other problem?
// ContentView.swift
// Widget_and_LiveActivities
//
// Created by Makwin Santhosh K on 20/11/22.
//
import SwiftUI
import ClockKit
struct ContentView: View {
var body: some View {
var future = Calendar.current.date(byAdding: .minute, value: (Int(minutes) ?? 0), to: Date())! // here is where im getting (cannot find 'minutes' in the scope)
future = Calendar.current.date(byAdding: .second, value: (Int(seconds) ?? 0), to: future)! // also where is where im getting (cannot find 'seconds' in the scope)
let date = Date.now...future
let updatedDeliveryStatus = PizzaDeliveryAttributes.PizzaDeliveryStatus(driverName: "Anne Johnson", deliveryTimer: date)
let alertConfiguration = AlertConfiguration(title: "Delivery Update", body: "Your pizza order will arrive in 25 minutes.", sound: .default)
await deliveryActivity?.update(using: updatedDeliveryStatus, alertConfiguration: alertConfiguration)
let initialContentState = PizzaDeliveryAttributes.ContentState(driverName: "Bill James", deliveryTimer:date)
let activityAttributes = PizzaDeliveryAttributes(numberOfPizzas: 3, totalAmount: "$42.00", orderNumber: "12345")
do {
deliveryActivity = try Activity.request(attributes: activityAttributes, contentState: initialContentState)
print("Requested a pizza delivery Live Activity \(String(describing: deliveryActivity?.id)).")
} catch (let error) {
print("Error requesting pizza delivery Live Activity \(error.localizedDescription).")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
// this is the example code from
[https://developer.apple.com/documentation/activitykit/displaying-live-data-with-live-activities)
this is my code I need my toolBar buttons to navigate to other SwiftUi views
what should I write in button action { } to open the other SwiftUi View
// SwiftLoginView.swift
// Login FireBase
//
// Created by Makwin Santhosh K on 08/11/22.
//
import SwiftUI
import MapKit
import CoreLocationUI
struct OverallView: View {
var body: some View{
NavigationView {
ZStack{
ToolBarShape()
.frame(width: 400,height: 110)
.foregroundColor(.white)
.shadow(radius: 6)
.offset(x : 0, y: 410)
.toolbar {
ToolbarItemGroup(placement: .bottomBar){
//MARK: Button Home
Button(action :{
}, label:{
VStack {
Image(systemName: "house")
Text("Home")
}
.font(.footnote)
.foregroundColor(.black)
})
Spacer()
//MARK: Button Money
Button(action :{
},label:{
VStack {
Image(systemName: "dollarsign")
Text("Money")
}
.font(.footnote)
.foregroundColor(.black)
})
Spacer()
//MARK: Button Home
Button(action :{
},label:{
VStack {
Image(systemName: "person")
Text("Help")
}
.font(.footnote)
.foregroundColor(.black)
})
//MARK: Button Home
Spacer()
Button(action :{
},label:{
VStack {
Image(systemName: "menubar.rectangle")
Text("More")
}
.font(.footnote)
.foregroundColor(.black)
})
}
}
}
}
}
}
struct MapUView: View {
@StateObject public var ViewModel = ContentViewModal()
var body: some View {
ZStack(alignment: .bottom) {
AreaMap(region: $ViewModel.region)
LocationButton(.currentLocation){
ViewModel.requestUserLocationForOnce()
}
.foregroundColor(.white)
.cornerRadius(8)
}
}
struct AreaMap: View {
@Binding var region: MKCoordinateRegion
var body: some View {
let binding = Binding(
get: { self.region },
set: { newValue in
DispatchQueue.main.async {
self.region = newValue
}
}
)
return Map(coordinateRegion: binding, showsUserLocation: true)
.ignoresSafeArea()
}
}
final class ContenViewModal: NSObject, ObservableObject, CLLocationManagerDelegate{
@Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 20, longitude: 90), span: MKCoordinateSpan(latitudeDelta: 100, longitudeDelta: 100))
let locationManager = CLLocationManager()
override init() {
super.init()
locationManager.delegate = self
}
func requestUserLocationForOnce() {
locationManager.requestLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let latestLocation = locations.first else {
//show error
return
}
self.region = MKCoordinateRegion(center: latestLocation.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
}
}
}
struct OverallView_Previews: PreviewProvider {
static var previews: some View {
OverallView()
}
}
Im building the small Map View by accessing the Users Location From the App
Im getting this Error in Xcode 14 in Purple Color
there is no error in this Code side it shows only while running in this simulator
also according to the error My Location is not updating to it
Can any 1 say where am I going wrong
below is my code
// MapUIView.swift
// Login_Via_SwiftUI
//
// Created by Makwin Santhosh K on 10/11/22.
//
import SwiftUI
import MapKit
import CoreLocationUI
struct MapUIView: View {
@StateObject private var ViewModel = ContentViewModal()
var body: some View {
ZStack(alignment: .bottom) {
Map(coordinateRegion: $ViewModel.region, showsUserLocation: true)
.ignoresSafeArea()
LocationButton(.currentLocation){
ViewModel.requestUserLocationForOnce()
}
.foregroundColor(.white)
.cornerRadius(8)
.padding()
}
}
}
struct MapUIView_Previews: PreviewProvider {
static var previews: some View {
MapUIView()
}
}
final class ContentViewModal: NSObject, ObservableObject, CLLocationManagerDelegate{
@Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 40, longitude: 120), span: MKCoordinateSpan(latitudeDelta: 100, longitudeDelta: 100))
let locationManager = CLLocationManager()
override init() {
super.init()
locationManager.delegate = self
}
func requestUserLocationForOnce() {
locationManager.requestLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let latestLocation = locations.first else{
//show error
return
}
DispatchQueue.main.async {
self.region = MKCoordinateRegion(center: latestLocation.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
}
}
Is there any online tool to convert the images to json file for annotation from image exceptionally made for ML app
import Foundation
enum VideoDetails: String, CaseIterable{
case Nature , Food , Animals , Travel
}
struct ResponseBody: Decodable {
var page: Int
var perPage: Int
var totalResults: Int
var url: String
var videos: [Video]
}
struct Video: Identifiable, Decodable{
var id: Int
var image: String
var duration: Int
var user: User
var videofiles: [VideoFile]
struct User: Identifiable, Decodable {
var id: Int
var name: String
var url: String
}
struct VideoFile: Identifiable, Decodable {
var id: Int
var quality: String
var fileType: String
var link: String
}
}
//this one doesn't work but the below code works perfectly can anyone why it is happening
import Foundation
enum VideoDetails: String, CaseIterable{
case Nature , Food , Animals , Travel
}
struct Video: Identifiable, Decodable {
var id: Int
var image: String
var duration: Int
var user: User
var videoFiles: [VideoFile]
struct User: Identifiable, Decodable {
var id: Int
var name: String
var url: String
}
struct VideoFile: Identifiable, Decodable {
var id: Int
var quality: String
var fileType: String
var link: String
}
}
import SwiftUI
struct ButtonUI: View {
var body: some View {
ZStack {
Color.white
RoundedRectangle(cornerRadius: 50)
.fill(.blue)
.frame(width: 250, height: 75, alignment: .center)
Text("Enable Location")
.font(.title3)
.fontWeight(.bold)
.foregroundColor(Color.white)
}
.offset(x: 0, y: 300)
}
}
struct ButtonUI_Previews: PreviewProvider {
static var previews: some View {
ButtonUI()
}
}
// I have used this code to create a button like shape in Xcode how to do i make it work like open the location settings in iPhone
// it should work like a button to open the location settings in iPhone
I have to added the background image and background colour in launch screen
but for user experience i need to add the loading animation in launch screen,
I also used the Activity indicator View but it is not moving (not showing animation)
is there is any way to add LottieView or Rive Animation in Launch Screen
below is my code of reading data from HealthKit for Multiple Data
but for reading Multiple data using Set()
it shows
"Cannot convert value of type 'Set' to expected argument type 'HKQuantityType' "
func readData(completion: @escaping (HKStatisticsCollection?)-> Void){
let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!
let MoveCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.appleMoveTime)!
let DistanceCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.distanceWalkingRunning)!
let Activitysummary = Set([stepCount,MoveCount,DistanceCount])
let startDate = Calendar.current.date(byAdding: .day, value: -7, to: Date())
//MARK: here we setting our start time at 12.00 AM
let anchorDate = Date.monday12AM()
//MARK: we going to calculate the value for each day
let daily = DateComponents(day : 1)
let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)
//MARK: .cummulativesum -> iPhone and Apple Watch Difference
query = HKStatisticsCollectionQuery(quantityType: Activitysummary, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily)
//MARK: here in ActivitySummary it show the error
query!.initialResultsHandler = { query,statisticsCollection, error in
completion(statisticsCollection)
}
if let healthStore = healthStore, let query = self.query{
healthStore.execute(query)
}
}
when I'm using for each loop(using repeat command) instead of printing 5 items it is printing 10 times, it always doubles my command
it is my code
NavigationView {
ScrollView {
ScrollView(.horizontal , showsIndicators: false){
HStack(spacing: -10){
ForEach(0..<5) { item in
NavigationLink(destination: DetailView()) {
CardView()
CardView()
import SwiftUI
struct List_View: View {
var Wallet : Wallet_Data
var body: some View {
ZStack {
ListRectShape()
.fill(Color.background)
.frame(width: 368, height: 75)
Wallet.image
.padding(.trailing, 280.0)
Text("Amazon")
.font(.title3)
.fontWeight(.light)
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.padding(.top, -25.0)
.padding(.trailing, 125.0)
Text("Augest 10 2022")
.font(.body)
.fontWeight(.light)
.foregroundColor(Color.white)
.padding(.trailing, 78.0)
.padding(.top, 21.0)
ListRectShape()
.fill(Color.background)
.frame(width: 83, height: 33)
.border(Color.white)
.padding(.leading, 225.0)
Text("$109.08")
.foregroundColor(Color.white)
.padding(.leading, 225.0)
}
ZStack {
ListRectShape()
.fill(Color.background)
.frame(width: 368, height: 75)
Image("Apple WC")
.padding(.trailing, 280.0)
Text("Apple")
.font(.title3)
.fontWeight(.light)
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.padding(.top, -22.0)
.padding(.trailing, 145.0)
Text("Augest 10 2022")
.font(.body)
.fontWeight(.light)
.foregroundColor(Color.white)
.padding(.trailing, 78.0)
.padding(.top, 21.0)
ListRectShape()
.fill(Color.background)
.frame(width: 83, height: 33)
.border(Color.white)
.padding(.leading, 225.0)
Text("$1000.00")
.foregroundColor(Color.white)
.padding(.leading, 225.0)
}
}
}
struct List_View_Previews: PreviewProvider {
static var previews: some View {
List_View(Wallet: Wallet_App[0]) // here is were I'm getting an error
}
}
//this is my ModelData were I'm trying to load my json file
import Foundation
import Combine
final class ModelData : ObservableObject{
var Wallet_App: [Wallet_Data] = load("Contents.json")
}
func load<T: Decodable>(_ filename: String) -> T {
let data: Data
guard let file = Bundle.main.url(forResource: filename, withExtension: nil)
else {
fatalError("Couldn't find (filename) in main bundle.")
}
do {
data = try Data(contentsOf: file)
} catch {
fatalError("Couldn't load (filename) from main bundle:\n(error)")
}
do {
let decoder = JSONDecoder()
return try decoder.decode(T.self, from: data)
} catch {
fatalError("Couldn't parse (filename) as (T.self):\n(error)")
}
}
I'm trying to add a video in viewController and there is a minor issue. I'm not able view video them in simulator can any one explain how to view viewController in simulator.
when I click the play button it only displays the ContentView
I have just started to learn Storyboard While I was Creating the View Controller,
the Assistant doesn't open up to opens up only for navigation controller.
I have like 2 View Controller, Assistant doesn't showing up for those two of them.
can anyone point out where it I make a mistake.
// OTPViewController.swift
// FinalBookingApp
//
// Created by Makwin Santhosh K on 19/10/22.
//
import UIKit
import FirebaseAuth
import Firebase
import FirebaseCore
class OTPViewController: UIViewController {
@IBOutlet weak var OTPLabel: UILabel!
@IBOutlet weak var EnterOTPLabel: UILabel!
@IBOutlet weak var MailTextField : UITextField!
@IBOutlet weak var PasswordTextField: UITextField!
@IBOutlet weak var EnterOTPTextField: UITextField!
@IBOutlet weak var VerifyButton: UIButton!
@IBOutlet weak var ErrorLabel : UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
// check the data validate Things
func validateFields() -> String?{
if PasswordTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" // // im getting error in this error saying "Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"
{
return "Please enter the password without the BlankSpaces"
}
let cleanedPassword = PasswordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
if Helpers.isPasswordValid(cleanedPassword) == false{
//Password wasn't secure enough
return "Please make sure your password is at least 8 characters, contains a special character and a number."
}
return nil
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
@IBAction func ButtonTapped(_ sender: Any) {
let error = validateFields()
if error != nil {
// There's something wrong with the fields, show error message
showError(error!)
}
else {
let Email = MailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let Password = PasswordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
//MARK: Create a User
Auth.auth().createUser(withEmail: Email, password: Password){(result,err) in
if err != nil {
// There was an error creating the user
self.showError("Error creating user")
}
else {
let db = Firestore.firestore()
db.collection("Users").addDocument(data: ["mail" : Email, "uid" : result!.user.uid])
}
}
self.TransistiontoHome()
}
}
func showError(_ message : String){
ErrorLabel.text = message
ErrorLabel.alpha = 1
}
func TransistiontoHome() {
}
}
this is not an code related doubt
I have 2 two storyboard which is connected to each other say like LoginView and SignUpView in storyBoard
and then I have create the HomeView in SwiftUI File How do I tell the Xcode to run the SwiftUI File after the LoginView.StoryBoard