Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.3 kB
2
Indexable
Never
    
    @objc private func goToMissionInProgress() {
        let missionInProgressVC = MissionInProgressViewController()
        let sheetSizes : [SheetSize] = [.fixed(510), .marginFromTop(60)]
        
        let options = SheetOptions(
            shrinkPresentingViewController: false
        )

        let sheetController = SheetViewController(controller: missionInProgressVC, sizes: sheetSizes, options: options)
        sheetController.cornerRadius = 12
        sheetController.gripSize = CGSize(width: 50, height: 4)

        present(sheetController, animated: true)
    }
    
    @objc private func goToDailyProgress() {
        let vc = DailyGoalViewController()
        
        var sheetSizes : [SheetSize] = [.fixed(520), .fixed(650)]
        
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd"
        formatter.timeZone = TimeZone(identifier: "UTC")
        let yesterdayString = formatter.string(from: Date().dayBefore)
        
        if StorageService.shared.getFailedStreakAchievementDate() != yesterdayString {
            sheetSizes = [.fixed(560), .fixed(680)]
        }
        
        vc.sourcePage = .home
        
        var options = SheetOptions()
        options.shouldExtendBackground = true
        options.shrinkPresentingViewController = false
        
        let sheetController = SheetViewController(controller: vc, sizes: sheetSizes, options: options)
        sheetController.cornerRadius = 12
        sheetController.gripSize = CGSize(width: 50, height: 4)
        sheetController.allowPullingPastMaxHeight = false
        
        sheetController.didDismiss = { _ in
            NotificationCenter.default.post(name: Notification.Name.DailyGoal.hideNewBadge, object: nil)
            NotificationCenter.default.post(name: Notification.Name.Coachmark.removeCoachmark, object: nil)
        }
        
        present(sheetController, animated: true)
    }

        NotificationCenter.default.addObserver(self, selector: #selector(self.goToMissionInProgress), name: Notification.Name.Navigation.missionInProgressBottomModal, object: nil)
        
        NotificationCenter.default.addObserver(self, selector: #selector(self.goToDailyProgress), name: Notification.Name.Navigation.dailyProgress, object: nil)