Package-level declarations

Types

Link copied to clipboard
internal class AndroidImageSaver(val mediaStoreGateway: MediaStoreGateway, val dispatchersProvider: DispatchersProvider) : ImageSaver

Coordinates AndroidImageSaver behavior in the SDAI presentation layer.

Link copied to clipboard
internal class AndroidImageSharer(val context: Context, val fileProviderDescriptor: FileProviderDescriptor, val dispatchersProvider: DispatchersProvider, val base64ToBitmapConverter: Base64ToBitmapConverter) : ImageSharer, FileSavableExporter.BmpToFile

Coordinates AndroidImageSharer behavior in the SDAI presentation layer.

Link copied to clipboard
interface ImageSaver

Defines the ImageSaver contract for the SDAI presentation layer.

Link copied to clipboard
sealed interface ImageSaveResult

Defines the ImageSaveResult contract for the SDAI presentation layer.

Link copied to clipboard
interface ImageSharer

Defines the ImageSharer contract for the SDAI presentation layer.

Link copied to clipboard
sealed interface ImageShareResult

Defines the ImageShareResult contract for the SDAI presentation layer.

Link copied to clipboard
private class IosImageSaver : ImageSaver

Coordinates IosImageSaver behavior in the SDAI presentation layer.

Link copied to clipboard
private class IosImageSharer : ImageSharer

Coordinates IosImageSharer behavior in the SDAI presentation layer.

Link copied to clipboard
private data class PendingGeneration(val state: TextToImageState, val payload: TextToImagePayload)
Link copied to clipboard
internal data class StableDiffusionSamplersKey(val serverUrl: String, val demoMode: Boolean)

Carries StableDiffusionSamplersKey data through the SDAI presentation layer.

Link copied to clipboard
internal class TextToImageActionHandler(val dispatchersProvider: DispatchersProvider, val textToImageUseCase: TextToImageUseCase, val saveGenerationResultUseCase: SaveGenerationResultUseCase, val saveLastResultToCacheUseCase: SaveLastResultToCacheUseCase, val interruptGenerationUseCase: InterruptGenerationUseCase, val preferenceManager: PreferenceManager, val backgroundTaskManager: BackgroundTaskManager, val backgroundWorkObserver: BackgroundWorkObserver, val wakeLockInterActor: WakeLockInterActor, val platformServices: GenerationPlatformServices, val buildInfoProvider: BuildInfoProvider, val dimensionValidator: DimensionValidator, val localGenerationBenchmarkGateProvider: () -> LocalGenerationBenchmarkGate, val imageSaver: ImageSaver, val imageSharer: ImageSharer, val router: TextToImageRouter, val currentState: () -> TextToImageState, val emitState: (TextToImageState) -> Unit, val updateState: ((TextToImageState) -> TextToImageState) -> Unit, val launch: ViewModelLauncher, val onError: (Throwable) -> Unit)

Coordinates TextToImageActionHandler behavior in the SDAI presentation layer.

Link copied to clipboard
sealed interface TextToImageIntent : MviIntent

User actions and form updates emitted by the txt2img screen.

Link copied to clipboard
internal class TextToImageIntentProcessor(val router: TextToImageRouter, val updateState: ((TextToImageState) -> TextToImageState) -> Unit, val generate: () -> Unit, val cancelGeneration: () -> Unit, val saveImage: (String) -> Unit, val shareImage: (String) -> Unit, val saveGenerationResults: (List<AiGenerationResult>) -> Unit, val viewGenerationResult: (AiGenerationResult) -> Unit, val reportGenerationResult: (AiGenerationResult) -> Unit, val applyGenerationResult: (AiGenerationResult) -> Unit)

Applies synchronous txt2img UI intents.

