How do you change data class variable values with outside functions in Jetpack Compose?

I’m trying to structure a simple application in a way that makes it easier to refactor by importing all values into a composable using data classes.

All the values are passed through successfully. However, whenever I try to add functionally into the composable it doesn’t work despite showing no errors.

Here is the file that contains the main activity and composable titled “Test1”
It displays a text widget that says “Hello World” with a red font and a blue button underneath it.

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Test1(Test1Properties(
                    textProperties = TextProperties(),
                    buttonProperties = ButtonProperties()
                ),
                  Test1Functions())
        }
    }
}

@Composable
fun Test1(
    test1Properties: Test1Properties,
    test1Functions: Test1Functions
    ){
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center,
        modifier = Modifier
            .fillMaxSize()
    ) {
       Text(
           text = test1Properties.textProperties.text,
           color = test1Properties.textProperties.color,
           fontSize = test1Properties.textProperties.fontSize,
           fontWeight = test1Properties.textProperties.fontWeight
           )
       Button(
           onClick = {test1Functions.changeTextPropertiesText(test1Properties)},
           colors = ButtonDefaults.buttonColors(
               containerColor = test1Properties.buttonProperties.containerColor
           )
       ) {
           Text(text = test1Properties.buttonProperties.text)
       }
    }
}

Here is the file containing all of the data classes that hold all of the values for the composable.
There are three data classes. one for the text widget, one for the button, and one to hold them all together. There is one class to hold the functionally of the composable called “Test1Functions”. It only has one function to change the color of the text widget to blue.

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp


data class Test1Properties(
    val textProperties: TextProperties,
    val buttonProperties: ButtonProperties
)
data class TextProperties(
    var text: String = "Hello World",
    var color: Color = Color.Red,
    val fontSize: TextUnit = 30.sp,
    val fontWeight: FontWeight = FontWeight.Bold
)

data class ButtonProperties(
    val onClick: () -> Unit = {},
    val text: String = "Button",
    val containerColor: Color = Color.Blue
)

class Test1Functions {
fun changeTextPropertiesText(test1Properties: Test1Properties): Color {
    test1Properties.textProperties.color = Color.Blue
    return test1Properties.textProperties.color
    }
}

Everything seems fine, no errors occurring, but when pressing the button the intended functionally does not occur. The intended functionally being turning the text in text widget blue.

And if you have any problems with this way of structuring your app, please recommend a better way.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật