You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
844 B
Kotlin
37 lines
844 B
Kotlin
4 years ago
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
|
||
|
package org.mozilla.fenix.components.tips
|
||
|
|
||
|
sealed class TipType {
|
||
|
data class Button(val text: String, val action: () -> Unit) : TipType()
|
||
|
}
|
||
|
|
||
|
open class Tip(
|
||
|
val type: TipType,
|
||
|
val identifier: String,
|
||
|
val title: String,
|
||
|
val description: String,
|
||
|
val learnMoreURL: String?
|
||
|
)
|
||
|
|
||
|
interface TipProvider {
|
||
|
val tip: Tip?
|
||
|
val shouldDisplay: Boolean
|
||
|
}
|
||
|
|
||
|
interface TipManager {
|
||
|
fun getTip(): Tip?
|
||
|
}
|
||
|
|
||
|
class FenixTipManager(
|
||
|
private val providers: List<TipProvider>
|
||
|
) : TipManager {
|
||
|
override fun getTip(): Tip? {
|
||
|
return providers
|
||
|
.firstOrNull { it.shouldDisplay }
|
||
|
?.tip
|
||
|
}
|
||
|
}
|