Link copied to clipboard
private sealed interface TextToImagePanel
Link copied to clipboard
data class TextToImageState(val loadingConfiguration: Boolean = true, val generating: Boolean = false, val savingImage: Boolean = false, val sharingImage: Boolean = false, val promptValidationError: UiText? = null, val error: UiText? = null, val message: UiText? = null, val screenModal: GenerationModal = GenerationModal.None, val results: List<AiGenerationResult> = emptyList(), val editTag: PromptTagEditRequest? = null, val onBoardingDemo: Boolean = false, val platform: Platform = Platform.ANDROID, val mode: ServerSource = ServerSource.AUTOMATIC1111, val advancedToggleButtonVisible: Boolean = true, val advancedOptionsVisible: Boolean = false, val formPromptTaggedInput: Boolean = false, val prompt: String = "", val negativePrompt: String = "", val width: String = DEFAULT_SIZE.toString(), val height: String = DEFAULT_SIZE.toString(), val samplingSteps: Int = 20, val cfgScale: Float = 7.0f, val restoreFaces: Boolean = false, val seed: String = "", val subSeed: String = "", val subSeedStrength: Float = 0.0f, val selectedSampler: String = "", val selectedScheduler: Scheduler = Scheduler.AUTOMATIC, val availableForgeModules: List<ForgeModule> = emptyList(), val selectedForgeModules: List<ForgeModule> = emptyList(), val availableSamplers: List<String> = emptyList(), val selectedStylePreset: StabilityAiStylePreset = StabilityAiStylePreset.NONE, val selectedClipGuidancePreset: StabilityAiClipGuidance = StabilityAiClipGuidance.NONE, val openAiModel: OpenAiModel = OpenAiModel.default, val openAiSize: OpenAiSize = OpenAiSize.W1024_H1024, val openAiQuality: OpenAiQuality = OpenAiQuality.AUTO, val falAiModel: FalAiModel = FalAiModel.defaultTextToImage, val falAiImageSize: FalAiImageSize = FalAiImageSize.default, val falAiAcceleration: FalAiAcceleration = FalAiAcceleration.default, val falAiSyncMode: Boolean = false, val sdxlBackend: SdxlBackend = SdxlBackend.AUTO, val bonsaiBackend: BonsaiBackend = BonsaiBackend.AUTO, val bonsaiBackendSelectionVisible: Boolean = false, val arliAiModels: List<String> = emptyList(), val arliAiModel: String = "", val widthValidationError: UiText? = null, val heightValidationError: UiText? = null, val nsfw: Boolean = false, val batchCount: Int = 1, val hires: HiresConfig = HiresConfig.DISABLED, val aDetailer: ADetailerConfig = ADetailerConfig.DISABLED, val aDetailerAvailable: Boolean = false, val aDetailerRefreshing: Boolean = false) : MviState, GenerationInputFormState

Complete render state for txt2img.

Link copied to clipboard
data class TextToImageStrings(val title: String = Localization.string("title_text_to_image"), val prompt: String = Localization.string("hint_prompt"), val negativePrompt: String = Localization.string("hint_prompt_negative"), val width: String = Localization.string("width"), val height: String = Localization.string("height"), val steps: String = Localization.string("gallery_info_field_sampling_steps"), val cfgScale: String = Localization.string("gallery_info_field_cfg"), val batch: String = Localization.string("hint_batch_tag"), val generate: String = Localization.string("action_generate"), val generating: String = Localization.string("notification_running_title"), val save: String = Localization.string("action_save"), val savingImage: String = Localization.string("message_image_saving"), val share: String = Localization.string("action_share_prompt"), val sharingImage: String = Localization.string("message_image_sharing"), val configureProvider: String = Localization.string("settings_item_config"), val sourceUnavailable: String = Localization.string("error_source_android_only"), val results: String = Localization.string("title_generation_results"), val imageUnavailable: String = Localization.string("message_image_data_received"), val resultMeta: (AiGenerationResult) -> String = { result -> Localization.string( "generation_result_meta", result.width, result.height, result.samplingSteps, ) })
Link copied to clipboard
class TextToImageViewModel(val dispatchersProvider: DispatchersProvider, val getConfigurationUseCase: GetConfigurationUseCase, val getStableDiffusionSamplersUseCase: GetStableDiffusionSamplersUseCase, val getForgeModulesUseCase: GetForgeModulesUseCase, val fetchAndGetArliAiModelsUseCase: FetchAndGetArliAiModelsUseCase, val isADetailerAvailableUseCase: IsADetailerAvailableUseCase, val textToImageUseCase: TextToImageUseCase, val saveGenerationResultUseCase: SaveGenerationResultUseCase, val saveLastResultToCacheUseCase: SaveLastResultToCacheUseCase, val interruptGenerationUseCase: InterruptGenerationUseCase, val observeHordeProcessStatusUseCase: ObserveHordeProcessStatusUseCase, val observeLocalDiffusionProcessStatusUseCase: ObserveLocalDiffusionProcessStatusUseCase, val observeStableDiffusionCppProcessStatusUseCase: ObserveStableDiffusionCppProcessStatusUseCase, val observeCoreMlProcessStatusUseCase: ObserveCoreMlProcessStatusUseCase, val observeBonsaiProcessStatusUseCase: ObserveBonsaiProcessStatusUseCase, val preferenceManager: PreferenceManager, val backgroundTaskManager: BackgroundTaskManager, val backgroundWorkObserver: BackgroundWorkObserver, val wakeLockInterActor: WakeLockInterActor, val platformServices: GenerationPlatformServices, val buildInfoProvider: BuildInfoProvider, val generationFormUpdateEvent: GenerationFormUpdateEvent, val dimensionValidator: DimensionValidator, val localGenerationBenchmarkGateProvider: () -> LocalGenerationBenchmarkGate, val imageSaver: ImageSaver, val imageSharer: ImageSharer, val router: TextToImageRouter, val onError: (Throwable) -> Unit = {}) : BaseMviViewModel<TextToImageState, TextToImageIntent, EmptyEffect>

