Post

Replies

Boosts

Views

Activity

How to move the Gauge Indicator with Animation
I wanted to make a Gauge View to display the angle Moved below is the image and the needle give the angle according to the input is given ,but I need to change the direction of the needle with some animation as of now its just moving like a glitch below is my code import SwiftUI struct RudderView: View {     @State var ArrowValue: CGFloat = -100     let AngleTimer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()     var body: some View {         NavigationView {             ZStack{                     Circle()                         .stroke(.gray.opacity(0.1),lineWidth: 25)                     Circle()                         .trim(from: 0,to: 0.75)                         .stroke(Gradient(colors: [.red,.white,.green]), style: StrokeStyle(lineWidth: 25,lineCap: .round,lineJoin: .round))                         .rotationEffect(Angle(degrees: -225))                                   ZStack {                         RoundedRectangle(cornerRadius: 20)                             .foregroundColor(.white)                             .frame(width: 25, height: 150)                     }                     .offset(x:0, y: -50)                     .rotationEffect(Angle(degrees: ArrowValue))                     .onReceive(AngleTimer) { _ in                         withAnimation {                                                              }                         }                     }                     Text("40")                         .font(.largeTitle)                         .fontWeight(.thin)                         .foregroundColor(.white)                         .offset(x:100, y:170)                     Text("-40")                         .font(.largeTitle)                         .fontWeight(.thin)                         .foregroundColor(.white)                         .offset(x:-100, y:170)             }             .padding()         }                      }             } struct RudderView_Previews: PreviewProvider {     static var previews: some View {         RudderView()             .preferredColorScheme(.dark)     }]w } can anyone say what to type in the animation bracket to move my needle smoothly according to the changes of input for arrow
0
0
1.3k
Mar ’23
I need to create Swift Charts using Sensor data
I have created Swift Charts using Ready Made Data Like below static let last12Months = [ (month: date(year: 2022, month: 6), KW: 3952, dailyAverage: 127, dailyMin: 95, dailyMax: 345), (month: date(year: 2022, month: 7), KW: 8322, dailyAverage: 124, dailyMin: 55, dailyMax: 255), (month: date(year: 2022, month: 8), KW: 2952, dailyAverage: 245, dailyMin: 99, dailyMax: 673), (month: date(year: 2022, month: 9), KW: 3352, dailyAverage: 875, dailyMin: 92, dailyMax: 623), (month: date(year: 2022, month: 10), KW: 3252, dailyAverage: 257,dailyMin: 55, dailyMax: 675), (month: date(year: 2022, month: 11), KW: 3232, dailyAverage: 537,dailyMin: 65, dailyMax: 643), (month: date(year: 2022, month: 12), KW: 9871, dailyAverage: 253,dailyMin: 25, dailyMax: 987), (month: date(year: 2023, month: 1), KW: 8623, dailyAverage: 235, dailyMin: 96, dailyMax: 353), (month: date(year: 2023, month: 2), KW: 7612, dailyAverage: 276, dailyMin: 64, dailyMax: 765), (month: date(year: 2023, month: 3), KW: 2335, dailyAverage: 978, dailyMin: 36, dailyMax: 456), (month: date(year: 2023, month: 4), KW: 9087, dailyAverage: 667, dailyMin: 63, dailyMax: 675), (month: date(year: 2023, month: 5), KW: 2823, dailyAverage: 865, dailyMin: 100, dailyMax: 765), (month: date(year: 2023, month: 6), KW: 9762, dailyAverage: 544, dailyMin: 36, dailyMax: 999), ] `but now I want to create same charts with real world reading like Health App. For example aim taking the sensor value through bluetooth, I can show the reading from sensor to app but how can I store the data for months and show them in Charts Any Ideas where am I lagging`
0
0
713
Jun ’23
Build Error due o info.plist
this is the error I'm getting building the project Build input file cannot be found: '/Users/nsame/Desktop/Xcode Files/Login FireBase/Login FireBase/Login FireBase/Info.plist'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? what does it means I have already gone through several forms before posting it can anyone say what should I do
1
0
7.5k
Oct ’22
I want to use HKStatisticsQuery to read the Active Energy Burned from HealthKit
I have requested the access from the HealthKit by below code let calorieCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.activeEnergyBurned)! and it working perfectly but not able to read the data using Query after reading the documentation I have found out HKStatisticsQuery is used for Query     func CaloriesBurned() {         let activeEnergy = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!         let startDate = Calendar.current.date(byAdding: .day,value: -7, to: Date())         let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)         let query = HKStatisticsQuery(quantityType: activeEnergy, quantitySamplePredicate: predicate,completionHandler: <#T##(HKStatisticsQuery, HKStatistics?, Error?) -> Void#>))     } but I don't understand what should be written in completion handler in above code to read the active Energy Burned I have read already documentation if anyone has sample code to read energy burned or sample code on how to use HKStatisticsQuery
1
0
1k
Jan ’23
I need to read multiple Queries of HKStatisticsCollectionQuery Like StepCount and Swimming Stroke
This is the the func for Authorisation from health App func stepCount(completion: @escaping (Bool) -> Void){ if HKHealthStore.isHealthDataAvailable(){ let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!  let swimmingStrokeCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.swimmingStrokeCount)!   guard let healthStore = self.healthStore else { return completion(false) }   healthStore.requestAuthorization(toShare: [], read: [swimmingStrokeCount,stepCount]) { (success, error) in completion(success)             }   }     } and then Im not able to read both step count and swimming Stroke at the the same query func readData(completion: @escaping (HKStatisticsCollection?)-> Void){         let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!         let swimmmingStrokeCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.swimmingStrokeCount)!         let startDate = Calendar.current.date(byAdding: .day,value: -7, to: Date())         let anchorDate = Date.monday12AM()         let daily = DateComponents(day : 1)         let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)         query = HKStatisticsCollectionQuery(quantityType: stepCount, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily)         query1 = HKStatisticsCollectionQuery(quantityType: swimmmingStrokeCount, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily)         query!.initialResultsHandler = { query, statisticsCollection, error in             completion(statisticsCollection)         } if let healthStore = healthStore, let query = self.query {             healthStore.execute(query)         }     } is there any possible way to call both query and query1 as a single query also I have tried to call them entirely separate as two different queries but that too is not working as expected it results becomes sum of step count and swimming stroke can anyone clear my doubt?
1
0
1k
Mar ’23
problem with ForEach loop
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()
2
0
1.2k
Aug ’22
Value of type ' Module<Wallet_App>' has no subscript please check the below code
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)")     } }
2
0
725
Aug ’22
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value .... what im I doing wrong
//  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() {                      }          }
2
0
1.3k
Nov ’22