diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index c8fbcab..a842bda 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -728,6 +728,7 @@ 9CDCE1432BDB9B64003FEF11 /* Sounds */, 52C8B0722BDA7560003B51D0 /* GIF_JSON */, 523ED2942BDA3D0800CFED02 /* Fonts */, + 9C56E8472BDBEFAB00E4CA14 /* AssetColor.swift */, 523ED2662BDA2BC900CFED02 /* Assets.xcassets */, ); path = Assets; @@ -898,7 +899,6 @@ 5202AAFF2BDFA7860043B7BD /* Validations */, 52C8B06A2BDA6E7A003B51D0 /* Localized */, 52C8B0522BDA4B58003B51D0 /* UIElements Helper */, - 9C56E8472BDBEFAB00E4CA14 /* AssetColor.swift */, 52663FF62BDFACF60001D8CE /* ShadowView.swift */, 5257B2642BDFB6F50086D79B /* CheckPhoneHomeBtnOrNotch.swift */, 52D774F02BDFC53B001D87DE /* StringSubScript.swift */, diff --git a/WOKA/Helpers/AssetColor.swift b/WOKA/Assets/AssetColor.swift similarity index 92% rename from WOKA/Helpers/AssetColor.swift rename to WOKA/Assets/AssetColor.swift index 2d6a0cf..9f0303a 100644 --- a/WOKA/Helpers/AssetColor.swift +++ b/WOKA/Assets/AssetColor.swift @@ -9,6 +9,7 @@ import UIKit enum AssetsColor: String { case TextDarkBlue + case ImageDarkBlue } extension UIColor { diff --git a/WOKA/Assets/Assets.xcassets/AssetColor/ImageDarkBlue.colorset/Contents.json b/WOKA/Assets/Assets.xcassets/AssetColor/ImageDarkBlue.colorset/Contents.json new file mode 100644 index 0000000..082a2e7 --- /dev/null +++ b/WOKA/Assets/Assets.xcassets/AssetColor/ImageDarkBlue.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.365", + "green" : "0.000", + "red" : "0.035" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/Contents.json b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/Contents.json new file mode 100644 index 0000000..387f38b --- /dev/null +++ b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "FavouriteRemove.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "FavouriteRemove@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "FavouriteRemove@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove.png new file mode 100644 index 0000000..e2c296f Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@2x.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@2x.png new file mode 100644 index 0000000..4757c35 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@2x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@3x.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@3x.png new file mode 100644 index 0000000..4dd018e Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteAdd.imageset/FavouriteRemove@3x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/Contents.json b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/Contents.json new file mode 100644 index 0000000..0ad881b --- /dev/null +++ b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "FavouriteAdd.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "FavouriteAdd@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "FavouriteAdd@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd.png new file mode 100644 index 0000000..81e47d6 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@2x.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@2x.png new file mode 100644 index 0000000..b8212af Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@2x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@3x.png b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@3x.png new file mode 100644 index 0000000..797b663 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/FavouriteRemove.imageset/FavouriteAdd@3x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/Contents.json b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/Contents.json new file mode 100644 index 0000000..cb3c8cf --- /dev/null +++ b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "likeAdd.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "likeAdd@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "likeAdd@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd.png new file mode 100644 index 0000000..9a0d4b9 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@2x.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@2x.png new file mode 100644 index 0000000..d5f95ad Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@2x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@3x.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@3x.png new file mode 100644 index 0000000..35b2168 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeAdd.imageset/likeAdd@3x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/Contents.json b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/Contents.json new file mode 100644 index 0000000..cc15854 --- /dev/null +++ b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "LikeRemove.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "LikeRemove@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "LikeRemove@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove.png new file mode 100644 index 0000000..881031d Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@2x.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@2x.png new file mode 100644 index 0000000..d3923f1 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@2x.png differ diff --git a/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@3x.png b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@3x.png new file mode 100644 index 0000000..f791468 Binary files /dev/null and b/WOKA/Assets/Assets.xcassets/WebSeries/LikeRemove.imageset/LikeRemove@3x.png differ diff --git a/WOKA/Authentication/ViewModel/SelectAvatarVM.swift b/WOKA/Authentication/ViewModel/SelectAvatarVM.swift index 24a9d16..29bf610 100644 --- a/WOKA/Authentication/ViewModel/SelectAvatarVM.swift +++ b/WOKA/Authentication/ViewModel/SelectAvatarVM.swift @@ -88,7 +88,7 @@ class SelectAvatarVM{ /* Set UserType */ - if let createChildAccount{ + if createChildAccount != nil{ AuthFunc.shareInstance.regData.user_type = "1" /* In Add child will be 1 diff --git a/WOKA/Home/Controller/MyListVC.swift b/WOKA/Home/Controller/MyListVC.swift index 2a3a14b..d4baf76 100644 --- a/WOKA/Home/Controller/MyListVC.swift +++ b/WOKA/Home/Controller/MyListVC.swift @@ -27,6 +27,7 @@ class MyListVC: UIViewController{ @IBOutlet weak var scrollView: UIScrollView! + @IBOutlet weak var gradientView: UIView! var vm = MyListVM() override func viewDidLoad() { @@ -57,6 +58,7 @@ class MyListVC: UIViewController{ override func viewDidAppear(_ animated: Bool) { if K.GVar.reloadMyList{ K.GVar.reloadMyList = false + Utilities.startProgressHUD() vm.getFavouriteListing() } } @@ -201,7 +203,6 @@ extension MyListVC : CollectionViewSRC{ webSeriesHindiCV.reloadItems(at: [IndexPath(row: i, section: 0)]) } } - } } } @@ -413,9 +414,98 @@ extension MyListVC : CollectionViewSRC{ } extension MyListVC : ReloadSeriesFavLike{ - func updateRows(index: Int, type: FavCellCLick) { - updateFavLikes(type: type, index: index) + func updateRows(index: Int, type: FavCellCLick, isFav: Bool?, isLike: Bool?) { + + switch vm.selectedCollection { + case .webSeriesCV: +// if let isFav{ +// let categoryID = vm.categoryListingData[vm.dropDownModule.indexForSelectedRow ?? 0].id ?? 0 +// switch isFav{ +// case true: +// vm.showData[index].markAsFavourite = true +// vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString()) +// showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) +// case false: +// vm.showData[index].markAsFavourite = false +// vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue("") +// showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) +// } +// K.GVar.reloadMyList = true +// } + + if let isLike{ + switch isLike{ + case true: + vm.favListingData?.showData?[index].isLiked = true + vm.favListingData?.showData?[index].likesCount! += 1 + webSeriesCV.reloadItems(at: [IndexPath(row: index, section: 0)]) + + for (i,element) in vm.webSeriesHindi.enumerated(){ + if element.id == vm.favListingData?.showData?[index].id{ + vm.webSeriesHindi[i].isLiked = true + vm.webSeriesHindi[i].likesCount! += 1 + webSeriesHindiCV.reloadItems(at: [IndexPath(row: i, section: 0)]) + } + } + case false: + vm.favListingData?.showData?[index].isLiked = false + vm.favListingData?.showData?[index].likesCount! -= 1 + webSeriesCV.reloadItems(at: [IndexPath(row: index, section: 0)]) + + for (i,element) in vm.webSeriesHindi.enumerated(){ + if element.id == vm.favListingData?.showData?[index].id{ + vm.webSeriesHindi[i].isLiked = false + vm.webSeriesHindi[i].likesCount! -= 1 + webSeriesHindiCV.reloadItems(at: [IndexPath(row: i, section: 0)]) + } + } + } + } + case .webSeriesHindiCV: + if let isLike{ + switch isLike{ + case true: + vm.webSeriesHindi[index].isLiked = true + vm.webSeriesHindi[index].likesCount! += 1 + webSeriesHindiCV.reloadItems(at: [IndexPath(row: index, section: 0)]) + vm.checkNil() + + guard let showData = vm.favListingData?.showData else{return} + + for (i,element) in showData.enumerated(){ + if element.id == vm.webSeriesHindi[index].id{ + vm.favListingData?.showData?[i].isLiked = true + vm.favListingData?.showData?[i].likesCount! += 1 + webSeriesCV.reloadItems(at: [IndexPath(row: i, section: 0)]) + } + } + case false: + vm.webSeriesHindi[index].isLiked = false + vm.webSeriesHindi[index].likesCount! -= 1 + webSeriesHindiCV.reloadItems(at: [IndexPath(row: index, section: 0)]) + vm.checkNil() + + guard let showData = vm.favListingData?.showData else{return} + + for (i,element) in showData.enumerated(){ + if element.id == vm.webSeriesHindi[index].id{ + vm.favListingData?.showData?[i].isLiked = false + vm.favListingData?.showData?[i].likesCount! -= 1 + webSeriesCV.reloadItems(at: [IndexPath(row: i, section: 0)]) + } + } + + } + } + default: + break + + } + + print(index , type , isFav, isLike) } + + func updateFavLikes(type : FavCellCLick, index : Int){ switch vm.selectedCollection { @@ -428,24 +518,13 @@ extension MyListVC : ReloadSeriesFavLike{ if let categoryIds = data.bookmarkCategoryIDS { let components = categoryIds.components(separatedBy: ",") if isFav == true && (components.first == categoryID.toString() || components.last == categoryID.toString()){ - LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in if isDone{ vm.favListingData?.showData?.remove(at: index) -// vm.webSeriesHindi[index].markAsFavourite = false -// vm.webSeriesHindi[index].bookmarkCategoryIDS = "" webSeriesCV.reloadItems(at: [IndexPath(row: index, section: 0)]) } } } -// else{ -// LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in -// if isDone{ -// vm.webSeriesHindi[index].markAsFavourite = false -// vm.webSeriesHindi[index].bookmarkCategoryIDS = categoryID.toString() -// webSeriesHindiCV.reloadItems(at: [IndexPath(row: index, section: 0)]) -// } -// } -// } return } case .liked: @@ -478,7 +557,7 @@ extension MyListVC : ReloadSeriesFavLike{ if let categoryIds = data.bookmarkCategoryIDS { let components = categoryIds.components(separatedBy: ",") if isFav == true && (components.first == categoryID.toString() || components.last == categoryID.toString()){ - LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in if isDone{ vm.webSeriesHindi.remove(at: index) // vm.webSeriesHindi[index].markAsFavourite = false @@ -487,7 +566,7 @@ extension MyListVC : ReloadSeriesFavLike{ } } }else{ - LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in if isDone{ vm.webSeriesHindi[index].markAsFavourite = false vm.webSeriesHindi[index].bookmarkCategoryIDS = categoryID.toString() diff --git a/WOKA/Home/Home.storyboard b/WOKA/Home/Home.storyboard index bd98e4a..e50e460 100644 --- a/WOKA/Home/Home.storyboard +++ b/WOKA/Home/Home.storyboard @@ -1,6 +1,6 @@ - + @@ -26,7 +26,7 @@ - + @@ -73,20 +73,20 @@ - + - + - + - + - + - + - + - + - + @@ -959,13 +963,13 @@ - + - + - + @@ -990,13 +994,13 @@ - + - + - + @@ -1021,13 +1025,13 @@ - + - + - + @@ -1052,13 +1056,13 @@ - + - + - + @@ -1083,7 +1087,7 @@ - + @@ -1091,6 +1095,7 @@ + @@ -1116,12 +1121,16 @@ + + + + @@ -1132,6 +1141,7 @@ + @@ -1151,7 +1161,7 @@ - + @@ -1168,11 +1178,11 @@ - + - + @@ -1195,24 +1205,24 @@ - + - + - - - - - + + + + + - + - + @@ -1224,5 +1234,8 @@ + + + diff --git a/WOKA/Home/View/FavouriteCell.swift b/WOKA/Home/View/FavouriteCell.swift index f5fb803..f387a6c 100644 --- a/WOKA/Home/View/FavouriteCell.swift +++ b/WOKA/Home/View/FavouriteCell.swift @@ -56,19 +56,18 @@ class FavouriteCell: UICollectionViewCell { if let favourite = data.markAsFavourite{ switch favourite{ case true: - favBtnn.setImage(UIImage(systemName: "heart.fill"), for: .normal) + favBtnn.setImage(UIImage(named: "FavouriteAdd"), for: .normal) case false: - favBtnn.setImage(UIImage(systemName: "heart"), for: .normal) - + favBtnn.setImage(UIImage(named: "FavouriteRemove"), for: .normal) } } if let like = data.isLiked{ switch like{ case true: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup.fill"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeAdd"), for: .normal) case false: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeRemove"), for: .normal) } } } @@ -88,19 +87,18 @@ class FavouriteCell: UICollectionViewCell { if let favourite = data.markAsFavourite{ switch favourite{ case true: - favBtnn.setImage(UIImage(systemName: "heart.fill"), for: .normal) + favBtnn.setImage(UIImage(named: "FavouriteAdd"), for: .normal) case false: - favBtnn.setImage(UIImage(systemName: "heart"), for: .normal) - + favBtnn.setImage(UIImage(named: "FavouriteRemove"), for: .normal) } } if let like = data.isLiked{ switch like{ case true: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup.fill"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeAdd"), for: .normal) case false: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeRemove"), for: .normal) } } } diff --git a/WOKA/Home/View/FavouriteCell.xib b/WOKA/Home/View/FavouriteCell.xib index 2ff7247..625ab90 100644 --- a/WOKA/Home/View/FavouriteCell.xib +++ b/WOKA/Home/View/FavouriteCell.xib @@ -6,7 +6,6 @@ - @@ -31,7 +30,7 @@ - + @@ -40,64 +39,59 @@ - + - - + + - - + + - - - + - + - + @@ -131,21 +125,18 @@ - - - + + + - - - - + + + + - - - diff --git a/WOKA/Home/ViewModel/MyListVM.swift b/WOKA/Home/ViewModel/MyListVM.swift index 8d5a870..8ef0b59 100644 --- a/WOKA/Home/ViewModel/MyListVM.swift +++ b/WOKA/Home/ViewModel/MyListVM.swift @@ -28,6 +28,11 @@ class MyListVM{ var selectedCollection : CollectionSelectionMyList? func initView(){ + let color1 = #colorLiteral(red: 0.6745098039, green: 0.6235294118, blue: 0.1725490196, alpha: 1) + let color2 = #colorLiteral(red: 0.5450980392, green: 0.6745098039, blue: 0.1725490196, alpha: 1) + + vc.gradientView.applyGradient(colors: [color2, color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0)) + setupCell() Utilities.startProgressHUD() getFavouriteListing() @@ -75,6 +80,8 @@ class MyListVM{ self.refreshControl.endRefreshing() Utilities.dismissProgressHUD() self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + webSeriesHindi.removeAll() + favListingData = nil reloadCollections() checkNil() case 1: @@ -87,11 +94,18 @@ class MyListVM{ favListingData = data if var hindiData = favListingData?.showData{ - /* + + /* Taking out the hindi series , 1-> English , 18-> Hindi - And the saving it to hindi series + And the saving it to hindi series, also modify the bookmark category ids */ - webSeriesHindi = hindiData.compactMap { $0 }.filter { ($0.bookmarkCategoryIDS?.components(separatedBy: ",").first == "18" || $0.bookmarkCategoryIDS?.components(separatedBy: ",").last == "18") } + webSeriesHindi = hindiData.compactMap { $0 }.filter { + ($0.bookmarkCategoryIDS?.components(separatedBy: ",").first == "18" || $0.bookmarkCategoryIDS?.components(separatedBy: ",").last == "18") + }.map { element -> FavouriteListingDM.ResultData.ShowDatum in + var modifiedElement = element + modifiedElement.bookmarkCategoryIDS = "18" + return modifiedElement + } if let data = favListingData?.showData{ var indicesToRemove = [Int]() diff --git a/WOKA/Theme/Controller/MoreVC.swift b/WOKA/Theme/Controller/MoreVC.swift index 7de2164..50fb348 100644 --- a/WOKA/Theme/Controller/MoreVC.swift +++ b/WOKA/Theme/Controller/MoreVC.swift @@ -183,7 +183,7 @@ extension MoreVC : TableViewSRC{ guard let self = self else { return } currentTimePlayer = Int(CMTimeGetSeconds(time)) if let currentPlayingIndex = self.vm.currentIndexPlayingSong, - let cell = self.songTableView.cellForRow(at: IndexPath(row: vm.currentIndexPlayingSong ?? 0, section: 0)) as? SongListCell { + let cell = self.songTableView.cellForRow(at: IndexPath(row: currentPlayingIndex, section: 0)) as? SongListCell { cell.updateCurrentTime() } } diff --git a/WOKA/WebSeries/Controller/WebSeriesSeasonVC.swift b/WOKA/WebSeries/Controller/WebSeriesSeasonVC.swift index e036ad8..aa9e594 100644 --- a/WOKA/WebSeries/Controller/WebSeriesSeasonVC.swift +++ b/WOKA/WebSeries/Controller/WebSeriesSeasonVC.swift @@ -94,17 +94,6 @@ class WebSeriesSeasonVC: UIViewController { } JWPlayerManager.shared.presentPlayer(from: self, playerItems: playerItems, startIndex: 0, contentType: .trailer) - -// let seasonData = vm.seasonListingData.filter({$0.id == vm.episodeSelectedCateogory}).first -// if vm.categoryID == 1{ -// guard let englishData = seasonData?.seasonMoreDetails?.filter({$0.languageMasterID == 1}).first , let url = englishData.trailerHDURL , let title = englishData.title else{return} -// let playerItem = JwPlayerItemCreate(url: url, poster: seasonData?.thumbnailPath, titles: title) -// JWPlayerManager.shared.presentPlayer(from: self, playerItems: [playerItem], startIndex: 0, contentType: .trailer) -// }else if vm.categoryID == 18{ -// guard let hindiData = seasonData?.seasonMoreDetails?.filter({$0.languageMasterID == 2}).first , let url = hindiData.trailerHDURL , let title = hindiData.title else{return} -// let playerItem = JwPlayerItemCreate(url: url, poster: seasonData?.thumbnailPath, titles: title) -// JWPlayerManager.shared.presentPlayer(from: self, playerItems: [playerItem], startIndex: 0, contentType: .trailer) -// } } @IBAction func retryBtnTapped(_ sender: LocalisedElementsButton) { diff --git a/WOKA/WebSeries/Controller/WebSeriesVC.swift b/WOKA/WebSeries/Controller/WebSeriesVC.swift index dcbb8de..4162c08 100644 --- a/WOKA/WebSeries/Controller/WebSeriesVC.swift +++ b/WOKA/WebSeries/Controller/WebSeriesVC.swift @@ -8,7 +8,8 @@ import UIKit protocol ReloadSeriesFavLike{ - func updateRows(index : Int, type : FavCellCLick) + func updateRows(index : Int, type : FavCellCLick, isFav : Bool? , isLike : Bool? ) + } class WebSeriesVC: UIViewController { @@ -62,6 +63,11 @@ class WebSeriesVC: UIViewController { self.navigationController?.setColor(color: .black) } + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + vm.updateTableHeight() + } + // MARK: - Tap Handler @IBAction func playTrailer(_ sender: LocalisedElementsButton) { let item = JwPlayerItemCreate(url: vm.masilaUrl, poster: nil, titles: "Masila") @@ -111,7 +117,7 @@ extension WebSeriesVC : TableViewSRC{ if let categoryIds = data.favouriteCategoryIDS?.rawValue { let components = categoryIds.components(separatedBy: ",") if isFav == true && (components.first == categoryID.toString() || components.last == categoryID.toString()){ - LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in if isDone{ vm.showData[index].markAsFavourite = false vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue("") @@ -120,7 +126,7 @@ extension WebSeriesVC : TableViewSRC{ } } }else{ - LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in if isDone{ vm.showData[index].markAsFavourite = true vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString()) @@ -134,7 +140,7 @@ extension WebSeriesVC : TableViewSRC{ case .liked: guard let isLiked = data.isLiked ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return} if isLiked{ - LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, index: index, vc: self) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self) { [unowned self] isDone in if isDone{ vm.showData[index].isLiked = false vm.showData[index].likesCount! -= 1 @@ -142,7 +148,7 @@ extension WebSeriesVC : TableViewSRC{ } } }else{ - LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, index: index, vc: self){ [unowned self] isDone in + LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self){ [unowned self] isDone in if isDone{ vm.showData[index].isLiked = true vm.showData[index].likesCount! += 1 @@ -171,11 +177,38 @@ extension WebSeriesVC : TableViewSRC{ } extension WebSeriesVC : ReloadSeriesFavLike{ - func updateRows(index: Int, type: FavCellCLick) { - print(index , type) - updateFavLikes(type: type, index: index) - } + // if like or fav is done in webseriesseason vc, dont need to do api call in this screen. + func updateRows(index: Int, type: FavCellCLick, isFav: Bool?, isLike: Bool?) { + if let isFav{ + let categoryID = vm.categoryListingData[vm.dropDownModule.indexForSelectedRow ?? 0].id ?? 0 + switch isFav{ + case true: + vm.showData[index].markAsFavourite = true + vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString()) + showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) + case false: + vm.showData[index].markAsFavourite = false + vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue("") + showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) + } + K.GVar.reloadMyList = true + } + + if let isLike{ + switch isLike{ + case true: + vm.showData[index].isLiked = true + vm.showData[index].likesCount! += 1 + showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) + case false: + vm.showData[index].isLiked = false + vm.showData[index].likesCount! -= 1 + showListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) + } + K.GVar.reloadMyList = true + } + } } // MARK: - CollectionView Delegate and Data Source diff --git a/WOKA/WebSeries/LikeFavCommonFunc.swift b/WOKA/WebSeries/LikeFavCommonFunc.swift index 23fe902..b08de77 100644 --- a/WOKA/WebSeries/LikeFavCommonFunc.swift +++ b/WOKA/WebSeries/LikeFavCommonFunc.swift @@ -14,7 +14,7 @@ class LikeFavCommonFunc{ // MARK: - Like , unlike - func likePost(postID : Int, postType : Int, index : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ + func likePost(postID : Int, postType : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ Utilities.startProgressHUD() let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", "access-token": AuthFunc.shareInstance.getAccessToken()] @@ -45,7 +45,7 @@ class LikeFavCommonFunc{ } } - func unlikePost(postID : Int, postType : Int , index : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ + func unlikePost(postID : Int, postType : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ Utilities.startProgressHUD() let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", "access-token": AuthFunc.shareInstance.getAccessToken()] @@ -77,7 +77,7 @@ class LikeFavCommonFunc{ // MARK: - Remove Favourite - func removeFavourite(postID : Int, postType : Int, categoryID : Int, index : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ + func removeFavourite(postID : Int, postType : Int, categoryID : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ Utilities.startProgressHUD() let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", "access-token": AuthFunc.shareInstance.getAccessToken()] @@ -108,7 +108,7 @@ class LikeFavCommonFunc{ } } - func addFavourite(postID : Int, postType : Int, categoryID : Int, index : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ + func addFavourite(postID : Int, postType : Int, categoryID : Int, vc : UIViewController, onCompletion : @escaping (Bool) -> Void){ Utilities.startProgressHUD() let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", "access-token": AuthFunc.shareInstance.getAccessToken()] diff --git a/WOKA/WebSeries/View/WebSeriesCell.xib b/WOKA/WebSeries/View/WebSeriesCell.xib index a98ceab..1456d55 100644 --- a/WOKA/WebSeries/View/WebSeriesCell.xib +++ b/WOKA/WebSeries/View/WebSeriesCell.xib @@ -4,6 +4,7 @@ + @@ -41,15 +42,22 @@ - @@ -89,4 +97,9 @@ + + + + + diff --git a/WOKA/WebSeries/View/WebSeriesShowListingCell.swift b/WOKA/WebSeries/View/WebSeriesShowListingCell.swift index 7da4c1a..7f5fad1 100644 --- a/WOKA/WebSeries/View/WebSeriesShowListingCell.swift +++ b/WOKA/WebSeries/View/WebSeriesShowListingCell.swift @@ -48,9 +48,9 @@ class WebSeriesShowListingCell: UITableViewCell { if let like = data.isLiked{ switch like{ case true: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup.fill"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeAdd"), for: .normal) case false: - likeBtn.setImage(UIImage(systemName: "hand.thumbsup"), for: .normal) + likeBtn.setImage(UIImage(named: "LikeRemove"), for: .normal) } } @@ -58,17 +58,17 @@ class WebSeriesShowListingCell: UITableViewCell { if let categoryIds = data.favouriteCategoryIDS?.rawValue { // if string, it means category is selected for multiple language let components = categoryIds.components(separatedBy: ",") if favourite == true && (components.first == selectedCategory.toString() || components.last == selectedCategory.toString()){ - favBtn.setImage(UIImage(systemName: "heart.fill"), for: .normal) + favBtn.setImage(UIImage(named: "FavouriteAdd"), for: .normal) }else{ - favBtn.setImage(UIImage(systemName: "heart"), for: .normal) + favBtn.setImage(UIImage(named: "FavouriteRemove"), for: .normal) } return } if favourite == true && data.favouriteCategoryIDS?.intValue == selectedCategory{ - favBtn.setImage(UIImage(systemName: "heart.fill"), for: .normal) + favBtn.setImage(UIImage(named: "FavouriteAdd"), for: .normal) }else{ - favBtn.setImage(UIImage(systemName: "heart"), for: .normal) + favBtn.setImage(UIImage(named: "FavouriteRemove"), for: .normal) } // switch favourite{ // case true: diff --git a/WOKA/WebSeries/View/WebSeriesShowListingCell.xib b/WOKA/WebSeries/View/WebSeriesShowListingCell.xib index 336a46a..6cd4fdd 100644 --- a/WOKA/WebSeries/View/WebSeriesShowListingCell.xib +++ b/WOKA/WebSeries/View/WebSeriesShowListingCell.xib @@ -25,10 +25,10 @@ - + - + @@ -42,65 +42,60 @@ - - + + - - + + - - + + - - - - - - - - + - + @@ -144,10 +139,10 @@ - - - - + + + + diff --git a/WOKA/WebSeries/ViewModel/WebSeriesSeasonVM.swift b/WOKA/WebSeries/ViewModel/WebSeriesSeasonVM.swift index 5e03d56..ef034bf 100644 --- a/WOKA/WebSeries/ViewModel/WebSeriesSeasonVM.swift +++ b/WOKA/WebSeries/ViewModel/WebSeriesSeasonVM.swift @@ -32,31 +32,47 @@ class WebSeriesSeasonVM{ setShowData() vc.addView.addTapGesture { [weak self] in - - guard let self ,let indexSelected, let categoryID, let showData, let isFav = showData.markAsFavourite else{return} - vc.likeFavDelegate?.updateRows(index: indexSelected, type: .favourite) + guard let self ,let indexSelected, let categoryID, let showData, let showID = showData.id, let isFav = showData.markAsFavourite, let postType = showData.contentMoreDetails?.first?.postType else{return} if isFav { - self.showData?.markAsFavourite = false - self.showData?.favouriteCategoryIDS = ValueWrapper.stringValue("") + LikeFavCommonFunc.shareInstance.removeFavourite(postID: showID, postType: postType, categoryID: categoryID, vc: self.vc) { isDone in + self.showData?.markAsFavourite = false + self.showData?.favouriteCategoryIDS = ValueWrapper.stringValue("") + self.setShowData() + self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .favourite, isFav: false, isLike: nil) + K.GVar.reloadMyList = true + } }else{ - self.showData?.markAsFavourite = true - self.showData?.favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString()) + LikeFavCommonFunc.shareInstance.addFavourite(postID: showID, postType: postType, categoryID: categoryID, vc: self.vc) { isDone in + self.showData?.markAsFavourite = true + self.showData?.favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString()) + self.setShowData() + self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .favourite, isFav: true, isLike: nil) + K.GVar.reloadMyList = true + } } - setShowData() } + vc.likeView.addTapGesture { [weak self] in - guard let self ,let indexSelected, let showData, let isLiked = showData.isLiked else{return} - vc.likeFavDelegate?.updateRows(index: indexSelected, type: .liked) + guard let self ,let indexSelected, let showData, let showID = showData.id, let isLiked = showData.isLiked, let postType = showData.contentMoreDetails?.first?.postType else{return} + if isLiked{ - self.showData?.isLiked = false - self.showData?.likesCount! -= 1 + LikeFavCommonFunc.shareInstance.unlikePost(postID: showID, postType: postType, vc: self.vc) { isDone in + self.showData?.isLiked = false + self.showData?.likesCount! -= 1 + self.setShowData() + self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .liked, isFav: nil, isLike: false) + } }else{ - self.showData?.isLiked = true - self.showData?.likesCount! += 1 + LikeFavCommonFunc.shareInstance.likePost(postID: showID, postType: postType, vc: self.vc) { isDone in + self.showData?.isLiked = true + self.showData?.likesCount! += 1 + self.setShowData() + self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .liked, isFav: nil, isLike: true) + } } - setShowData() } + vc.shareView.addTapGesture { print("share") } diff --git a/WOKA/WebSeries/ViewModel/WebSeriesVM.swift b/WOKA/WebSeries/ViewModel/WebSeriesVM.swift index bb34803..7835bc3 100644 --- a/WOKA/WebSeries/ViewModel/WebSeriesVM.swift +++ b/WOKA/WebSeries/ViewModel/WebSeriesVM.swift @@ -24,12 +24,7 @@ class WebSeriesVM{ func initView(){ setupCell() - self.vc.tableHeight.constant = self.vc.showListingTableView.contentSize.height + 100 - self.vc.showListingTableView.layoutIfNeeded() - self.vc.tableHeight.constant = self.vc.showListingTableView.contentSize.height - startShimmer() - vc.scrollView.indicatorStyle = .white // or .white let color1 = #colorLiteral(red: 0.5921568627, green: 0.2588235294, blue: 0.8941176471, alpha: 1) @@ -73,6 +68,12 @@ class WebSeriesVM{ vc.showListingTableView.dataSource = vc.self } + func updateTableHeight(){ + self.vc.tableHeight.constant = self.vc.showListingTableView.contentSize.height + 100 + self.vc.showListingTableView.layoutIfNeeded() + self.vc.tableHeight.constant = self.vc.showListingTableView.contentSize.height + } + // MARK: - DropDown func initDropDown(){ diff --git a/WOKA/WebSeries/WebSeries.storyboard b/WOKA/WebSeries/WebSeries.storyboard index 024e1c6..2d6fa6b 100644 --- a/WOKA/WebSeries/WebSeries.storyboard +++ b/WOKA/WebSeries/WebSeries.storyboard @@ -434,7 +434,7 @@ - + @@ -445,7 +445,7 @@ - + @@ -475,7 +475,7 @@ - + @@ -486,7 +486,7 @@ - + @@ -518,7 +518,7 @@ - + @@ -529,7 +529,7 @@ - + @@ -1068,6 +1068,9 @@ + + +