View-model for the txt2img screen.

Link copied to clipboard

Provides the UnsupportedAndroidImageSaver singleton used by the SDAI presentation layer.

Link copied to clipboard

Provides the UnsupportedAndroidImageSharer singleton used by the SDAI presentation layer.

Properties

Link copied to clipboard
private const val ADETAILER_INSTALL_URL: String
Link copied to clipboard
Link copied to clipboard
internal const val BONSAI_DEFAULT_SIZE: Int = 128

Exposes the BONSAI_DEFAULT_SIZE value used by the SDAI presentation layer.

Link copied to clipboard
internal const val BONSAI_SIZE_MULTIPLE: Int = 32

Exposes the BONSAI_SIZE_MULTIPLE value used by the SDAI presentation layer.

Link copied to clipboard
internal const val DEFAULT_SIZE: Int = 512
Link copied to clipboard
private const val MAX_ARLI_AI_STEPS: Int = 40
Link copied to clipboard
internal const val MAX_BATCH_COUNT: Int = 20

Exposes the MAX_BATCH_COUNT value used by the SDAI presentation layer.

Link copied to clipboard
internal const val MAX_CFG_SCALE: Float = 35.0f

Exposes the MAX_CFG_SCALE value used by the SDAI presentation layer.

Link copied to clipboard
private const val MAX_FAL_AI_BATCH_COUNT: Int = 4
Link copied to clipboard
private const val MAX_SIZE: Int = 2048
Link copied to clipboard
internal const val MAX_STEPS: Int = 150

Exposes the MAX_STEPS value used by the SDAI presentation layer.

Link copied to clipboard
internal const val MAX_SUB_SEED_STRENGTH: Float = 1.0f

Exposes the MAX_SUB_SEED_STRENGTH value used by the SDAI presentation layer.

Link copied to clipboard
private const val MIME_TYPE_JPG: String

Exposes the MIME_TYPE_JPG value used by the SDAI presentation layer.

Link copied to clipboard
internal const val MIN_BATCH_COUNT: Int = 1

Exposes the MIN_BATCH_COUNT value used by the SDAI presentation layer.

Link copied to clipboard
internal const val MIN_CFG_SCALE: Float = 1.0f

Exposes the MIN_CFG_SCALE value used by the SDAI presentation layer.

Link copied to clipboard
private const val MIN_SIZE: Int = 64
Link copied to clipboard
internal const val MIN_STEPS: Int = 1

Exposes the MIN_STEPS value used by the SDAI presentation layer.

Link copied to clipboard
internal const val MIN_SUB_SEED_STRENGTH: Float = 0.0f

Exposes the MIN_SUB_SEED_STRENGTH value used by the SDAI presentation layer.

Link copied to clipboard
private const val SIZE_STEP: Int = 64

Functions

Link copied to clipboard
private fun String.appendPromptTag(tag: String): String
Link copied to clipboard
private fun String.bonsaiSizeError(): UiText?
Link copied to clipboard

Executes the canGenerate step in the SDAI presentation layer.

Link copied to clipboard

Creates the SDAI value produced by createImageFileName.

Link copied to clipboard

Creates the SDAI value produced by createPlatformImageSaver.

Creates the SDAI value produced by createPlatformImageSaver.

Creates the SDAI value produced by createPlatformImageSaver.

Link copied to clipboard

Creates the SDAI value produced by createPlatformImageSharer.

