This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A type-erased task that you can store in a collection | |
/// to allow you to cancel at a later date. | |
/// | |
/// Upon deinit of the task, the task will be cancelled | |
/// automatically. Similar to Combine's AnyCancellable. | |
final class AnyTask { | |
/// Call this cancellation block to cancel the task manually. | |
let cancel: () -> Void | |
/// Checks whether the task is cancelled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* MIT License | |
* | |
* Copyright (c) 2022 Albert Chang | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.foundation.layout.BoxWithConstraints | |
import androidx.compose.foundation.layout.BoxWithConstraintsScope | |
import androidx.compose.foundation.text.InlineTextContent | |
import androidx.compose.foundation.text.InternalFoundationTextApi | |
import androidx.compose.foundation.text.TextDelegate | |
import androidx.compose.material.LocalTextStyle | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.SuppressLint | |
import androidx.compose.animation.core.animateDpAsState | |
import androidx.compose.animation.core.animateFloatAsState | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.gestures.awaitFirstDown | |
import androidx.compose.foundation.gestures.forEachGesture | |
import androidx.compose.foundation.gestures.horizontalDrag | |
import androidx.compose.foundation.layout.Arrangement.spacedBy | |
import androidx.compose.foundation.layout.Box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. | |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
* | |
* This code is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License version 2 only, as | |
* published by the Free Software Foundation. Oracle designates this | |
* particular file as subject to the "Classpath" exception as provided | |
* by Oracle in the LICENSE file that accompanied this code. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Publisher { | |
func asResult() -> AnyPublisher<Result<Output, Failure>, Never> { | |
return map(Result.success) | |
.catch { Just(Result.failure($0)) } | |
.eraseToAnyPublisher() | |
} | |
} | |
extension Publisher { | |
func values<S, F: Error>() -> AnyPublisher<S, Never> where Output == Result<S, F>, Failure == Never { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
/*: | |
DateComponentsFormatter: A formatter that creates string representations of quantities of time. | |
*/ | |
let dateComponentsFormatter = DateComponentsFormatter() | |
/*: | |
A DateComponentsFormatter can be configured with an array of NSCalendarUnits. These components are then used in the output. |