Thank you for this! As you said I was really overwhelmed with all the complex architecture and libraries in other tutorials, this is what I needed at my level! Please make more!
Thanks as always for the great content, Philipp. One modest suggestion that I feel could be helpful: I'd love to see @Preview annotations used and see the UI built iteratively. It's easier to see the effects of the code that's being written when the execution of the code happens piecemeal. It's a little harder to string together when it happens all at once🙂. To be fair, coding along is an option, but sometimes I like to just hang back and enjoy the show.
Just a readability hack I found Instead of using a data class Operation inside a sealed class CalculatorOperation we could just another sealed class Example: sealed class CalculatorAction { data class Number(val number: Int) : CalculatorAction() object Clear : CalculatorAction() object Delete : CalculatorAction() object Decimal : CalculatorAction() object Calculate : CalculatorAction() //Instead of this //data class Operation(val operation: CalculatorOperation) : CalculatorAction() //Use this sealed class CalculatorOperation(val symbol: String) : CalculatorAction(){ object Add : CalculatorOperation("+") object Subtract : CalculatorOperation("-") object Divide : CalculatorOperation("/") object Multiply : CalculatorOperation("*") } } Readability benfit: // This is better onClick = { onAction(CalculatorAction.CalculatorOperation.Divide) }) //than this onClick = { onAction(CalculatorAction.Operation(CalculatorOperation.Divide)) })
i've been learning on the side and had to take a break because work stuff was keeping me busy, holy cow the new version launches the app super fast now when i recompile my code, gotta give the props for the android team
I think this would actually be _simplified_ by adding support for more operations, because now you just input a big string of characters and finally calculate it by hitting =. So all the operation buttons can just be the same action as the digits. Also you could cut the repetitive code down very simply by defining a local function with the 4 params which vary and packing the calls to that on a single line for each button.
I experience joy of elegant coding in Jetpack Compose without messy xml. Kotlin with Compose is now at the same level as SwiftUI without messy .xib associated with storyboard in UIKit. Great lecture, Thanks.
I already made a similar one in java, having something similar in compose is a good way for me to learn stuff. Thank you philip, now i can understand how to work in jetpack compose the correct way
hey, the best I found is the last 2 chapters of Headfirst Android 3rd edition. Those are really really good to understand how compose work. I found them better than the official material on compose.
Hello Phillip, so yeah, I did the assignment. I can carry out multiple operations. Though, I changed the layer above to contain two textviews, one for displaying input and the other for displaying result. Thanks once again.
it should be in android framework by default by now, but there is an operation called exhaustive, which if you add it to your when block, it forces you to add all the possible sealed classes possibilities (and will give you the option to do so) or add an else block. very handy indeed. it looks like this val T.exhaustive: T get() = this you add it to your util file, and can use it wherever you want.
@22:02 luckily for me, I can populate the buttons using an array of buttons. because the button is actually the same object, it only differs in width in two areas (or elements). if we use the formula to linearize the 2d space into 1d space we can define it like this: f(i)=y*w+x where: 'i' is the index, 'y' is the index of y with the range of 0 to 4 'x' is the index of x with the range of 0 to 4 except when y=0 and y=4, its range is 0 to 2 so, since the number of buttons object is 4*5-2 = 18 we can do for loop. in that for loop we can populate a homogenous attributes to all button object first for the color, then we can explicitly change certain attributes of the button. for example, button[0] and button[15] to have wider attribute for the size to be drawn on the screen. For button[0] and button[1] they have light grey color attribute. For the operation button, we can use % modulo operator to give orange color. like: if i%4==0: button[i].color=Color.orange button[17]=Color.orange and we are done.
Great idea for a video big 🐕. I like that it's a realistic, full project but not overly complicated. I'm rewriting my super old Java/XML Android app in Compose/Kotlin/Room, learning all as I go, and decided to use Clean Architecture too. But man for my simple app that is way too unnecessarily complicated. There's about 4 times the files and code of my old app and I'm about half done lmao. I can see CA being useful for more complex apps and apps that a team works on, but for a small app by a single developer? No way, way overkill imo.
Very good Video, please more stuff like this simple app in Compose, maybe some with an API Call to load some contacts in a lazy list or something like that.
Hello Phillip Knacker. In the beginning of this video. You said that this is for those who have an idea of the basics of JetPack Compose. Does this mean I have to know at least the small basics of JetPack Compose before embarking on this project?? Just asking
Great tutorial, helped me with ViewModel when I was loosing hope to find solution of my problem, much thanks! :D Also I have a question: how did you push the modifier higher over buttonSpacing? Seem like some smart key comination
@19:33 Initially I was confused with how Compose work. Because, it is just a function annotated with `@Composable` keyword with multiple parameters. In the parameter we can set the default value for the function. Inside the body of the function, we can set the layout of that compose such as the Box compose which is also a function, here inside the Box's parameter is the place where we can set the attribute for that Box, but in it's body, It will specify the children element of that Box. For example, a Column compose as the children of Box. So, it is like xml file, where we can set the attribute of an element, or declare a children element. In a nutshell, in the Compose function's: 1. parameter : specify the attribute of that particular Compose element. 2. body: specify the children element of that particular Compose element.
If we want multiple children element let say inside Column, we have 2 children elements: 1. Text 2. Row we do not need to put comma "," also for `Text` element it does not need a "body" or children.
while following this tutorial while 15:56 viewModel is showing unresolved reference, i am using emptyactivity in android studio giraffe?????? please help!!!! !!!!!!!!!!!!!!!!!! i have found similar problem in stack overflow but no solution given
Do you have? ... import androidx.lifecycle.ViewModel import androidx.compose.runtime.* and in build.gradle > implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2" Tip: Hover and use Alt-Enter when it suggests imports
Hello phillip this is a non related question but, do you know which technology I can use to automate apps,Like i want to create an app that automate WhatsApp message,I know aapium out there,but there is no reference how to implement as an app,Can you please tell me!.
Please someone answer my question. At 15:31, if you want to retain the state after the screen rotates shouldn't the ViewModel be: "var state by rememberSaveable {mutableStateOf(CalculatorState()) }" Instead of what's in the video: var state by mutableStateOf(CalculatorState())
@@PhilippLackner isn’t the purpose of the view model to keep the state after the screen rotates and it’s destroyed? I thought rememberSavable was the only way to stop the state from getting destroyed after a configuration change like rotating your screen so why does mutableState work too or does it have a different purpose?
@@punyan775 if you store the state in the composable itself, rememberSaveable is needed. But in a viewmodel it's save since that has a different livecycle
Probably it's good for someone, but it would be way better if you showed the visual changes while writing the code rather than just describing how it works. Thanks anyway.
Philip can I know what your android studio theme is? I've been getting into native android recently, previously I've always worked in VS Code and I can't find a theme that I like. This one seems pretty cool to try
Hi phil.. i am always enter ur channel everyday and it helps me a lot... I am just wanna ask u if u could make these tutorials or at least one of them - Simple validation clean arch - how to handle lifecycle with many real examples - paging 3 Oh and all of them by xml not the compose please 😂
Actually, I made the UI and the final row overlaps with the above row because there is not much space. This is solved if I use scrollState on the column or lower the fontSize of the Text, but what is the optimal way of designing it so that it is smoothly running on all devices?
in your CalculatorButton.kt, make sure the .clickable in your modifier inside your box is .clickable{ onClick() } If you use only .clickable {onClick}, it won't work
That is a great tutorial, could you make another tutorial about authentication especially firebase authentication with google credential in correct way? Thanks!!
Hi phillip, ive been making an nft app in android studio and im struggling with the xml layout designs. Can you please make a video on an nft marketplace ui design?
I think there is no default keyboard shortcut in AS, but you can set your own by going to Setting -> Keymap -> search kotlin class/file and then you can use any shortcut which is not already assigned to any other
@Philipp: Is there is any way to create project KMP using jetpack library rather than jetpack compose. There is no setting while creating project of KMP. It is by default creating project using jetpack compose library. There should be a option to do so while creating project of KMP .
Why u havent used textfield there coz in official google there is actually the implementation with text field what will you do when u have to change the number between the input please apply those changes and reupload the video....Thanks
The amount of files required to make this project in the jetpack compose is absurd. Google is trying, but this will down the drain. XML is much simpler and faster to implement.
Thank you for this! As you said I was really overwhelmed with all the complex architecture and libraries in other tutorials, this is what I needed at my level! Please make more!
Glad it was helpful!
Thanks as always for the great content, Philipp. One modest suggestion that I feel could be helpful: I'd love to see @Preview annotations used and see the UI built iteratively. It's easier to see the effects of the code that's being written when the execution of the code happens piecemeal. It's a little harder to string together when it happens all at once🙂.
To be fair, coding along is an option, but sometimes I like to just hang back and enjoy the show.
Really helpful videos for someone who's re-qualifying from data analytics world to Android. Keep up the good work!!!
Just a readability hack I found
Instead of using a data class Operation inside a sealed class CalculatorOperation we could just another sealed class
Example:
sealed class CalculatorAction {
data class Number(val number: Int) : CalculatorAction()
object Clear : CalculatorAction()
object Delete : CalculatorAction()
object Decimal : CalculatorAction()
object Calculate : CalculatorAction()
//Instead of this
//data class Operation(val operation: CalculatorOperation) : CalculatorAction()
//Use this
sealed class CalculatorOperation(val symbol: String) : CalculatorAction(){
object Add : CalculatorOperation("+")
object Subtract : CalculatorOperation("-")
object Divide : CalculatorOperation("/")
object Multiply : CalculatorOperation("*")
}
}
Readability benfit:
// This is better
onClick = {
onAction(CalculatorAction.CalculatorOperation.Divide)
})
//than this
onClick = {
onAction(CalculatorAction.Operation(CalculatorOperation.Divide))
})
Damn, this comment need more likes
You are a really good teacher. I've been learning Kotlin mainly by watching your videos and it's been a great experience.
I'm gonna upgrade this to the scientific level.
Please upload your scientific calculator source code.
Same
@@Justme-dk7vm ikr😆
i've been learning on the side and had to take a break because work stuff was keeping me busy, holy cow the new version launches the app super fast now when i recompile my code, gotta give the props for the android team
I think this would actually be _simplified_ by adding support for more operations, because now you just input a big string of characters and finally calculate it by hitting =. So all the operation buttons can just be the same action as the digits.
Also you could cut the repetitive code down very simply by defining a local function with the 4 params which vary and packing the calls to that on a single line for each button.
I experience joy of elegant coding in Jetpack Compose without messy xml. Kotlin with Compose is now at the same level as SwiftUI without messy .xib associated with storyboard in UIKit. Great lecture, Thanks.
but xml performance is sitll better
I already made a similar one in java, having something similar in compose is a good way for me to learn stuff. Thank you philip, now i can understand how to work in jetpack compose the correct way
hey, the best I found is the last 2 chapters of Headfirst Android 3rd edition. Those are really really good to understand how compose work. I found them better than the official material on compose.
@@akashkroy thank you for the advice, i will check them out
Created it successfully, and modified it a little bit 🥰 Thanks Philipp, you are the best teacher ever!
You are a genious. I expect one day to be able to think all the things as fast as you do with Kotlin
Hello Phillip, so yeah, I did the assignment. I can carry out multiple operations. Though, I changed the layer above to contain two textviews, one for displaying input and the other for displaying result. Thanks once again.
Wow. Mind sharing how you did it?I've tried it's not working for me.
it should be in android framework by default by now, but there is an operation called exhaustive, which if you add it to your when block, it forces you to add all the possible sealed classes possibilities (and will give you the option to do so) or add an else block.
very handy indeed.
it looks like this
val T.exhaustive: T
get() = this
you add it to your util file, and can use it wherever you want.
In enter decimal function, instead of writing number2=state.number2+"." you write number1=state.number2+"." Last thing it a nice project
thanks for the great video.
there is a bug in 36:42 where for "number2" decimal you use the "number1" variable
I search this on TH-cam, you made my day..
@22:02
luckily for me, I can populate the buttons using an array of buttons.
because the button is actually the same object, it only differs in width in two areas (or elements).
if we use the formula to linearize the 2d space into 1d space we can define it like this:
f(i)=y*w+x
where:
'i' is the index,
'y' is the index of y with the range of 0 to 4
'x' is the index of x with the range of 0 to 4 except when y=0 and y=4, its range is 0 to 2
so, since the number of buttons object is 4*5-2 = 18
we can do for loop.
in that for loop we can populate a homogenous attributes to all button object first for the color, then we can explicitly change certain attributes of the button.
for example, button[0] and button[15] to have wider attribute for the size to be drawn on the screen. For button[0] and button[1] they have light grey color attribute.
For the operation button, we can use % modulo operator to give orange color.
like:
if i%4==0:
button[i].color=Color.orange
button[17]=Color.orange
and we are done.
i have learn so much about Kotlin. I love your Videos
Great one buddy. Helped a lot. Thanks!
Another fan!!!!! You're spectacular, I've been following your videos and honestly , I like you, you're so wonderful...thanks for your time...
reallly helpful, thanks a lot philipp
great as always philipp
Great video so much helpful great work :)
Thank u this was very helpful.
Thanks dude, it was so clear to understand.
Great idea for a video big 🐕. I like that it's a realistic, full project but not overly complicated.
I'm rewriting my super old Java/XML Android app in Compose/Kotlin/Room, learning all as I go, and decided to use Clean Architecture too. But man for my simple app that is way too unnecessarily complicated. There's about 4 times the files and code of my old app and I'm about half done lmao.
I can see CA being useful for more complex apps and apps that a team works on, but for a small app by a single developer? No way, way overkill imo.
Wonderful! Was wondering why you used sealed class vs enum for operations and I see you have another video for that. :) Mind-blown! ❣️
Very very cool tutorial
Very good Video, please more stuff like this simple app in Compose, maybe some with an API Call to load some contacts in a lazy list or something like that.
Thank you, this was very helpful as always
Thanks One of the best Channel
It's really a good looking app
Thx for the tutorial 🙏
Welcome!
I have created a calculator like this. It was in one class 400 columns and it takes nearly 4 hours.
This was a great tutorial. I really hope you will do more simple basic tutorials like this
Thx for the video... Which plugin are you using?
Thank you so much, great content love your videos
10/10 architecture
Hello Phillip Knacker. In the beginning of this video. You said that this is for those who have an idea of the basics of JetPack Compose. Does this mean I have to know at least the small basics of JetPack Compose before embarking on this project?? Just asking
Adamın hası, hası
Great tutorial, helped me with ViewModel when I was loosing hope to find solution of my problem, much thanks! :D
Also I have a question: how did you push the modifier higher over buttonSpacing? Seem like some smart key comination
You are genius man
Hope you will make an update for this app using Constraint layout. Nice video and very helpful!!
Thank you, great tutorial
very cool video
thank you BRO
you are the best
wish you all the best 🔥👍👍👍👍
@19:33 Initially I was confused with how Compose work. Because, it is just a function annotated with `@Composable` keyword with multiple parameters.
In the parameter we can set the default value for the function.
Inside the body of the function, we can set the layout of that compose such as the Box compose which is also a function, here inside the Box's parameter is the place where we can set the attribute for that Box, but in it's body,
It will specify the children element of that Box. For example, a Column compose as the children of Box.
So, it is like xml file, where we can set the attribute of an element, or declare a children element.
In a nutshell, in the Compose function's:
1. parameter : specify the attribute of that particular Compose element.
2. body: specify the children element of that particular Compose element.
If we want multiple children element let say inside Column, we have 2 children elements:
1. Text
2. Row
we do not need to put comma ","
also for `Text` element it does not need a "body" or children.
while following this tutorial while 15:56 viewModel is showing unresolved reference, i am using emptyactivity in android studio giraffe?????? please help!!!! !!!!!!!!!!!!!!!!!! i have found similar problem in stack overflow but no solution given
Do you have?
...
import androidx.lifecycle.ViewModel
import androidx.compose.runtime.*
and in build.gradle > implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2"
Tip: Hover and use Alt-Enter when it suggests imports
@@hkjk0 I have it but same issue suggestions are create local variable, property ,object, parameter. have viewModels() though not viewModel()
@@2050Debanjan and you synced it? (I had similar issues, but would have to start all over again to reproduce the solution)
Also, is anything else blowing red?
@@hkjk0 solved after syncing ..there was sybcing issue
Thank you, it was great!!!
thank you Philipp
Can I start my development journey with jetpack compose If I'm a beginner or first I should go for XML one then switch on jetpack compose ????
Great video! Thank you!
How update viewModel from Service?
Hello phillip this is a non related question but, do you know which technology I can use to automate apps,Like i want to create an app that automate WhatsApp message,I know aapium out there,but there is no reference how to implement as an app,Can you please tell me!.
Thank you so much for this tutorial
Nice vid bro I dropped a like and a sub
Good video but this calculator can operate only at two numbers. It is unable to perform operation for 3 and more numbers like: 25+32+5 =
Hi Philipp why you don't sale your courses on Udemy?
Hello tell me pls what theme you use in android studio?
Great!!!. Thank you very much!
that's very cool👍🏽
I think this video is out of date now, many things now dont work in the new version of Android Studio. He needs to update this video completely.
Please someone answer my question. At 15:31, if you want to retain the state after the screen rotates shouldn't the ViewModel be:
"var state by rememberSaveable {mutableStateOf(CalculatorState()) }"
Instead of what's in the video:
var state by mutableStateOf(CalculatorState())
No, in the viewmodel there's no composition which the state would need to survive
@@PhilippLackner isn’t the purpose of the view model to keep the state after the screen rotates and it’s destroyed?
I thought rememberSavable was the only way to stop the state from getting destroyed after a configuration change like rotating your screen so why does mutableState work too or does it have a different purpose?
@@punyan775 if you store the state in the composable itself, rememberSaveable is needed. But in a viewmodel it's save since that has a different livecycle
@@PhilippLackner I see. Thank you 🙏🏽
12:33 why you don't use sealed interface instead of class 😅😅😅
You are the fucking best ever Time a have a default thing that needs explaining your the man to go to... I hope you know how much we appreciate you..
❤️🙏
Probably it's good for someone, but it would be way better if you showed the visual changes while writing the code rather than just describing how it works. Thanks anyway.
Nice content but there should be history like normal calculator app
Thank you Sir
I'm getting error in text sir like annotationstring textunit , that's because i'm unable to run my app
Uma Calculadora Muito fofa!
Philip can I know what your android studio theme is?
I've been getting into native android recently, previously I've always worked in VS Code and I can't find a theme that I like. This one seems pretty cool to try
Xcode dark
Amazing video 🌟🌟🌟
hey im unable to use fontWeigth in calculator.kt please help
Hi phil.. i am always enter ur channel everyday and it helps me a lot... I am just wanna ask u if u could make these tutorials or at least one of them
- Simple validation clean arch
- how to handle lifecycle with many real examples
- paging 3
Oh and all of them by xml not the compose please 😂
I already saw this one coming.
how to make table from json data dynamically through kotlin code volley without using xml
Why you haven't use constraint layout ?
u dont need to. nesting is fine
state.copy doesnt work unsolved reference someone help pls
Actually, I made the UI and the final row overlaps with the above row because there is not much space. This is solved if I use scrollState on the column or lower the fontSize of the Text, but what is the optimal way of designing it so that it is smoothly running on all devices?
Give the Calc section a weight of 1f and the button section no weight
@@PhilippLackner Wow, that worked. Checked the documentation about how weight works when some children are unweighted. Thanks Philipp!
I fixed it by replacing the line
fontSize = 80.sp,
to
style = TextStyle(fontSize = 80.sp),
Having an issue:
When i click on the numbers it’s not displaying the numbers.. where could be the mistake
same problem bro. Have you resolved this issue yet?
please answer this
same issue is there any solution
did you fixed it ? dude@@priyanshukumar2606
in your CalculatorButton.kt, make sure the .clickable in your modifier inside your box is .clickable{ onClick() }
If you use only .clickable {onClick}, it won't work
did you got any solution
That is a great tutorial, could you make another tutorial about authentication especially firebase authentication with google credential in correct way? Thanks!!
Great!
Using a key and value with a loop would work
Where is thousend separator?
Hi phillip, ive been making an nft app in android studio and im struggling with the xml layout designs. Can you please make a video on an nft marketplace ui design?
How to remove that decimal from result i.e 5+5 = 10.0 how to remove that .0 ?
Convert it to an int
Спасибо!
🔥🔥🔥🔝
What is this keyboard shortcut? sorry 3:24
I think there is no default keyboard shortcut in AS, but you can set your own by going to Setting -> Keymap -> search kotlin class/file and then you can use any shortcut which is not already assigned to any other
Woow woow
@Philipp: Is there is any way to create project KMP using jetpack library rather than jetpack compose. There is no setting while creating project of KMP. It is by default creating project using jetpack compose library. There should be a option to do so while creating project of KMP .
now i see my calculator from a different perspective 😅
Hai anna iam Nagendar Anna na age 42 LIKESEX.Uno qualification m.l.t medical lab technicianc ,Srpt lo jobs unte cheppagalaru anna.with govt Jobs
Very difficult to follow. He just assumes everything we know and starts writing the code without explaining what and why.
Cullem cullem cullem cullem
"With the layout preview while programming, it's better for understanding."😢
Why u havent used textfield there coz in official google there is actually the implementation with text field what will you do when u have to change the number between the input please apply those changes and reupload the video....Thanks
20:26
41:22
The amount of files required to make this project in the jetpack compose is absurd. Google is trying, but this will down the drain. XML is much simpler and faster to implement.
i agree but in this case only : ) but this is f** future
your voice not clear
give up android compose :)
Ok
pretty garbage tutorials :/
Where's JavaScript Mastery for Kotlin/Android? ugh :/