aipok
06/23/2020, 10:50 AMaipok
06/23/2020, 11:44 AMjim
06/23/2020, 12:11 PMDatePicker or CreditCardEntryForm or AddressForm could all have very sophisticated validation logic. If you were implementing GoogleDocs, you might have a GoogleDocTextEditor widget that took in a mutable RichTextDoc data structure describing the document. But the logic of these widgets should be self-contained to the widget's specific concerns, and not explicitly depend on the app as a whole. If your widget has a reference to your Activity, you're almost certainly doing it wrong.
Compose widgets are certainly expected to replace Fragments in general usage, but I'd suggest using a mental model that is closer to custom views. Fragments were a very leaky abstraction that wasn't conducive to good encapsulation. Instead, you want to build reusable chunks that feel like something you could embed into another app. At some point you will intentionally break this rule, but if you feel the need to ask the question, then you're probably not yet ready to break the rule.