An experimental UI toolkit for generating PowerPoint presentation files using Compose

Overview

ComposePPT

An experimental UI toolkit for generating PowerPoint presentation files(.pptx) using Compose. Inspired by Glance and Mosaic.

Why?

This project is created just for fun and demonstrate the power of Compose Runtime 💪 .

Download

First, add the composePPT dependency from maven central. You should also add the compose compiler to kotlin compiler classpath.

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.fatihgiris.composePPT:composePPT:0.1.0")
    
    // Add the compose compiler to kotlin compiler classpath
    add(
        org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME, 
        "org.jetbrains.compose.compiler:compiler:1.1.1" // Compatible with Kotlin 1.6.10
    ) 
}

Usage

There is a single entry point called runComposePPT to create a presentation. In order to add a content, you must use Slide composable to add slides to a presentation first. Then you can place the composables inside the Slide composable.

fun main() {
    runComposePPT {
        // Slide composable must be used to place other composables 
        Slide {
            Text("Hello from composePPT")
        }
    }
}

After running the above code, you will see a presentation file composePPT.pptx in your project root folder. You can modify the presentation file name as below.

runComposePPT(presentationFileName = "myPresentation") { ... }

Calling runComposePPT several times is allowed if you want to create all presentations at once.

fun main() {
    runComposePPT(presentationFileName = "firstPresentation") { ... }
    runComposePPT(presentationFileName = "secondPresentation") { ... }
}

You can also use side effects and remember composable function.

Composables

Slide

A slide element which is to be used to place the content.

runComposePPT {
    Slide {
        Text(
            text = "ComposePPT is a UI toolkit to create PowerPoint " +
                    "presentations with Compose 🤩"
        )
    }
}

The above code will generate a slide without a title. If you want to have title, you can use title attribute.

runComposePPT {
    Slide(title = "ComposePPT") {
        Text(
            text = "ComposePPT is a UI toolkit to create PowerPoint " +
                    "presentations with Compose 🤩"
        )
    }
}

Additionally, you can create multiple slides as below.

runComposePPT {
    Slide {
        Text(text = "First slide")
    }
    Slide {
        Text(text = "Second slide")
    }
}

List

A vertical list which can layout other composables. Horizontal list is currently not supported.

runComposePPT {
    Slide {
        List {
            Text(
                text = "ComposePPT is a UI toolkit to create PowerPoint " +
                        "presentations with Compose 🤩"
            )
            Text(
                text = "ComposePPT uses Compose Runtime under the hood."
            )
        }
    }
}

Text

A core text element which can be styled using TextStyle.

runComposePPT {
    Slide {
        Text(text = "Here is a simple text with default styles")
    }
}

You can use style parameter to customize the style of a text.

runComposePPT {
    Slide {
        Text(
            text = "Here is a text with font size 30 and font color magenta",
            style = TextStyle(
                fontSize = 30f,
                fontColor = Color.MAGENTA
            )
        )
    }
}

Side Effects

Side effects are supported in composePPT and any job will be awaited before the termination of the program.

LaunchedEffect

Any job started with LaunchedEffect inside a composable will be awaited before terminating the program. It means that you can do long-running tasks.

runComposePPT {
    Slide {
        LaunchedEffect(Unit) {
            delay(1000)
            println("You will see this line and then program will terminate")
        }
    }
}

SideEffect

runComposePPT {
    SideEffect { 
        // Will be executed on every recomposition
    }
}

DisposableEffect

runComposePPT {
    DisposableEffect(Unit) {
        onDispose {
            // Will be executed before the disposal of the composition 
        }
    }
}

Composition Locals

LocalTextStyle

A composition local for the text style to be used in Text composable. You can provide a custom text style using this composition local.

Example:

runComposePPT {
    Slide {
        val smallRedTextStyle = TextStyle(
            fontSize = 10f,
            fontColor = Color.RED
        )

        CompositionLocalProvider(
            LocalTextStyle provides smallRedTextStyle
        ) {
            List {
                Text(
                    text = "This text is using the provided custom text style through " +
                            "LocalTextStyle composition local."
                )
                Text(
                    text = "If you check this and above text element there is no style set " +
                            "but they both have the same style which is different than default."
                )
            }
        }
    }
}

State in ComposePPT

You can use remember composable function in the compose runtime inside any of the composePPT composable body. Any changes made to the state objects will trigger recomposition.

Example:

runComposePPT {
    var rememberedStateValue by remember { mutableStateOf(0) }

    LaunchedEffect(Unit) {
        delay(1000)
        rememberedStateValue = 1
    }

    DisposableEffect(Unit) {
        onDispose {
            assert(rememberedStateValue == 1) // True
        }
    }
}

Limitations

You can only use LaunchedEffect to launch a coroutine. Even though using rememberCoroutineScope will work, it will not terminate the program. So you have to manually terminate it in order the presentation file to be created.

License

Copyright 2022 Fatih Giris

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
👋 A common toolkit (utils) ⚒️ built to help you further reduce Kotlin boilerplate code and improve development efficiency. Do you think 'kotlin-stdlib' or 'android-ktx' is not sweet enough? You need this! 🍭

Toolkit [ 🚧 Work in progress ⛏ 👷 🔧️ 🚧 ] Snapshot version: repositories { maven("https://s01.oss.sonatype.org/content/repositories/snapshots") }

Double Open license classification for OSS Review Toolkit (ORT) and other uses.

Double Open Policy Configuration This repository is used to maintain the license classification (license-classifications.yml) created by Double Open.

This program will read from your android application string.xml file and generate translated strings.xml files in your preferred languages using google sheet.
This program will read from your android application string.xml file and generate translated strings.xml files in your preferred languages using google sheet.

Localize your application content This program will read from your application string.xml file and generate translated strings.xml files in your prefe

Project-applocker - A concept app that uses Jetpack Security to encrypt user data such as text files or images using Encrypted Shared Preferences 🛠️ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files.
🛠️ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files.

DrawableToolbox English | 中文 The missing DrawableToolbox for Android. Create drawables programmatically and get rid of the boring and always repeated

Sync Kotlin files with an Xcode project

Kotlin Xcode Sync Note Soon to be deprecated. You can add folder references instead. See here. Import kotlin files into an Xcode project. This is used

Android project setup files when developing apps from scratch. The codebase uses lates jetpack libraries and MVVM repository architecture for setting up high performance apps

Android architecture app Includes the following Android Respository architecture MVVM Jepack libraries Carousel view Kotlin Kotlin Flow and Livedata P

This server uses json files to model items, entities and more.
This server uses json files to model items, entities and more.

Design Server | Simple server to design items, entities or more About this project/server: This server uses json files to model items, entities and mo

Open as default - A flutter plugin that allows setting up your flutter app to open files as default
Open as default - A flutter plugin that allows setting up your flutter app to open files as default

open_as_default A flutter plugin that allows setting up your flutter app to open

Owner
Fatih Giriş
Android Developer
Fatih Giriş
Curations and configuration files for the OSS Review Toolkit.

ORT Config This repository contains configuration files for the OSS Review Toolkit. Content Curations The curations directory contains package curatio

OSS Review Toolkit 9 Dec 8, 2022
An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime

An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime

Jake Wharton 1.4k Dec 28, 2022
A mobile application developed for *Android* devices, aimed at 11th grade students in which they can take some basic training tests for presentation of external tests.

ApliKTest11 Application with Kit of questions and Knowledge Test for the preparation of the Saber Test. Description A mobile application developed for

Mike Molina 0 Dec 13, 2021
Various experimental proposals and extensions to Javalin 4.x used in Reposilite 3.x

Javalin RFCs Various experimental extensions to Javalin 4.x used in Reposilite 3.x. Provides basic support for Kotlin coroutines and async routes with

Reposilite Playground 5 Feb 22, 2022
🐅 Experimental Kotlin library for Revolt (API subject is to change)

Kairi ?? Experimental Kotlin library for Revolt

Noel 3 Jul 4, 2022
Functional Kotlin & Arrow based library for generating and verifying JWTs and JWSs

kJWT Functional Kotlin & Arrow based library for generating and verifying JWTs and JWSs. JWS JWT The following Algorithms are supported: HS256 HS384 H

Peter vR 31 Dec 25, 2022
An android application for generating random quotes for learning Room, Jetpack Navigation and Lifecycles, Retrofit

Random-Quote-Generator An android application for generating random quotes for learning Room, Jetpack Navigation and Lifecycles, Retrofit MAD Score Te

Prasoon 2 Oct 16, 2022
Kotlin tooling for generating kotlinx.serialization serializers for serializing a class as a bitmask

kotlinx-serialization-bitmask Kotlin tooling for generating kotlinx.serialization serializers for serializing a class as a bitmask. Example @Serializa

marie 2 May 29, 2022
Kotlin multiplatform benchmarking toolkit

NOTE: Starting from version 0.3.0 of the library: The library runtime is published to Maven Central and no longer published to Bintray. The Gradle plu

Kotlin 310 Jan 2, 2023