- Implemented clicks for all home interactions. FM and webseries will hold posted

This commit is contained in:
2024-08-07 20:21:47 +05:30
parent f3a62cee63
commit 0348f07230
23 changed files with 661 additions and 241 deletions

View File

@@ -144,6 +144,10 @@
52ACC1252C610CBC00791528 /* UserClicks+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */; };
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */; };
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1292C610EC900791528 /* PersistentStorage.swift */; };
52ACC12D2C63479300791528 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC12B2C63479300791528 /* WOKA.xcdatamodeld */; };
52ACC1302C639DBA00791528 /* MyOrderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC12E2C639DBA00791528 /* MyOrderCell.swift */; };
52ACC1312C639DBA00791528 /* MyOrderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52ACC12F2C639DBA00791528 /* MyOrderCell.xib */; };
52ACC1332C639F3800791528 /* OrderListingDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1322C639F3800791528 /* OrderListingDM.swift */; };
52AECA802C08BCB6004A7579 /* PlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AECA7F2C08BCB6004A7579 /* PlayerVC.swift */; };
52AF71EE2C36AD3100BC5972 /* GamesListVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AF71ED2C36AD3100BC5972 /* GamesListVM.swift */; };
52AF71F02C36B29A00BC5972 /* GamesListDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AF71EF2C36B29A00BC5972 /* GamesListDM.swift */; };
@@ -243,7 +247,6 @@
9C21F81C2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F81B2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift */; };
9C21F81E2C37E3CA0050BFCC /* AVPlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F81D2C37E3CA0050BFCC /* AVPlayerVC.swift */; };
9C21F8222C382A580050BFCC /* AVPlayerVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F8212C382A580050BFCC /* AVPlayerVM.swift */; };
9C23FB772C62085C00F4DC5C /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */; };
9C23FB792C62164600F4DC5C /* URLStaticDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C23FB782C62164600F4DC5C /* URLStaticDM.swift */; };
9C27E1602BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */; };
9C27E1632BDB6F1900EC1DA9 /* AuthFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */; };
@@ -497,6 +500,10 @@
52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataClass.swift"; sourceTree = SOURCE_ROOT; };
52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
52ACC1292C610EC900791528 /* PersistentStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentStorage.swift; sourceTree = "<group>"; };
52ACC12C2C63479300791528 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
52ACC12E2C639DBA00791528 /* MyOrderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyOrderCell.swift; sourceTree = "<group>"; };
52ACC12F2C639DBA00791528 /* MyOrderCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MyOrderCell.xib; sourceTree = "<group>"; };
52ACC1322C639F3800791528 /* OrderListingDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderListingDM.swift; sourceTree = "<group>"; };
52AECA7F2C08BCB6004A7579 /* PlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerVC.swift; sourceTree = "<group>"; };
52AF71ED2C36AD3100BC5972 /* GamesListVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GamesListVM.swift; sourceTree = "<group>"; };
52AF71EF2C36B29A00BC5972 /* GamesListDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GamesListDM.swift; sourceTree = "<group>"; };
@@ -600,7 +607,6 @@
9C21F81B2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KaraokeContinueWatchingDM.swift; sourceTree = "<group>"; };
9C21F81D2C37E3CA0050BFCC /* AVPlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVPlayerVC.swift; sourceTree = "<group>"; };
9C21F8212C382A580050BFCC /* AVPlayerVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVPlayerVM.swift; sourceTree = "<group>"; };
9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
9C23FB782C62164600F4DC5C /* URLStaticDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLStaticDM.swift; sourceTree = "<group>"; };
9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsStruct.swift; sourceTree = "<group>"; };
9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFunc.swift; sourceTree = "<group>"; };
@@ -788,6 +794,7 @@
isa = PBXGroup;
children = (
52BC3BE72C0E04A9002FACA6 /* FaqListDM.swift */,
52ACC1322C639F3800791528 /* OrderListingDM.swift */,
);
path = Model;
sourceTree = "<group>";
@@ -797,6 +804,8 @@
children = (
52BC3BE32C0E0326002FACA6 /* FaqCell.swift */,
52BC3BE42C0E0326002FACA6 /* FaqCell.xib */,
52ACC12E2C639DBA00791528 /* MyOrderCell.swift */,
52ACC12F2C639DBA00791528 /* MyOrderCell.xib */,
);
path = View;
sourceTree = "<group>";
@@ -857,7 +866,7 @@
9C535DC82C00C34000DA6DCD /* Theme */,
52DAC6462C21761700E2F85B /* WebSeries */,
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */,
52ACC12B2C63479300791528 /* WOKA.xcdatamodeld */,
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
);
path = WOKA;
@@ -2039,6 +2048,7 @@
52C8B0712BDA7512003B51D0 /* PassingCloud.json in Resources */,
5255C3FD2C5B67D90030BB22 /* WokaFM.storyboard in Resources */,
9C8C4FB02C1328060017DD3B /* Disclaimer.rtf in Resources */,
52ACC1312C639DBA00791528 /* MyOrderCell.xib in Resources */,
527A2BC62C576EAF0080DF9B /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -2192,7 +2202,6 @@
52D2F3D82C24043D009E52FF /* ShimmerEffectView.swift in Sources */,
9C27E16F2BDB866500EC1DA9 /* CellIdentifier.swift in Sources */,
52BC3BF22C170264002FACA6 /* MoreVM.swift in Sources */,
9C23FB772C62085C00F4DC5C /* WOKA.xcdatamodeld in Sources */,
9CB3D08F2C37D0D60062869D /* KaraokeListingDM.swift in Sources */,
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */,
9CBE1B412C0F37B300CA6E61 /* DPDUIView+Extension.swift in Sources */,
@@ -2205,6 +2214,7 @@
52C8B05D2BDA5AA7003B51D0 /* ApplyGradrient.swift in Sources */,
52C6E01B2BE383C000E22D59 /* YourIntrestCell.swift in Sources */,
525954142BE8C87300191286 /* ExtensionVCToastAlert.swift in Sources */,
52ACC1302C639DBA00791528 /* MyOrderCell.swift in Sources */,
52B8D4D92C04A25E00ED65F3 /* UIViewController+Container.swift in Sources */,
9C834EDC2C1C26CD00B29A9C /* HtmlText.swift in Sources */,
527AC6F72C171C8F00434FB7 /* BlogsCell.swift in Sources */,
@@ -2231,6 +2241,7 @@
52A6DCBC2C4EA46400F63C51 /* ShopProductsCell.swift in Sources */,
528BEF602C2C372900FFDAB8 /* ContinueWatchingVC.swift in Sources */,
9CBCB29B2BE4D614007D7934 /* LoginVC.swift in Sources */,
52ACC12D2C63479300791528 /* WOKA.xcdatamodeld in Sources */,
52BC3BE82C0E04A9002FACA6 /* FaqListDM.swift in Sources */,
9C56E83B2BDBC6E600E4CA14 /* SelectAgeVM.swift in Sources */,
9C535DC02C00B36000DA6DCD /* HomeVC.swift in Sources */,
@@ -2247,6 +2258,7 @@
9C0A853F2BEE35340093783D /* ForgotPassDM.swift in Sources */,
52CC85542C5BABD40084030E /* WokaFMVM.swift in Sources */,
9CBCB2AA2BE51A52007D7934 /* ThemeOneVC.swift in Sources */,
52ACC1332C639F3800791528 /* OrderListingDM.swift in Sources */,
52D774E92BDFBDA4001D87DE /* AuthenticationStringConstant.swift in Sources */,
527A2BCE2C579D490080DF9B /* AddNewAddressVM.swift in Sources */,
5259541B2BE8D6F900191286 /* NetworkReachibility.swift in Sources */,
@@ -2831,14 +2843,14 @@
/* End XCSwiftPackageProductDependency section */
/* Begin XCVersionGroup section */
9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */ = {
52ACC12B2C63479300791528 /* WOKA.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */,
52ACC12C2C63479300791528 /* WOKA.xcdatamodel */,
);
currentVersion = 9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */;
currentVersion = 52ACC12C2C63479300791528 /* WOKA.xcdatamodel */;
name = WOKA.xcdatamodeld;
path = /Users/bilal/Desktop/woka_native_ios_swift/WOKA/WOKA.xcdatamodeld;
path = /Users/macbookpro/Desktop/WOKA/WOKA/WOKA.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};

