Skip to content

Commit

Permalink
Merge pull request #93 from cedricbahirwe/widget
Browse files Browse the repository at this point in the history
Minor Fixes
  • Loading branch information
cedricbahirwe authored Jun 3, 2023
2 parents 567ee17 + b965618 commit 784889b
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 118 deletions.
12 changes: 4 additions & 8 deletions Dialer/Dialer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
82D41FBD25D1C1FF00551D22 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82D41FBC25D1C1FF00551D22 /* Assets.xcassets */; };
82D41FC025D1C1FF00551D22 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82D41FBF25D1C1FF00551D22 /* Preview Assets.xcassets */; };
82D41FC325D1C1FF00551D22 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 82D41FC125D1C1FF00551D22 /* LaunchScreen.storyboard */; };
82D7C19B266D2031003E0E0E /* CTCarrierDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D7C19A266D2031003E0E0E /* CTCarrierDetector.swift */; };
82D7C1A7266D26E7003E0E0E /* Views+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82D7C1A6266D26E7003E0E0E /* Views+Extension.swift */; };
82E8E63B2676A7B300AB1723 /* ContactsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E8E63A2676A7B300AB1723 /* ContactsListView.swift */; };
82EEBCED26C12E2500B1720A /* DialerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82EEBCEC26C12E2500B1720A /* DialerTests.swift */; };
Expand Down Expand Up @@ -159,7 +158,6 @@
82D41FBF25D1C1FF00551D22 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
82D41FC225D1C1FF00551D22 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
82D41FC425D1C1FF00551D22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
82D7C19A266D2031003E0E0E /* CTCarrierDetector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CTCarrierDetector.swift; sourceTree = "<group>"; };
82D7C1A6266D26E7003E0E0E /* Views+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Views+Extension.swift"; sourceTree = "<group>"; };
82E8E63A2676A7B300AB1723 /* ContactsListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsListView.swift; sourceTree = "<group>"; };
82EEBCEA26C12E2500B1720A /* DialerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DialerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -392,7 +390,6 @@
82EEBCF426C1336000B1720A /* Utilities */ = {
isa = PBXGroup;
children = (
82D7C19A266D2031003E0E0E /* CTCarrierDetector.swift */,
CB895D772806FE84002AA0BE /* BiometricAuthenticator.swift */,
CB3B81E529ABD0D8001FAFF6 /* FirebaseManager.swift */,
CB1CC86B29C4524200FF2116 /* FirebaseCRUD.swift */,
Expand Down Expand Up @@ -686,7 +683,6 @@
CB18BD4529AE0C3200A7B45C /* FirebaseRemoteConfig.swift in Sources */,
CB7426BF2A05C05D00BE76DF /* DeviceAccount.swift in Sources */,
82D41FB925D1C1FE00551D22 /* SceneDelegate.swift in Sources */,
82D7C19B266D2031003E0E0E /* CTCarrierDetector.swift in Sources */,
825F996626720B46009E4A7B /* ContactsFetcher.swift in Sources */,
82D7C1A7266D26E7003E0E0E /* Views+Extension.swift in Sources */,
CB393A2928120A73009CA95E /* Binding+Extension.swift in Sources */,
Expand Down Expand Up @@ -953,7 +949,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.7.2;
MARKETING_VERSION = 4.7.3;
PRODUCT_BUNDLE_IDENTIFIER = com.abc.incs.cedricbahirwe.Dialit;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -980,7 +976,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.7.2;
MARKETING_VERSION = 4.7.3;
PRODUCT_BUNDLE_IDENTIFIER = com.abc.incs.cedricbahirwe.Dialit;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1114,7 +1110,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.7.2;
MARKETING_VERSION = 4.7.3;
PRODUCT_BUNDLE_IDENTIFIER = com.abc.incs.cedricbahirwe.Dialit.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1240,7 +1236,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.7.2;
MARKETING_VERSION = 4.7.3;
PRODUCT_BUNDLE_IDENTIFIER = com.abc.incs.cedricbahirwe.Dialit.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion Dialer/Dialer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let filePath = Bundle.main.path(forResource: fileName, ofType: "plist"),
let options = FirebaseOptions(contentsOfFile: filePath)
else {
debugPrint("Could not find Firebase config file")
Log.debug("Could not find Firebase config file")
return
}

Expand Down
13 changes: 0 additions & 13 deletions Dialer/Dialer/Extensions/Views+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

import SwiftUI

struct MTNDisabling: ViewModifier {
func body(content: Content) -> some View {
content
.disabled(CTCarrierDetector.shared.cellularProvider().status == false)
}
}

struct BiometricsAccessibility: ViewModifier {
private let biometrics = BiometricsAuth.shared
var onEvaluation: (Bool) -> Void
Expand Down Expand Up @@ -47,12 +40,6 @@ extension View {
ModifiedContent(content: self, modifier: BiometricsAccessibility(onEvaluation: onEvaluation))
}

/// Disable access if `Mtn` sim card is not detected
/// - Returns: a disabled view if mtn card is not detected (no interaction).
func momoDisability() -> some View {
ModifiedContent(content: self, modifier: MTNDisabling())
}

/// Dismiss keyboard
func hideKeyboard() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
Expand Down
4 changes: 2 additions & 2 deletions Dialer/Dialer/Services/FirebaseTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class FirebaseTracker {
func stopSession(for screen: ScreenName) {
/// 1. get the start date of the session
guard let start = sessions[screen] else {
debugPrint("could not get start time of the session for given screen: \(screen.rawValue)")
Log.debug("could not get start time of the session for given screen: \(screen.rawValue)")
return
}
/// 2. get the session length and format it as string and miliseconds
let interval = start.timeIntervalSinceNow * (-1)
let formatted = interval.formattedString()
let seconds: Int = Int(interval)
debugPrint("screen session time for: \(screen.rawValue) is \(formatted) seconds: \(seconds)")
Log.debug("screen session time for: \(screen.rawValue) is \(formatted) seconds: \(seconds)")

/// 3. log event on firebase
// screen_session_length - Name of the Event
Expand Down
9 changes: 7 additions & 2 deletions Dialer/Dialer/Services/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ enum Log {
static func add(_ message: StaticString, file: String = #file, dso: UnsafeRawPointer? = #dsohandle, log: OSLog = .default, type: OSLogType = .default, _ args: CVarArg...) {
// 1. log the message using OSLog
os_log(message, dso: dso, log: log, type: type, args)
debugPrint(message, args)
let filename = String(file.split(separator: "/").last ?? "")
let formatter = DateFormatter(format: "MM/dd/yyyy HH:mm")
let logs: [String : Any] = [
"date": formatter.string(from: Date()),
"message": "\(message)",
"args:": "\(args)",
"args": "\(args)",
"file": filename
]
// 2. log an event depending on
let logType: LogEvent = type == .error ? .error : .debugInfo
Tracker.shared.logEvent(name: logType, parameters: logs)
}

static func debug(_ items: Any...) {
#if DEBUG
debugPrint(items)
#endif
}
}
27 changes: 0 additions & 27 deletions Dialer/Dialer/Utilities/CTCarrierDetector.swift

This file was deleted.

10 changes: 3 additions & 7 deletions Dialer/Dialer/Utilities/DialerLocalNotificationCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class DialerNotificationCenter: NSObject {
try await createNotification(dailyNotification, repeats: true)
DialerStorage.shared.setDailyNotificationStatus(to: true)
} catch {
debugPrint("Issue with notification", error.localizedDescription)
Log.debug("Issue with notification", error.localizedDescription)
}
}
}
Expand All @@ -53,7 +53,6 @@ final class DialerNotificationCenter: NSObject {
// MARK: - Helper Methods
private extension DialerNotificationCenter {
func isNotificationAuthorized() async throws -> Bool {
debugPrint(#function)
do {
return try await notificationCenter.requestAuthorization(options: [.alert, .sound])
} catch {
Expand All @@ -63,7 +62,6 @@ private extension DialerNotificationCenter {
}

func createNotification(_ notification: AppNotification, repeats: Bool) async throws {
debugPrint(#function)
guard try await isNotificationAuthorized() else { return }

let content = UNMutableNotificationContent()
Expand All @@ -84,26 +82,24 @@ private extension DialerNotificationCenter {
do {
try await notificationCenter.add(request)
} catch {
debugPrint("Unable to add notification: ", error.localizedDescription)
Log.debug("Unable to add notification: ", error.localizedDescription)
throw NotificationError.notAdded
}
}
}

extension DialerNotificationCenter {
func deleteNotifications() {
debugPrint(#function)
notificationCenter.removeAllPendingNotificationRequests()
DialerStorage.shared.setDailyNotificationStatus(to: false)
}

///Prints to console schduled notifications
func printNotifications() {
debugPrint(#function)
Task {
let pendingNotifs = await notificationCenter.pendingNotificationRequests()

debugPrint("Pending Notifications Count: ", pendingNotifs.count)
Log.debug("Pending Notifications Count: ", pendingNotifs.count)

}
}
Expand Down
10 changes: 5 additions & 5 deletions Dialer/Dialer/Utilities/FirebaseCRUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension FirebaseCRUD {
}
}
} catch {
debugPrint("Could not save \(type(of: element)): \(error.localizedDescription).")
Log.debug("Could not save \(type(of: element)): \(error.localizedDescription).")
continuation.resume(throwing: error)
}
}
Expand All @@ -57,7 +57,7 @@ extension FirebaseCRUD {

return await getAllWithQuery(querySnapshot)
} catch {
debugPrint("Can not get \(type(of: Merchant.self)) Error: \(error).")
Log.debug("Can not get \(type(of: Merchant.self)) Error: \(error).")
return []
}
}
Expand All @@ -67,7 +67,7 @@ extension FirebaseCRUD {
do {
return try document.data(as: T.self)
} catch {
debugPrint("Firestore Decoding error: ", error, querySnapshot.documents.forEach { print($0.data()) } )
Log.debug("Firestore Decoding error: ", error, querySnapshot.documents.forEach { print($0.data()) } )
return nil
}
}
Expand All @@ -85,7 +85,7 @@ extension FirebaseCRUD {

return item
} catch {
debugPrint("Error getting \(T.self): \(error)")
Log.debug("Error getting \(T.self): \(error)")
return nil
}
}
Expand All @@ -109,7 +109,7 @@ extension FirebaseCRUD {

continuation.resume(returning: true)
} catch {
debugPrint("Error updating Merchant: \(error)")
Log.debug("Error updating Merchant: \(error)")
continuation.resume(throwing: error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Dialer/Dialer/Utilities/FirebaseManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension FirebaseManager: MerchantProtocol {
return await getAllWithQuery(querySnapshot)

} catch {
debugPrint("Can not get \(type(of: Merchant.self)), Error: \(error).")
Log.debug("Can not get \(type(of: Merchant.self)), Error: \(error).")
Tracker.shared.logError(error: error)
return []
}
Expand Down
11 changes: 3 additions & 8 deletions Dialer/Dialer/Utilities/FirebaseRemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ extension FirebaseRemoteConfig: RemoteConfigsProtocol {
do {
let status = try await firebaseRemoteConfig.fetch(withExpirationDuration: fetchTimeout)
if status == .success {
debugPrint("Remote config fetched!")
let isActivated = try await firebaseRemoteConfig.activate()
if isActivated {
debugPrint("Remote Config Activated")
} else {
debugPrint("Remote Config Not Activated")
}
_ = try await firebaseRemoteConfig.activate()

}
} catch {
debugPrint("Error occured \(error.localizedDescription)")
Log.debug("Error occured \(error.localizedDescription)")
}
}

Expand Down
6 changes: 3 additions & 3 deletions Dialer/Dialer/View Models/LocalStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private extension DialerStorage {
do {
return try JSONDecoder().decode(type, from: data)
} catch let error {
debugPrint("Couldn't decode the data of type \(type): ", error.localizedDescription)
Log.debug("Couldn't decode the data of type \(type): ", error.localizedDescription)
}
return nil
}
Expand All @@ -158,7 +158,7 @@ private extension DialerStorage {
do {
return try Firestore.Decoder().decode(type, from: dictionary)
} catch let error {
debugPrint("Couldn't decode the firebase data of type \(type): ", error)
Log.debug("Couldn't decode the firebase data of type \(type): ", error)
}
return nil
}
Expand All @@ -171,7 +171,7 @@ private extension DialerStorage {
do {
return try JSONDecoder().decode(type, from: data)
} catch let error {
debugPrint("Couldn't decode the array of type \(type): ", error.localizedDescription)
Log.debug("Couldn't decode the array of type \(type): ", error.localizedDescription)
}
return []
}
Expand Down
40 changes: 1 addition & 39 deletions Dialer/Dialer/Views/DashBoardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ struct DashBoardView: View {
@State private var presentQuickDial = false
@State private var presentTransferView = false
@State private var showPurchaseSheet = false
@State private var showMerchantsList = false

private let checkCellularProvider = CTCarrierDetector.shared.cellularProvider()


var body: some View {
ZStack(alignment: .bottom) {
VStack {
Expand All @@ -31,7 +28,6 @@ struct DashBoardView: View {
DashItemView(
title: "Buy airtime",
icon: "wallet.pass")
.momoDisability()
.onTapGesture {
withAnimation {
showPurchaseSheet = true
Expand Down Expand Up @@ -79,20 +75,6 @@ struct DashBoardView: View {

Spacer()

if checkCellularProvider.status == false {
HStack {
Text("Sim card is required to unlock all the features.")
.font(.system(size: 20, weight: .semibold, design: .rounded))
.foregroundColor(.red)
.lineLimit(1)
.minimumScaleFactor(0.6)
}
.frame(maxWidth: .infinity)
.padding()
.background(.ultraThickMaterial)
.hidden()
}

bottomBarView
}
.blur(radius: showPurchaseSheet ? 3 : 0)
Expand Down Expand Up @@ -169,29 +151,9 @@ extension DashBoardView {
}

Spacer(minLength: 5)

Label {
Text(LocalizedStringKey(checkCellularProvider.message))
.font(.system(.body, design: .rounded)
.weight(.medium))
.multilineTextAlignment(.leading)
} icon: {
Image(systemName: checkCellularProvider.status ? "chart.bar.fill" : "chart.bar")
}
.foregroundColor(checkCellularProvider.status ? .main : .red)
.padding(10)
.background(Color.white)
.cornerRadius(10)
.onTapGesture(count: 3) {
guard AppConfiguration.isDebug else { return }
showMerchantsList = true
}
}
.padding(.horizontal)
.padding(.bottom, 8)
.fullScreenCover(isPresented: $showMerchantsList) {
MerchantsListView()
}
}
}

Expand Down
Loading

0 comments on commit 784889b

Please sign in to comment.