Skip to content

Commit

Permalink
feat:search for apps through app id or package name
Browse files Browse the repository at this point in the history
  • Loading branch information
iHTCboy committed Apr 25, 2023
1 parent 511b08f commit 14284bf
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
14 changes: 6 additions & 8 deletions iAppStore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@
CODE_SIGN_ENTITLEMENTS = iAppStore/iAppStore.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023.04.03;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2023.04.25;
DEVELOPMENT_ASSET_PATHS = "\"iAppStore/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand All @@ -664,11 +664,10 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iAppStore;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -685,8 +684,8 @@
CODE_SIGN_ENTITLEMENTS = iAppStore/iAppStore.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023.04.03;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2023.04.25;
DEVELOPMENT_ASSET_PATHS = "\"iAppStore/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand All @@ -705,11 +704,10 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iAppStore;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
6 changes: 4 additions & 2 deletions iAppStore/Network/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public struct APIService {
newFreeApplications(cid: String, country: String, limit: Int),
newPaidApplications(cid: String, country: String, limit: Int),
searchApp(word: String, country: String, limit: Int),
lookupApp(appid: String, country: String)
lookupApp(appid: String, country: String),
lookupBundleId(appid: String, country: String)

func url() -> String {
let url = APIService.shared.baseURL
Expand Down Expand Up @@ -61,6 +62,8 @@ public struct APIService {
return url + "search?term=\(word)&country=\(country)&limit=\(limit)&entity=software"
case .lookupApp(appid: let appid, country: let country):
return url + "\(country)/lookup?id=\(appid)"
case .lookupBundleId(appid: let appid, country: let country):
return url + "\(country)/lookup?bundleId=\(appid)"
}
}
}
Expand All @@ -83,7 +86,6 @@ public struct APIService {
debugPrint(components.url!)
var request = URLRequest(url: components.url!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 60.0)
request.httpMethod = "POST"
request.setValue("iAppStore/1.0 Mobile/15E148 Safari/604.1", forHTTPHeaderField: "User-Agent")
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
guard let data = data else {
DispatchQueue.main.async {
Expand Down
2 changes: 1 addition & 1 deletion iAppStore/Shared/UI/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct LoadingView: View {

var animateText: some View {
HStack(spacing: 1) {
ForEach(loadingText.indices) { index in
ForEach(loadingText.indices, id: \.self) { index in
Text(loadingText[index])
.font(.headline)
.fontWeight(.heavy)
Expand Down
22 changes: 22 additions & 0 deletions iAppStore/ViewModels/AppDetailModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ class AppDetailModel: ObservableObject {
if appId != nil {
self.app = response.results.first
}
if let word = keyWord {
self.lookupBundleId(word: word, regionId: regionId)
}
case .failure(_):
break
}
}
}

/// search bundleId
func lookupBundleId(word: String, regionId: String) {
guard let bundleId = word.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
return
}

let endpoint = APIService.Endpoint.lookupBundleId(appid: bundleId, country: regionId)
APIService.shared.POST(endpoint: endpoint, params: nil) { (result: Result<AppDetailM, APIService.APIError>) in
switch result {
case let .success(response):
if let app = response.results.first {
self.results.insert(app, at: 0)
}
case .failure(_):
break
}
Expand Down
2 changes: 1 addition & 1 deletion iAppStore/components/rankLists/AppDetailContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ struct AppDetailScreenShotView: View {
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack() {
ForEach(0..<(screenshotUrls ?? [String]()).count) { index in
ForEach(0..<(screenshotUrls ?? [String]()).count, id: \.self) { index in
let url = screenshotUrls![index]
Button(action: {
selectedImgUrl = url.imageAppleScale()
Expand Down
6 changes: 3 additions & 3 deletions iAppStore/components/rankLists/RankSortView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ extension RankSortView {

var rankContent: some View {
ScrollView {
ForEach(0..<TSMGConstants.rankingTypeLists.count) { index in
ForEach(0..<TSMGConstants.rankingTypeLists.count, id: \.self) { index in
buildSortListRow(index: index)
}
}
}

var categoryContent: some View {
ScrollView {
ForEach(0..<TSMGConstants.categoryTypeLists.count) {index in
ForEach(0..<TSMGConstants.categoryTypeLists.count, id: \.self) {index in
buildSortListRow(index: index)
}
}
}

var regionContent: some View {
ScrollView {
ForEach(0..<TSMGConstants.regionTypeLists.count) {index in
ForEach(0..<TSMGConstants.regionTypeLists.count, id: \.self) {index in
buildSortListRow(index: index)
}
}
Expand Down
2 changes: 1 addition & 1 deletion iAppStore/components/search/SearchHome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct SearchFilterView: View {
Divider()

ScrollView {
ForEach(0..<TSMGConstants.regionTypeLists.count){index in
ForEach(0..<TSMGConstants.regionTypeLists.count, id: \.self){index in
HStack{
let type = TSMGConstants.regionTypeLists[index]
if type == regionName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extension SubscriptionAddView {

var regionExpandView: some View {
ScrollView {
ForEach(0..<TSMGConstants.regionTypeLists.count){index in
ForEach(0..<TSMGConstants.regionTypeLists.count, id: \.self){index in
HStack{
let type = TSMGConstants.regionTypeLists[index]
if type == regionName {
Expand Down
2 changes: 1 addition & 1 deletion iAppStore/iAppStoreApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct TabbarView: View {
self.tabbarItem(text: "订阅", image: "checkmark.seal.fill")
}.tag(Tab.subscription)
SettingHome().tabItem{
self.tabbarItem(text: "设置", image: "heart.circle")
self.tabbarItem(text: "设置", image: "gearshape")
}.tag(Tab.setting)
}
}
Expand Down

0 comments on commit 14284bf

Please sign in to comment.