Skip to content

Commit

Permalink
Merge branch 'release/cert_record_load'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Loiselle authored and Sean Loiselle committed Aug 23, 2021
2 parents c78101e + a91c822 commit aa9afd7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
8 changes: 4 additions & 4 deletions bedside-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "bedside-ios/Bedside.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"bedside-ios/Preview Content\"";
DEVELOPMENT_TEAM = EUY77Y4C9L;
ENABLE_PREVIEWS = YES;
Expand All @@ -820,7 +820,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.9;
MARKETING_VERSION = 1.0.10;
PRODUCT_BUNDLE_IDENTIFIER = org.simpl.bedside;
PRODUCT_NAME = Bedside;
SWIFT_VERSION = 5.0;
Expand All @@ -835,7 +835,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "bedside-ios/Bedside.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"bedside-ios/Preview Content\"";
DEVELOPMENT_TEAM = EUY77Y4C9L;
ENABLE_PREVIEWS = YES;
Expand All @@ -844,7 +844,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.9;
MARKETING_VERSION = 1.0.10;
PRODUCT_BUNDLE_IDENTIFIER = org.simpl.bedside;
PRODUCT_NAME = Bedside;
SWIFT_VERSION = 5.0;
Expand Down
41 changes: 21 additions & 20 deletions bedside-ios/Navigation/Verify/CertRecordListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,33 @@ struct CertRecordListView: View {
}

var body: some View {
let certifiedRecords = viewModel.certified

let notCertified = viewModel.notCertified

return List {
if !certifiedRecords.isEmpty {
Section(header: CertifiedHeaderView()) {
ForEach(certifiedRecords) { certRecord in
NavigationLink(destination: CertRecordDetailView(certRecord: certRecord)) {
CertRecordRowView(certificationRecord: certRecord)
LoadingView(isShowing: $viewModel.loading) {
List {
let certifiedRecords = viewModel.certified
let notCertified = viewModel.notCertified
if !certifiedRecords.isEmpty {
Section(header: CertifiedHeaderView()) {
ForEach(certifiedRecords) { certRecord in
NavigationLink(destination: CertRecordDetailView(certRecord: certRecord)) {
CertRecordRowView(certificationRecord: certRecord)
}
}
}
}
}

if !notCertified.isEmpty {
Section(header:InProgressHeaderView()) {
ForEach(notCertified) {
certRecord in
NavigationLink(destination: CertRecordDetailView(certRecord: certRecord)) {
CertRecordRowView(certificationRecord: certRecord)
if !notCertified.isEmpty {
Section(header:InProgressHeaderView()) {
ForEach(notCertified) {
certRecord in
NavigationLink(destination: CertRecordDetailView(certRecord: certRecord)) {
CertRecordRowView(certificationRecord: certRecord)
}
}
}
}
}.onAppear {
UITableViewHeaderFooterView.appearance().tintColor = UIColor.clear
}
}.onAppear {
UITableViewHeaderFooterView.appearance().tintColor = UIColor.clear
}
}
}
Expand All @@ -171,4 +171,5 @@ struct CertifiedHeaderView: View {
}
}
}


4 changes: 3 additions & 1 deletion bedside-ios/Utils/CertRecordAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class CertRecordAPI {
if let next = result?.data?.listCertificationRecords?.nextToken {
self.getCertRecords(subjectId: subjectId, nextToken: next, callback: callback, certRecordList: certRecords)
}
callback(.success(certRecords))
else {
callback(.success(certRecords))
}
} else {
callback(.failure(CertRecordAPIError.MappingError))
}
Expand Down
17 changes: 17 additions & 0 deletions bedside-ios/Utils/CertRecordViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class CertRecordViewModel : ObservableObject {
@Published var certified: [CertificationRecord] = []
@Published var notCertified: [CertificationRecord] = []
@Published var showEmptyView: Bool = true
@Published var loading: Bool = false

let certRecordApi = CertRecordAPI()

private var cancellableSet : Set<AnyCancellable> = []

Expand All @@ -36,4 +39,18 @@ class CertRecordViewModel : ObservableObject {
.assign(to: \.showEmptyView, on: self)
.store(in: &cancellableSet)
}

func fetchCertRecords(user: User) {
self.loading = true
certRecordApi.getCertRecords(subjectId:user.id) {
result in
self.loading = false
switch result {
case .success(let certRecords):
self.allCertificationRecords = certRecords
case .failure(let error):
print("Error fetching certRecords: \(error)")
}
}
}
}
20 changes: 4 additions & 16 deletions bedside-ios/Utils/UserLoginState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class UserLoginState: ObservableObject {
@Published var ratersViewModel: RatersViewModel = RatersViewModel()
@Published var procedureSelectViewModel: ProcedureSelectViewModel = ProcedureSelectViewModel()


let certRecordApi = CertRecordAPI()

//TODO: have intermediate states for loading user data to display intermediate UIs
func setIsSignedIn(userState: UserState) {
switch (userState) {
Expand Down Expand Up @@ -107,24 +104,15 @@ class UserLoginState: ObservableObject {
self.ratersViewModel.fetchRaters(orgId: user.orgId!)
}

func fetchCertRecords(user: User){
self.certRecordViewModel.fetchCertRecords(user: user)
}

func fetchCurrentUserCertRecords() {
guard let currentUser = self.currentUser else { return }
fetchCertRecords(user: currentUser)
}

func fetchCertRecords(user: User) {

certRecordApi.getCertRecords(subjectId:user.id) {
result in
switch result {
case .success(let certRecords):
self.certRecordViewModel.allCertificationRecords = certRecords
case .failure(let error):
print("Error fetching certRecords: \(error)")
}
}
}

func fetchOrganizationInfo(orgId: String) {

for org in self.organizations {
Expand Down

0 comments on commit aa9afd7

Please sign in to comment.