Creates the SDAI value produced by createPlatformImageSharer.

Creates the SDAI value produced by createPlatformImageSharer.

Link copied to clipboard

Converts SDAI data with decodeBase64ImageBitmap.

Converts SDAI data with decodeBase64ImageBitmap.

Converts SDAI data with decodeBase64ImageBitmap.

Link copied to clipboard
private fun String.decodeGeneratedImageData(): NSData

Executes the decodeGeneratedImageData step in the SDAI presentation layer.

Link copied to clipboard
internal fun String.decodeGeneratedUiImage(): UIImage

Executes the decodeGeneratedUiImage step in the SDAI presentation layer.

Link copied to clipboard
Link copied to clipboard

Executes the function step in the SDAI presentation layer.

Link copied to clipboard
private fun flushPendingTaggedText(state: TextToImageState, promptChipTextFieldState: MutableState<TextFieldValue>, negativePromptChipTextFieldState: MutableState<TextFieldValue>, processIntent: (TextToImageIntent) -> Unit)
Link copied to clipboard
private fun GenerationHistoryDialog(onClose: () -> Unit, onGenerationSelected: (AiGenerationResult) -> Unit)
Link copied to clipboard

Executes the localizedMessageText step in the SDAI presentation layer.

Link copied to clipboard

Converts the current txt2img state into the domain generation request.

Link copied to clipboard
internal fun TextToImageState.progressModal(canCancelLocalGeneration: Boolean): GenerationModal

Executes the progressModal step in the SDAI presentation layer.

Link copied to clipboard
private fun UIApplication.rootViewController(): UIViewController?

Executes the rootViewController step in the SDAI presentation layer.

Link copied to clipboard
Link copied to clipboard
internal fun Float.roundToString(): String
Link copied to clipboard
private inline suspend fun runSavingAction(crossinline action: suspend () -> Unit): ImageSaveResult

Executes the runSavingAction step in the SDAI presentation layer.

Link copied to clipboard
private inline suspend fun runSharingAction(crossinline action: suspend () -> Unit): ImageShareResult

Executes the runSharingAction step in the SDAI presentation layer.

Link copied to clipboard
internal fun TextToImageBody(state: TextToImageState, strings: TextToImageStrings, promptChipTextFieldState: MutableState<TextFieldValue>, negativePromptChipTextFieldState: MutableState<TextFieldValue>, processIntent: (TextToImageIntent) -> Unit)

Renders the TextToImageBody UI for the SDAI presentation layer.

Link copied to clipboard
fun TextToImageContent(state: TextToImageState, processIntent: (TextToImageIntent) -> Unit, modifier: Modifier = Modifier, strings: TextToImageStrings = TextToImageStrings(), useDrawerNavigation: Boolean = false)

Screen content for text-to-image generation.

Link copied to clipboard
internal fun TextToImageForm(state: TextToImageState, strings: TextToImageStrings, promptChipTextFieldState: MutableState<TextFieldValue>, negativePromptChipTextFieldState: MutableState<TextFieldValue>, processIntent: (TextToImageIntent) -> Unit)

Renders the TextToImageForm UI for the SDAI presentation layer.

Link copied to clipboard

Converts SDAI data with toImageBytes.

Link copied to clipboard
private fun UIViewController.topMostPresentedViewController(): UIViewController

Converts SDAI data with topMostPresentedViewController.

Link copied to clipboard

Maps shared generation form events into txt2img intents.

Link copied to clipboard
internal fun List<AiGenerationResult>.toTextToImageResultModal(autoSaveEnabled: Boolean, reportEnabled: Boolean): GenerationModal

Converts SDAI data with toTextToImageResultModal.

Link copied to clipboard

Executes the validated step in the SDAI presentation layer.

Link copied to clipboard
internal fun TextToImageState.withSettings(settings: Settings, stableDiffusionSamplers: List<String>?, forgeModules: List<ForgeModule>?, aDetailerAvailable: Boolean?, arliAiModels: List<String>?): TextToImageState

Executes the withSettings step in the SDAI presentation layer.

Link copied to clipboard
internal fun TextToImageState.withSource(source: ServerSource, stableDiffusionSamplers: List<String>?, forgeModules: List<ForgeModule>?, aDetailerAvailable: Boolean?, arliAiModels: List<String>?): TextToImageState

Executes the withSource step in the SDAI presentation layer.