View File

@@ -29,6 +29,7 @@ extension K{
struct SideBarNav{
static let faqCell = "FaqCell"
static let myOrderCell = "MyOrderCell"
}
struct Home{

View File

@@ -11,12 +11,15 @@ import SDWebImage
extension UIImageView {
func imageURL(_ url: String, color : UIColor = UIColor.black) {
let activityIndicator = UIActivityIndicatorView(style: .medium)
activityIndicator.tintColor = UIColor.darkGray
activityIndicator.color = color
activityIndicator.frame = CGRect(x: 0, y: 0, width: 64, height: 64)
activityIndicator.hidesWhenStopped = true
activityIndicator.startAnimating()
DispatchQueue.main.async {
activityIndicator.startAnimating()
}
activityIndicator.translatesAutoresizingMaskIntoConstraints = true
// activityIndicator.center = CGPoint(x: self.frame.size.width / 2, y: self.frame.size.height / 2)
@@ -27,9 +30,12 @@ extension UIImageView {
self.addSubview(activityIndicator)
// self.sd_setImage(with: <#T##URL?#>, placeholderImage: <#T##UIImage?#>)
self.sd_setImage(with: URL(string: url.replacingOccurrences(of: " ", with: "%20"))) { (image, error, cacheType, url) in
activityIndicator.stopAnimating()
// activityIndicator.stopAnimating()
DispatchQueue.main.async {
activityIndicator.stopAnimating()
// activityIndicator.removeFromSuperview()
}
}
// }
}

View File

@@ -405,7 +405,11 @@ extension MyListVC : CollectionViewSRC{
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
switch collectionView{
case webSeriesCV:
// 18- hindi , 1- english
guard let showData = MyListDataTemp.shareInstance.favListingData?.showData?[indexPath.row] else{return}
PersistentStorage.shared.addWebSeries(catID: 1, postID: showData.id ?? 0)
let showDataModified = WebSeriesShowListDM.ShowDatum(id: showData.id, title: showData.title, description: showData.description, thumbnailPath: showData.thumbnailPath, showType: showData.showType, totalSeasons: showData.totalSeasons, totalEpisodes: showData.totalEpisodes, categoryMasterID: nil, ageRangeMasterID: nil, genderMasterID: showData.genderMasterID, contentMoreDetails: showData.contentMoreDetails, seasonData: nil, categoryData: nil, ageRangeData: nil, genderData: nil, markAsFavourite: showData.markAsFavourite, isLiked: showData.isLiked, likedCategoryIDS: nil, favouriteCategoryIDS: ValueWrapper.stringValue(showData.bookmarkCategoryIDS ?? "1") , likesCount: showData.likesCount, viewsCount: showData.viewsCount, bookmarkCount: showData.bookmarkCount)
let sb = UIStoryboard(name: K.StoryBoard.webSeries, bundle: nil)
@@ -418,6 +422,8 @@ extension MyListVC : CollectionViewSRC{
self.vm.selectedCollection = .webSeriesCV
case webSeriesHindiCV:
let showData = MyListDataTemp.shareInstance.webSeriesHindi[indexPath.row]
PersistentStorage.shared.addWebSeries(catID: 18, postID: showData.id ?? 0)
let showDataModified = WebSeriesShowListDM.ShowDatum(id: showData.id, title: showData.title, description: showData.description, thumbnailPath: showData.thumbnailPath, showType: showData.showType, totalSeasons: showData.totalSeasons, totalEpisodes: showData.totalEpisodes, categoryMasterID: nil, ageRangeMasterID: nil, genderMasterID: showData.genderMasterID, contentMoreDetails: showData.contentMoreDetails, seasonData: nil, categoryData: nil, ageRangeData: nil, genderData: nil, markAsFavourite: showData.markAsFavourite, isLiked: showData.isLiked, likedCategoryIDS: nil, favouriteCategoryIDS: ValueWrapper.stringValue(showData.bookmarkCategoryIDS ?? "1") , likesCount: showData.likesCount, viewsCount: showData.viewsCount, bookmarkCount: showData.bookmarkCount)
let sb = UIStoryboard(name: K.StoryBoard.webSeries, bundle: nil)

View File

@@ -70,6 +70,7 @@ struct APIEndPoints {
static let update_profile = makeURL(path: "update_profile")
static let user_logout = makeURL(path: "user_logout")
static let user_deactivate_account = makeURL(path: "user_deactivate_account")
static let order_listing = makeURL(path: "order_listing")
}
struct Home{

View File

@@ -10,7 +10,7 @@ import CoreData
/**
Hey there, I hope you enjoyed the video, if you have any questions then please feel free to ask I will be happy to answer them.
Do share this with your iOS group on whatsapp or facebook or anyone who wants to learn iOS*/
enum PersistentStorageEnum : String{
@@ -22,24 +22,42 @@ enum PersistentStorageEnum : String{
case post_type
}
enum PostType: String {
case series = "1"
case season = "2"
case episode = "3"
case video = "4"
// case paint = "5"
case game = "6"
case audio = "7"
case karaokeVideo = "8"
case shopProduct = "9"
// case parentalVideo = "10"
// case article = "11"
case liveTV = "12"
case FM = "13"
case teaser = "14"
case others = "15"
case home = "16"
enum PostType: Int {
case series = 1
case season = 2
case episode = 3
case video = 4
// case paint = 5
case game = 6
case audio = 7
case karaokeVideo = 8
case shopProduct = 9
// case parentalVideo = 10
// case article = 11
case liveTV = 12
case FM = 13
case teaser = 14
case others = 15
case home = 16
}
//enum PostType: String {
// case series = "1"
// case season = "2"
// case episode = "3"
// case video = "4"
//// case paint = "5"
// case game = "6"
// case audio = "7"
// case karaokeVideo = "8"
// case shopProduct = "9"
//// case parentalVideo = "10"
//// case article = "11"
// case liveTV = "12"
// case FM = "13"
// case teaser = "14"
// case others = "15"
// case home = "16"
//}
struct UserClickData {
let clickCounts: Int
@@ -50,27 +68,27 @@ struct UserClickData {
final class PersistentStorage
{
private init(){}
static let shared = PersistentStorage()
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "WOKA")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved errorsss \(error), \(error.userInfo)")
}
})
return container
}()
lazy var context = persistentContainer.viewContext
// MARK: - Core Data Saving support
func saveContext() {
if context.hasChanges {
do {
@@ -83,7 +101,7 @@ final class PersistentStorage
}
func createData(data : UserClickData){
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
@@ -92,23 +110,23 @@ final class PersistentStorage
share.category_id = Int64(data.categoryId)
share.post_id = Int64(data.postId)
share.post_type = Int64(data.postType)
do {
try managedContext.save()
retrieveData()
retrieveData(postID: data.postId, catID: data.categoryId, postType: data.postType)
} catch let error as NSError {
print("Could not save. \(error), \(error.userInfo)")
}
}
func checkIfExist( key : PersistentStorageEnum , clicksData : UserClickData) {
let managedContext = PersistentStorage.shared.context
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: PersistentStorageEnum.UserClicks.rawValue)
// fetchRequest.fetchLimit = 1
// fetchRequest.predicate = NSPredicate(format: "id == %d" ,id)
// fetchRequest.fetchLimit = 1
// fetchRequest.predicate = NSPredicate(format: "id == %d" ,id)
fetchRequest.predicate = NSPredicate(format: "\(key.rawValue) == %@" ,clicksData.postType.toString())
do {
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
if result.isEmpty{
@@ -122,39 +140,70 @@ final class PersistentStorage
objectUpdate.setValue(result.first!.click_counts + Int64(clicksData.clickCounts), forKey: "click_counts")
do{
try managedContext.save()
self.retrieveData()
retrieveData(postID: clicksData.postId, catID: clicksData.categoryId, postType: clicksData.postType)
}
catch
{
print(error)
}
}
result.forEach { clicks in
print("Counts" , clicks.click_counts)
// result.forEach { clicks in
// print("Counts" , clicks.click_counts)
// }
}catch let error as NSError {
print("Could not fetch. \(error), \(error.userInfo)")
}
}
func checkWebSeries(clicksData : UserClickData) {
let managedContext = PersistentStorage.shared.context
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: PersistentStorageEnum.UserClicks.rawValue)
fetchRequest.fetchLimit = 1
fetchRequest.predicate = NSPredicate(format: "post_id == %@ AND category_id == %@" ,clicksData.postId.toString(), clicksData.categoryId.toString())
do {
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
if result.isEmpty{
//create
PersistentStorage.shared.createData(data: clicksData)
print("create Main")
}else{
//update
let objectUpdate = result[0] as NSManagedObject
print("Update Main")
objectUpdate.setValue(result.first!.click_counts + Int64(clicksData.clickCounts), forKey: "click_counts")
do{
try managedContext.save()
retrieveData(postID: clicksData.postId, catID: clicksData.categoryId, postType: clicksData.postType)
}
catch
{
print(error)
}
}
}catch let error as NSError {
print("Could not fetch. \(error), \(error.userInfo)")
}
}
func retrieveData() {
func retrieveData(postID : Int?, catID : Int?, postType : Int) {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
// debugPrint(path[0])
// debugPrint(path[0])
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
let fetchRequests = NSFetchRequest<NSFetchRequestResult>(entityName: "UserClicks")
fetchRequest.predicate = NSPredicate(format: "post_id == %@ AND category_id == %@ AND post_type == %@" ,postID?.toString() ?? "0", catID?.toString() ?? "0" ,postType.toString())
// fetchRequests.fetchLimit = 1
// fetchRequests.predicate = NSPredicate(format: "uuid = %@", "2")
// fetchRequests.sortDescriptors = [NSSortDescriptor.init(key: "uuid", ascending: false)]
// fetchRequests.fetchLimit = 1
// fetchRequests.sortDescriptors = [NSSortDescriptor.init(key: "uuid", ascending: false)]
do {
guard let result = try managedContext.fetch(fetchRequests) as? [UserClicks] else {return}
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
result.forEach { clicks in
print("ID:-" , clicks.post_type, "Count:-", clicks.click_counts)
print("ID:-" , PostType(rawValue: Int(clicks.post_type))!, "CatID:- ", clicks.category_id, "PostID:- ", clicks.post_id , "Count:-", clicks.click_counts)
}
} catch let error
@@ -163,93 +212,98 @@ final class PersistentStorage
}
}
func updateData(){
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
fetchRequest.predicate = NSPredicate(format: "uuid = %@", "2")
do
{
let test = try managedContext.fetch(fetchRequest)
let objectUpdate = test[0] as! NSManagedObject
objectUpdate.setValue("Bilal Ahmed Khan New Name", forKey: "name")
do{
try managedContext.save()
self.retrieveData()
}
catch
{
print(error)
}
}
catch
{
print(error)
}
// func updateData(){
// //We need to create a context from this container
// let managedContext = PersistentStorage.shared.context
//
//
// let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
// fetchRequest.predicate = NSPredicate(format: "uuid = %@", "2")
// do
// {
// let test = try managedContext.fetch(fetchRequest)
//
// let objectUpdate = test[0] as! NSManagedObject
// objectUpdate.setValue("Bilal Ahmed Khan New Name", forKey: "name")
// do{
// try managedContext.save()
// self.retrieveData()
// }
// catch
// {
// print(error)
// }
// }
// catch
// {
// print(error)
// }
//
// }
// func deleteData(){
// //We need to create a context from this container
// let managedContext = PersistentStorage.shared.context
//
// let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "UserClicks")
//// fetchRequest.fetchLimit = 1
//// fetchRequest.predicate = NSPredicate(format: "uuid = %@ AND uuid = %@", "1", "1")
// fetchRequest.predicate = NSPredicate(format: "post_id = %@", "11")
//
// do
// {
// let test = try managedContext.fetch(fetchRequest)
//
// let objectToDelete = test[0] as! NSManagedObject
//// test.forEach { obbject in
//// managedContext.delete(obbject as! NSManagedObject)
//// }
// managedContext.delete(test.first as! NSManagedObject)
//// managedContext.delete(objectToDelete)
//
// do{
// try managedContext.save()
//// self.createData()
// self.retrieveData()
// }
// catch
// {
// print(error)
// }
//
// }
// catch
// {
// print(error)
// }
// }
// MARK: - Handle Clicks
func addOthersCount(){
let userClicks = UserClickData(clickCounts: 1, categoryId: 0, postId: 0, postType: PostType.others.rawValue)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
func deleteData(){
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "UserClicks")
// fetchRequest.fetchLimit = 1
// fetchRequest.predicate = NSPredicate(format: "uuid = %@ AND uuid = %@", "1", "1")
fetchRequest.predicate = NSPredicate(format: "post_id = %@", "11")
do
{
let test = try managedContext.fetch(fetchRequest)
let objectToDelete = test[0] as! NSManagedObject
// test.forEach { obbject in
// managedContext.delete(obbject as! NSManagedObject)
// }
managedContext.delete(test.first as! NSManagedObject)
// managedContext.delete(objectToDelete)
do{
try managedContext.save()
// self.createData()
self.retrieveData()
}
catch
{
print(error)
}
}
catch
{
print(error)
}
func addRadioCount(){
guard let postID = AuthFunc.shareInstance.staticURLs?.liveFmData?.id else{return}
let userClicks = UserClickData(clickCounts: 1, categoryId: 0, postId: postID, postType: PostType.FM.rawValue)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
// func saveClicksCount(){
// let clicks = UserClicks(context: PersistentStorage.shared.context)
// clicks.post_type = 1
// clicks.post_id = 22
// clicks.category_id = 33
// clicks.click_counts = 100
// PersistentStorage.shared.saveContext()
// }
//
// func getchClicksCount(){
// let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
// debugPrint(path[0])
//
// do {
// guard let result = try PersistentStorage.shared.context.fetch(UserClicks.fetchRequest()) as? [UserClicks] else {return}
// result.forEach({debugPrint("sad", $0.click_counts)})
//
// } catch let error
// {
// debugPrint(error)
// }
// }
func addLiveTVCount(){
guard let postID = AuthFunc.shareInstance.staticURLs?.liveData?.first?.id else{return}
let userClicks = UserClickData(clickCounts: 1, categoryId: 0, postId: postID, postType: PostType.liveTV.rawValue)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
func addTrailerCount(){
let userClicks = UserClickData(clickCounts: 1, categoryId: 0, postId: 0, postType: PostType.teaser.rawValue)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
func addWebSeries(catID : Int, postID : Int){
let userClicks = UserClickData(clickCounts: 1, categoryId: catID, postId: postID, postType: PostType.series.rawValue)
PersistentStorage.shared.checkWebSeries(clicksData: userClicks)
}
}

View File

@@ -0,0 +1,64 @@
//
// OrderListingDM.swift
// WOKA
//
// Created by MacBook Pro on 07/08/24.
//
import Foundation
// MARK: - OrderListingDM
struct OrderListingDM: Codable {
let result: ResultData?
// MARK: - Result
struct ResultData: Codable {
let currentPage: Int?
let data: [Datum]?
let total: Int?
enum CodingKeys: String, CodingKey {
case currentPage = "current_page"
case data
case total
}
}
// MARK: - Datum
struct Datum: Codable {
let id: Int?
let orderID: String?
let numberOfProducts: Int?
let orderBookedDateTime, orderStatus, paymentMode, paymentStatus: String?
let grandTotal, deliverySuccessStatus: Int?
let airwaybilno, courier, branchCode, dispatchLabelURL: String?
let shipmentLatestStatusCode, shipmentLatestStatus, edd: String?
enum CodingKeys: String, CodingKey {
case id
case orderID = "order_id"
case numberOfProducts = "number_of_products"
case orderBookedDateTime = "order_booked_date_time"
case orderStatus = "order_status"
case paymentMode = "payment_mode"
case paymentStatus = "payment_status"
case grandTotal = "grand_total"
case deliverySuccessStatus = "delivery_success_status"
case airwaybilno, courier
case branchCode = "branch_code"
case dispatchLabelURL = "dispatch_label_url"
case shipmentLatestStatusCode = "shipment_latest_status_code"
case shipmentLatestStatus = "shipment_latest_status"
case edd
}
}
// MARK: - Link
struct Link: Codable {
let url: String?
let label: String?
let active: Bool?
}
}

View File

@@ -386,7 +386,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rbx-B4-wDn">
<rect key="frame" x="0.0" y="0.0" width="374" height="80"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="picture" translatesAutoresizingMaskIntoConstraints="NO" id="ho3-bu-sXX">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="DefaultAvatar" translatesAutoresizingMaskIntoConstraints="NO" id="ho3-bu-sXX">
<rect key="frame" x="147" y="0.0" width="80" height="80"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@@ -687,16 +687,16 @@
</scenes>
<designables>
<designable name="arD-av-w7V">
<size key="intrinsicContentSize" width="119.5" height="21"/>
<size key="intrinsicContentSize" width="169.5" height="21"/>
</designable>
<designable name="fZS-d6-t0h">
<size key="intrinsicContentSize" width="119" height="21"/>
<size key="intrinsicContentSize" width="169" height="21"/>
</designable>
<designable name="fiK-Gg-JDj">
<size key="intrinsicContentSize" width="119.5" height="21"/>
<size key="intrinsicContentSize" width="169.5" height="21"/>
</designable>
<designable name="zMI-2r-pRQ">
<size key="intrinsicContentSize" width="119" height="21"/>
<size key="intrinsicContentSize" width="169" height="21"/>
</designable>
</designables>
<resources>
@@ -704,12 +704,12 @@
<image name="AboutVector" width="569.33331298828125" height="538.66668701171875"/>
<image name="BackgroundSplash" width="428" height="926"/>
<image name="Boy" width="49.5" height="50"/>
<image name="DefaultAvatar" width="133.33332824707031" height="133.33332824707031"/>
<image name="Girl" width="48.5" height="50"/>
<image name="OrderBottom" width="570.66668701171875" height="294.66665649414062"/>
<image name="SupportBottomArrow" width="16" height="16"/>
<image name="SupportGirlImage" width="166" height="166"/>
<image name="WokaLogo" width="2224" height="450.5"/>
<image name="picture" width="512" height="512"/>
<namedColor name="TextDarkBlue">
<color red="0.10599999874830246" green="0.050999999046325684" blue="0.60399997234344482" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>

View File

@@ -0,0 +1,23 @@
//
// MyOrderCell.swift
// WOKA
//
// Created by MacBook Pro on 07/08/24.
//
import UIKit
class MyOrderCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="Exo2-Bold.ttf">
<string>Exo2-Bold</string>
</array>
<array key="Exo2-Regular.ttf">
<string>Exo2-Regular</string>
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="166" id="KGk-i7-Jjw" customClass="MyOrderCell" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="422" height="166"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="422" height="166"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="thq-h9-HTk">
<rect key="frame" x="10" y="10" width="402" height="146"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="om1-xl-cHl">
<rect key="frame" x="0.0" y="0.0" width="402" height="146"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="fFg-2g-NQo">
<rect key="frame" x="5" y="5" width="392" height="21.666666666666668"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="H3K-qQ-uIB">
<rect key="frame" x="0.0" y="0.0" width="164.66666666666666" height="21.666666666666668"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="252" text="Order ID :" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tNd-xw-5fU">
<rect key="frame" x="0.0" y="0.0" width="71" height="21.666666666666668"/>
<fontDescription key="fontDescription" name="Exo2-Regular" family="Exo 2" pointSize="17"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="W12121212" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qjR-wR-llK">
<rect key="frame" x="74" y="0.0" width="90.666666666666686" height="21.666666666666668"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="tsW-Oy-qce">
<rect key="frame" x="227.33333333333337" y="0.0" width="164.66666666666663" height="21.666666666666668"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="252" text="Order ID :" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CTh-M7-uPa">
<rect key="frame" x="0.0" y="0.0" width="71" height="21.666666666666668"/>
<fontDescription key="fontDescription" name="Exo2-Regular" family="Exo 2" pointSize="17"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="W12121212" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DxS-tx-EWT">
<rect key="frame" x="73.999999999999972" y="0.0" width="90.666666666666657" height="21.666666666666668"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cbL-y4-34J">
<rect key="frame" x="5" y="36.666666666666664" width="392" height="0.3333333333333357"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="0.29999999999999999" id="yM2-6x-UgH"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="Dbe-aH-UFu">
<rect key="frame" x="5" y="47" width="392" height="94"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="zTN-Hj-3ve">
<rect key="frame" x="0.0" y="0.0" width="90.666666666666671" height="94"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="252" text="PLACED ON" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LIE-Az-C4m">
<rect key="frame" x="0.0" y="0.0" width="90.666666666666671" height="20.666666666666668"/>
<fontDescription key="fontDescription" name="Exo2-Regular" family="Exo 2" pointSize="17"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="W12121212" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3e7-GB-nb5">
<rect key="frame" x="0.0" y="22.666666666666671" width="90.666666666666671" height="71.333333333333329"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="textColor" name="ImageDarkBlue"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NZy-Uo-gaT">
<rect key="frame" x="342" y="0.0" width="50" height="94"/>
<color key="backgroundColor" systemColor="linkColor"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="Nwj-FX-GjI"/>
</constraints>
</view>
</subviews>
</stackView>
</subviews>
<edgeInsets key="layoutMargins" top="5" left="5" bottom="5" right="5"/>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="om1-xl-cHl" firstAttribute="top" secondItem="thq-h9-HTk" secondAttribute="top" id="2nM-Jb-6B0"/>
<constraint firstAttribute="trailing" secondItem="om1-xl-cHl" secondAttribute="trailing" id="KoM-Zx-hXS"/>
<constraint firstItem="om1-xl-cHl" firstAttribute="leading" secondItem="thq-h9-HTk" secondAttribute="leading" id="orm-Rh-bvO"/>
<constraint firstAttribute="bottom" secondItem="om1-xl-cHl" secondAttribute="bottom" id="x5z-ah-uKH"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="10"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<constraints>
<constraint firstItem="thq-h9-HTk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="6zo-Pn-31L"/>
<constraint firstAttribute="bottom" secondItem="thq-h9-HTk" secondAttribute="bottom" constant="10" id="8Qs-K0-RDx"/>
<constraint firstItem="thq-h9-HTk" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="sKA-s3-NVp"/>
<constraint firstAttribute="trailing" secondItem="thq-h9-HTk" secondAttribute="trailing" constant="10" id="z8U-Ao-HNh"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<point key="canvasLocation" x="216.79389312977099" y="62.676056338028175"/>
</tableViewCell>
</objects>
<resources>
<namedColor name="ImageDarkBlue">
<color red="0.035000000149011612" green="0.0" blue="0.36500000953674316" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>

View File

@@ -6,12 +6,13 @@
//
import UIKit
import Alamofire
class MyOrdersVM{
weak var vc : MyOrdersVC!
var cartButton: UIBarButtonItem!
var pageNo = 1
func initView(){
vc.title = "MY ORDERS".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
@@ -30,6 +31,8 @@ class MyOrdersVM{
}
}
}
getOrders()
}
@objc func cartButtonTapped(){
@@ -39,4 +42,33 @@ class MyOrdersVM{
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
self.vc.navigationController?.pushViewController(vcPush, animated: true)
}
// MARK: - Get MyORders
func getOrders(){
Utilities.startProgressHUD()
let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi",
"access-token": AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["limit" : "10"]
let url = "\(APIEndPoints.SideBarNav.order_listing )?page=\(pageNo)"
NetworkManager.shareInstance.apiRequest(url: url, method: .post, parameters: params,headers : headers) {(result : Result<BaseResponseModel<OrderListingDM>, NetworkManager.APIError>) in
switch result{
case .success(let data):
switch data.success{
case 0:
Utilities.dismissProgressHUD()
return
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data?.result else{return}
print(data)
default:
break
}
case .failure(let error):
Utilities.dismissProgressHUD()
}
}
}
}

View File

@@ -91,9 +91,9 @@ class ProfileVM{
vc.dob.date = formattedDate ?? Date()
}
//set the first name as the name
if let avatar = data.avtar{
if let avatar = data.avtarURL{
//https://wokaland.com/admin/storage/app/public/uploads/avtar/avatar2.png?d=1716889852
vc.avatarImage.imageURL("https://wokaland.com/admin/storage/app/public/uploads/avtar/avatar2.png?d=1716889852",color: .white)
vc.avatarImage.imageURL(avatar,color: .white)
}
setGender()

View File

@@ -51,10 +51,12 @@ class SideMenuVC: UIViewController {
}
@IBAction func closeBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addOthersCount()
self.sideMenuController?.hideMenu()
}
@IBAction func btnTapped(_ sender : UIButton){
PersistentStorage.shared.addOthersCount()
switch sender{
case aboutBtn:
self.sideMenuController?.hideMenu()
@@ -64,7 +66,6 @@ class SideMenuVC: UIViewController {
NotificationCenter.default.post(name: .linkPush, object: nil, userInfo: ["type": LinkTypeEnum.faq])
case wokaSupportBtn:
self.sideMenuController?.hideMenu()
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
NotificationCenter.default.post(name: .linkPush, object: nil, userInfo: ["type": LinkTypeEnum.support])
case profileBtn:
self.sideMenuController?.hideMenu()
@@ -93,6 +94,8 @@ class SideMenuVC: UIViewController {
}
@IBAction func logoutBtnTapped(_ sender: LocalisedElementsButton) {
PersistentStorage.shared.addOthersCount()
// if its guest user navigate him to login
if AuthFunc.shareInstance.getUserType() == 3{
self.sideMenuController?.hideMenu()
@@ -108,6 +111,7 @@ class SideMenuVC: UIViewController {
guard let self else{return}
switch mode{
case .yes:
PersistentStorage.shared.addOthersCount()
//If user clicked to proceed on login. Call the api.
vm.logoutUser { isDone in
self.sideMenuController?.hideMenu()
@@ -115,6 +119,7 @@ class SideMenuVC: UIViewController {
UIApplication.setRootView(LoginNavVC.instantiate(from: .AuthenticationSB))
}
case .no:
PersistentStorage.shared.addOthersCount()
print("no")
}
}
@@ -124,6 +129,8 @@ class SideMenuVC: UIViewController {
}
@IBAction func languageSwitchSlide(_ sender: CustomizableSegmentControl) {
PersistentStorage.shared.addOthersCount()
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { _ in

View File

@@ -244,6 +244,7 @@ extension TabBarVC: UITabBarControllerDelegate {
// This method will be called whenever a tab is selected
// Do something based on the selected index
print("Selected tab index: \(tabBarController.selectedIndex)")
PersistentStorage.shared.addOthersCount()
if tabBarController.selectedIndex == 1{
@@ -254,6 +255,8 @@ extension TabBarVC: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if viewController == tabBarController.viewControllers?[1] {
PersistentStorage.shared.addOthersCount()
let sb = UIStoryboard(name: "Home", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "ExploreWokaVC") as! ExploreWokaVC
vc.modalPresentationStyle = .overCurrentContext

View File

@@ -35,6 +35,8 @@ class SideMenuVM{
vc.theme2.addBorderView(width: 1.5, color: UIColor.white)
vc.theme1.addTapGesture { [weak self] in
PersistentStorage.shared.addOthersCount()
guard let self else {return}
if AuthFunc.shareInstance.selectedTheme == .theme1{
@@ -53,6 +55,8 @@ class SideMenuVM{
}
vc.theme2.addTapGesture { [weak self] in
PersistentStorage.shared.addOthersCount()
guard let self else {return}
if AuthFunc.shareInstance.selectedTheme == .theme2{

View File

@@ -21,6 +21,7 @@ class BlogDetailsVC: UIViewController {
}
@IBAction func clostBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addOthersCount()
self.dismiss(animated: true)
}

View File

@@ -33,7 +33,9 @@ class MoreVC: UIViewController {
vm.player?.pause()
}
@IBAction func playTrailerBtnTapped(_ sender: LocalisedElementsButton) {
PersistentStorage.shared.addTrailerCount()
let item = JwPlayerItemCreate(url: APIEndPoints.StaticURLs.masilaUrl, poster: nil, titles: "Masila")
JWPlayerManager.shared.presentPlayer(from: self, playerItems: [item], contentType: .trailer)
}
@@ -83,6 +85,7 @@ extension MoreVC : TableViewSRC{
guard let cell = tableView.cellForRow(at: indexPath) else { return }
addAnimation(cell: cell) { [weak self] in
guard let self else{return}
PersistentStorage.shared.addOthersCount()
/*
this will declare if the song is playing or not
*/
@@ -213,6 +216,7 @@ extension MoreVC : CollectionViewSRC{
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
PersistentStorage.shared.addOthersCount()
let data = vm.blogData[indexPath.row]
let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Theme.blogDetailsVC) as! BlogDetailsVC

View File

@@ -33,7 +33,6 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
super.viewDidLoad()
// self.rotateToLandsScapeDevice()
// rotateView(to: .pi / 2) // Example: 90 degrees rotation
//bring back button to the front
self.view.bringSubviewToFront(backButton)
}
@@ -46,7 +45,7 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
@objc func applicationDidBecomeActive() {
// self.setDeviceOrientation(orientation: .landscapeRight)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
@@ -77,12 +76,36 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
self.dismissTapped?()
}
appDelegate.deviceOrientation = .portrait
updateClicks()
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}
func updateClicks(){
switch contentType {
case .liveStream:
PersistentStorage.shared.addLiveTVCount()
// case .webSeries:
//// PersistentStorage.shared.addOthersCount()
case .trailer:
PersistentStorage.shared.addTrailerCount()
// case .continueWatching:
// <#code#>
// case .audioBooks:
// <#code#>
// case .games:
// <#code#>
// case .songs:
// <#code#>
case nil:
break
default:
break
}
}
// MARK: - Handle Screen Transition
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@@ -111,7 +134,7 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
}
// MARK: - JWPlayerViewControllerDelegate
override func jwplayer(_ player: any JWPlayer, didFinishLoadingWithTime loadTime: TimeInterval) {
super.jwplayer(player, didFinishLoadingWithTime: loadTime)
print("LoadTime", loadTime)
@@ -167,7 +190,6 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
self.handleBackAction()
}
}
}
override func jwplayer(_ player: JWPlayer, encounteredWarning code: UInt, message: String) {
@@ -192,10 +214,23 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
print("Buffering Reason:", reason)
}
//When Player is Paused
override func jwplayer(_ player: JWPlayer, didPauseWithReason reason: JWPauseReason) {
super.jwplayer(player, didPauseWithReason: reason)
if reason == .interaction{
updateClicks()
}
// Implement custom behavior
}
//When Player is Play
override func jwplayer(_ player: JWPlayer, isPlayingWithReason reason: JWPlayReason) {
super.jwplayer(player, isPlayingWithReason: reason)
if reason == .interaction{
updateClicks()
}
}
}
// MARK: - Full Screen Handling
@@ -228,7 +263,7 @@ extension PlayerVC {
func playerViewControllerDidDismissFullScreen(_ controller: JWPlayerViewController) {
print("playerViewControllerDidDismissFullScreen")
appDelegate.deviceOrientation = .portrait
updateClicks()
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
@@ -262,4 +297,5 @@ extension PlayerVC {
func playerViewController(_ controller: JWPlayerKit.JWPlayerViewController, relatedItemBeganPlaying item: JWPlayerKit.JWPlayerItem, atIndex index: Int, withMethod method: JWPlayerKit.JWRelatedMethod) {
print("Item ", item)
}
}

View File

@@ -73,10 +73,7 @@ class ThemeOneVC: UIViewController {
// PersistentStorage.shared.deleteData()
// PersistentStorage.shared.retrieveData()
let userClicks = UserClickData(clickCounts: 5, categoryId: 0, postId: 0, postType: 1)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
override func viewWillAppear(_ animated: Bool) {
@@ -119,31 +116,25 @@ class ThemeOneVC: UIViewController {
}
@IBAction func barButtonTapped(_ sender: UIButton) {
PersistentStorage.shared.addOthersCount()
self.sideMenuController?.revealMenu()
}
@IBAction func notificationBtnTapped(_ sender: UIButton) {
// CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in
// if isDone{
// let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC
// self.navigationController?.pushViewController(vcPush, animated: true)
// }
// }
PersistentStorage.shared.addOthersCount()
let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC
self.navigationController?.pushViewController(vcPush, animated: true)
}
@IBAction func radioBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addRadioCount()
let sb = UIStoryboard(name: K.StoryBoard.wokaFM, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.WokaFM.wokaFMVC) as! WokaFMVC
vcPush.modalPresentationStyle = .overCurrentContext
vcPush.modalTransitionStyle = .crossDissolve
self.present(vcPush, animated: true)
let userClicks = UserClickData(clickCounts: 5, categoryId: 0, postId: 0, postType: 1)
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
}
}

View File

@@ -40,7 +40,9 @@ class MoreVM{
setupCell()
vc.songTableView.showsVerticalScrollIndicator = false
vc.songTableView.showsHorizontalScrollIndicator = false
vc.homeBtn.addTapGesture {
PersistentStorage.shared.addOthersCount()
self.vc.dismiss(animated: true)
}
}

View File

@@ -15,7 +15,7 @@ class ThemeOneVM{
weak var vc : ThemeOneVC!
var cloudMovingRight = false // Flag to track the direction of movement
var isMovingRight = false // Flag to track the direction of movement
// var liveStreamURL = "https://d3volyx7jx7oal.cloudfront.net/master.m3u8"
// var liveStreamURL = "https://d3volyx7jx7oal.cloudfront.net/master.m3u8"
var avPlayer : AVPlayer!
var playerItem: AVPlayerItem!
@@ -23,17 +23,11 @@ class ThemeOneVM{
var shouldAnimate = true
let reachability = NetworkReachabilityManager()
// var jwPlayerViewController: JWPlayerViewController!
// var jwPlayerViewController: JWPlayerViewController!
func initView(){
vc.bottomArrow.addTapGesture {
let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Theme.moreVC) as! MoreVC
vcPush.modalPresentationStyle = .fullScreen
vcPush.modalTransitionStyle = .crossDissolve
self.vc.present(vcPush, animated: true)
}
AuthFunc.shareInstance.initTimePeriods()
startInitialTimer()
moveCloudView()
@@ -46,7 +40,7 @@ class ThemeOneVM{
vc.nameLabel.setContentCompressionResistancePriority(.fittingSizeLevel, for: .horizontal)
handleBackground()
}
private func handleNotificationCenter(){
@@ -55,60 +49,60 @@ class ThemeOneVM{
NotificationCenter.default.addObserver(self, selector: #selector(self.themeOnePush(notification:)), name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeOnePush), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.reloadTheme), name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
}
func setupAvPlayer(){
// Ensure the liveStreamURL is valid
// guard let liveStreamURL = URL(string: self.liveStreamURL) else {
// print("Invalid live stream URL")
// Utilities.dismissProgressHUD()
// return
// }
// jwPlayerViewController = JWPlayerViewController()
// do{
// let videoSourceBuilder = try JWVideoSourceBuilder()
// // .defaultVideo(true)
// .file(liveStreamURL)
// .label("Live Stream")
// .build()
//
// // Create a JWPlayerItem
// let item = try JWPlayerItemBuilder()
// // .file(liveStreamURL)
// .videoSources([videoSourceBuilder])
// .build()
//
// // Create a JWPlayerConfiguration
// let config = try JWPlayerConfigurationBuilder()
// .playlist(items: [item])
//// .preload(JWPreload(rawValue: 20) ?? .none)
// .autostart(true)
// .build()
//
//
//
// // Add JWPlayerViewController's view as a subview
// self.vc.liveTvPlayer.addSubview(jwPlayerViewController.view)
// jwPlayerViewController.view.frame = self.vc.liveTvPlayer.bounds
//
//// // Set up constraints
//// jwPlayerViewController.view.translatesAutoresizingMaskIntoConstraints = false
//// NSLayoutConstraint.activate([
//// jwPlayerViewController.view.topAnchor.constraint(equalTo: self.vc.liveTvPlayer.topAnchor),
//// jwPlayerViewController.view.leadingAnchor.constraint(equalTo: self.vc.liveTvPlayer.leadingAnchor),
//// jwPlayerViewController.view.trailingAnchor.constraint(equalTo: self.vc.liveTvPlayer.trailingAnchor),
//// jwPlayerViewController.view.bottomAnchor.constraint(equalTo: self.vc.liveTvPlayer.bottomAnchor)
//// ])
// jwPlayerViewController.player.volume = 0.0
//
// jwPlayerViewController.player.configurePlayer(with: config)
// jwPlayerViewController.interfaceBehavior = .hidden
//// self.vc.liveTvPlayer.addSubview(jwPlayerViewController.view)
//// jwPlayerViewController.player.play()
//
// }catch{
// print(error)
// }
// guard let liveStreamURL = URL(string: self.liveStreamURL) else {
// print("Invalid live stream URL")
// Utilities.dismissProgressHUD()
// return
// }
// jwPlayerViewController = JWPlayerViewController()
// do{
// let videoSourceBuilder = try JWVideoSourceBuilder()
// // .defaultVideo(true)
// .file(liveStreamURL)
// .label("Live Stream")
// .build()
//
// // Create a JWPlayerItem
// let item = try JWPlayerItemBuilder()
// // .file(liveStreamURL)
// .videoSources([videoSourceBuilder])
// .build()
//
// // Create a JWPlayerConfiguration
// let config = try JWPlayerConfigurationBuilder()
// .playlist(items: [item])
//// .preload(JWPreload(rawValue: 20) ?? .none)
// .autostart(true)
// .build()
//
//
//
// // Add JWPlayerViewController's view as a subview
// self.vc.liveTvPlayer.addSubview(jwPlayerViewController.view)
// jwPlayerViewController.view.frame = self.vc.liveTvPlayer.bounds
//
//// // Set up constraints
//// jwPlayerViewController.view.translatesAutoresizingMaskIntoConstraints = false
//// NSLayoutConstraint.activate([
//// jwPlayerViewController.view.topAnchor.constraint(equalTo: self.vc.liveTvPlayer.topAnchor),
//// jwPlayerViewController.view.leadingAnchor.constraint(equalTo: self.vc.liveTvPlayer.leadingAnchor),
//// jwPlayerViewController.view.trailingAnchor.constraint(equalTo: self.vc.liveTvPlayer.trailingAnchor),
//// jwPlayerViewController.view.bottomAnchor.constraint(equalTo: self.vc.liveTvPlayer.bottomAnchor)
//// ])
// jwPlayerViewController.player.volume = 0.0
//
// jwPlayerViewController.player.configurePlayer(with: config)
// jwPlayerViewController.interfaceBehavior = .hidden
//// self.vc.liveTvPlayer.addSubview(jwPlayerViewController.view)
//// jwPlayerViewController.player.play()
//
// }catch{
// print(error)
// }
/*
Av Player Setup
@@ -118,20 +112,20 @@ class ThemeOneVM{
return
}
var url = String()
// var title = String()
// var title = String()
if AuthFunc.shareInstance.languageSelected == .english{
url = liveStreamData.liveURL?.hdURLEn ?? ""
// title = liveStreamData.name?.titleEn ?? ""
// title = liveStreamData.name?.titleEn ?? ""
}else{
url = liveStreamData.liveURL?.hdURLHin ?? ""
// title = liveStreamData.name?.titleHin ?? ""
// title = liveStreamData.name?.titleHin ?? ""
}
guard let streamURL = URL(string: url) else{return}
playerItem = AVPlayerItem(url: streamURL)
// Create AVPlayer with the stream URL
avPlayer = AVPlayer(playerItem: playerItem)
// avPlayer.isMuted = true
@@ -171,7 +165,7 @@ class ThemeOneVM{
if let avatar = data.avtarURL{
vc.avatarImage.imageURL(avatar)
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
}else{
vc.avatarImage.image = UIImage(named: "DefaultAvatar")
}
@@ -200,8 +194,26 @@ class ThemeOneVM{
// MARK: - Handle Tap Gesture
func handleTaps(){
vc.bottomArrow.addTapGesture {
PersistentStorage.shared.addOthersCount()
let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Theme.moreVC) as! MoreVC
vcPush.modalPresentationStyle = .fullScreen
vcPush.modalTransitionStyle = .crossDissolve
self.vc.present(vcPush, animated: true)
}
/*
1 = series, 2 = season, 3= episode, 4 = video, 5 = paint, 6 = game, 7 = audio, 8 = kareoke video, 9 = shop product, 10 = parental video, 11 = article, 12 = live TV, 13 = FM, 14 = teaser, 15 others, 16 = Home
FM & Live TV - post_id , post_type
rest all will be in others post_type = 15
*/
//WebSeries
vc.webSeriesView.addTapGesture {
PersistentStorage.shared.addOthersCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.webSeriesView) { [weak self] in
guard let self else{return}
self.checkType(action: .webseries)
@@ -209,6 +221,8 @@ class ThemeOneVM{
}
vc.audioBooksView.addTapGesture {
PersistentStorage.shared.addOthersCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.audioBooksView) { [weak self] in
guard let self else{return}
self.checkType(action: .audioBooks)
@@ -216,6 +230,8 @@ class ThemeOneVM{
}
vc.gamesView.addTapGesture {
PersistentStorage.shared.addOthersCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.gamesView) { [weak self] in
guard let self else{return}
self.checkType(action: .games)
@@ -223,6 +239,8 @@ class ThemeOneVM{
}
vc.karaokeView.addTapGesture { [self] in
PersistentStorage.shared.addOthersCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.karaokeView) { [weak self] in
guard let self else{return}
self.checkType(action: .karaoke)
@@ -230,6 +248,8 @@ class ThemeOneVM{
}
vc.shopView.addTapGesture {
PersistentStorage.shared.addOthersCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.shopView) { [weak self] in
guard let self else{return}
self.checkType(action: .shop)
@@ -237,6 +257,8 @@ class ThemeOneVM{
}
vc.liveTVIcon.addTapGesture {
PersistentStorage.shared.addLiveTVCount()
ViewButtonAnimation.sharedInstance.btnTapped(in: self.vc, view: self.vc.liveTVIcon) { [weak self] in
guard let self else{return}
self.checkType(action: .liveTV)
@@ -300,7 +322,7 @@ class ThemeOneVM{
}
func moveLiveTVView() {
guard shouldAnimate else {
guard shouldAnimate else {
self.centerLiveTVViewHorizontally()
return
} // Stop animating if shouldAnimate is false
@@ -350,7 +372,7 @@ class ThemeOneVM{
private func addTapGestureToMovingView(){
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
// tap.numberOfTouchesRequired = 1
// tap.numberOfTouchesRequired = 1
tap.numberOfTapsRequired = 1
vc.liveTVView.addGestureRecognizer(tap)
vc.liveTVView.isUserInteractionEnabled = true
@@ -358,7 +380,7 @@ class ThemeOneVM{
// function which is triggered when handleTap on livetv is called
@objc func handleTap(_ sender: UITapGestureRecognizer) {
PersistentStorage.shared.addLiveTVCount()
DispatchQueue.main.async {
Utilities.startProgressHUD(msg: "Loading...")
}
@@ -531,7 +553,7 @@ class ThemeOneVM{
// let hitView = super.hitTest(point, with: event)
// // Debug statement to check when hitTest is called
// print("hitTest called with point: \(point)")
//
//
// // Check if the touch is within the bounds of this view
// if hitView == self {
// return hitView

View File

@@ -27,6 +27,7 @@ class WokaFMVC: UIViewController {
}
@IBAction func playBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addRadioCount()
if sender == playBtn{
if sender.image(for: .normal)?.pngData() == UIImage(named: "Reload")?.pngData(){
// when user reloads check for internet connection
@@ -43,6 +44,7 @@ class WokaFMVC: UIViewController {
}
@IBAction func volumeBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addRadioCount()
switch sender{
case volPlusBtn:
if vm.player.volume == 1 {
@@ -68,6 +70,7 @@ class WokaFMVC: UIViewController {
}
@IBAction func closeBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addRadioCount()
self.dismiss(animated: true)
}

View File

@@ -31,7 +31,7 @@ class WebSeriesEpisodeCell: UITableViewCell {
func setData(data : EpisodeListingDM.ResultData){
if let url = data.thumbnailPath{
self.seasonImage.imageURL(url, color: .black)
self.seasonImage.imageURL(url, color: UIColor.appColor(.TextDarkBlue)!)
}
self.seasonTime.text = data.episodeDuration ?? "0:00:00"