Skip to content

Debug view: Initial UI + Usage in MagicWeatherCompose#1075

Merged
tonidero merged 26 commits into
mainfrom
debug-view
Aug 3, 2023
Merged

Debug view: Initial UI + Usage in MagicWeatherCompose#1075
tonidero merged 26 commits into
mainfrom
debug-view

Conversation

@tonidero

@tonidero tonidero commented Jun 19, 2023

Copy link
Copy Markdown
Contributor

Description

Same as was added in iOS in RevenueCat/purchases-ios#2567. Includes the changes in #1180

This PR adds a debug view in the Android SDK and uses it in the MagicWeatherCompose sample app. This debug view is meant to be a Jetpack compose function, even though later we might add convenience accessors for people not using jetpack compose. It's extracted to a different module so it can be published separately from the main SDK. It also attempts to keep all the code in the debug source set, to try to include as few code in the release variants.

The provided API is currently 2 composable functions:

  • DebugRevenueCatDebugScreen: This is the actual UI that is part of the debug screen. In case devs want to use it in a custom UI.
  • DebugRevenueCatBottomSheet: This will display the debug screen as a bottom sheet. This is what's used in the MagicWeatherCompose sample app.
TODO
  • Allow visualizing offerings in debug menu
  • Support non-composable apps by wrapping it into a fragment, with utility launch methods.
  • Split library for debug and release
  • Add UI tests
  • Support publishing the new module as different libraries for debug and release.
  • Remove module local substitution once debugview library has been published
Screen_recording_20230728_115505.mp4

@tonidero tonidero added the test label Jun 19, 2023
Comment thread build.gradle Outdated
Comment thread debugview/build.gradle Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to update kotlin to 1.8 in this module, it didn't work even with 1.7.20 unless I downgraded compose a lot. Considering this is meant to be a new library, we can require Kotlin 1.8 I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release version of this composable does nothing.

@codecov

codecov Bot commented Jul 28, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1075 (819508f) into main (b428869) will not change coverage.
The diff coverage is n/a.

❗ Current head 819508f differs from pull request most recent head 5ec4c4f. Consider uploading reports for the commit 5ec4c4f to get more accurate results

@@           Coverage Diff           @@
##             main    #1075   +/-   ##
=======================================
  Coverage   85.92%   85.92%           
=======================================
  Files         181      181           
  Lines        6216     6216           
  Branches      899      899           
=======================================
  Hits         5341     5341           
  Misses        533      533           
  Partials      342      342           

Comment thread config/detekt/detekt.yml Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so it doesn't warn us about compose preview functions being unused.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to leave this until the debug view has been deployed at least once

Comment thread debugview/build.gradle Outdated

@tonidero tonidero Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler version needs to match the kotlin version https://developer.android.com/jetpack/androidx/releases/compose-kotlin. And for 1.7.21, it needs to be 1.4.0-alpha02. It won't work with 1.4.0. The alternative here would be to downgrade to 1.7.20, which would match with compiler version 1.3.2... As for upgrading to kotlin 1.8, it would cause breaking changes, since it seems apps using kotlin 1.6 aren't really compatible due to some dependencies. Open to suggestions here... For now, I haven't had issues using the alpha version

Comment thread debugview/build.gradle Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm commenting this out for now until I completely finish the debug view and is ready to be published as a separate package.

@tonidero tonidero Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to thoughts about the dependency name. I'm thinking something like this for the "debug" library and something like com.revenuecat.purchases:debugview-noop for the release version

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. I thought about only debug but that might imply other stuff like debug logs or something like that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bottom sheet APIs I'm using are marked as experimental, so I'm forced to opt in. This means there might be breaking changes at any point :(.

I thought about using Material instead of Material3 to do this, but the paradigm is quite different... In Material's version, you need to pass the UI below the bottom sheet as the content of the composable. IMO, that's not ideal, so I understand the new architecture they are using in Material3. In the end, I decided to go with Material3's version since it provides a much easier to use API and more modern UI as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a debug thing so I think it's fine to do this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to make offerings visible. My idea is to display them as alerts in a future PR. Navigation within bottom sheets requires additional experimental libraries on Google's side, so I wanted to avoid that for now.

@tonidero tonidero changed the title [WIP] Debug view Debug view: Initial UI + Usage in MagicWeatherCompose Jul 28, 2023
@tonidero tonidero marked this pull request as ready for review July 28, 2023 12:15
@tonidero tonidero requested a review from a team July 28, 2023 12:15

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting 😍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha this is basically just like @ViewBuilder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it's super similar to SwiftUI :P

Comment thread debugview/build.gradle Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be com.revenuecat.purchases.ui maybe? Are you thinking of having a separate one for "future" UI? 👀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe... I was thinking that for other ui projects, those would belong to other modules/dependencies, but maybe we could scope all those under ui. So maybe rename to com.revenuecat.purchases.ui.debugview. Wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ui.debugview sounds good to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do this rename in a followup PR to avoid conflicts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a debug thing so I think it's fine to do this.

Comment thread api-tester/build.gradle Outdated
Comment thread api-tester/build.gradle Outdated
Comment thread config/detekt/detekt.yml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@tonidero tonidero requested a review from vegaro August 1, 2023 09:12

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good! Good job!

Comment thread debugview/build.gradle Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ui.debugview sounds good to me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think this function should be toSettingGroupStates()?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of a viewModel or is it fine here? I am not that familiar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, unfortunately we don't have a view model for the MainScreen right now, so it was easier to move it here... But yeah, this is something that could be moved to a view model.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. I thought about only debug but that might imply other stuff like debug logs or something like that

tonidero added a commit that referenced this pull request Aug 3, 2023
…1180)

### Description
This reverts the changes in #1169, and additionally makes some changes
so we only apply the maven publish plugin when using the `defaults`
flavor in non-purchases modules. This should avoid having to have extra
flavors in those modules and having them support the
`customEntitlementComputation` flavor.

This was becoming a bit of a problem as I was working in the debug view
#1075. Since some of the functions I'm using aren't in the
`customEntitlementComputation` flavor. I could have split the debug view
library by flavor to make it compatible, but that seems like unnecessary
work.
@tonidero tonidero enabled auto-merge (squash) August 3, 2023 09:44
@tonidero tonidero merged commit 1c5f6e9 into main Aug 3, 2023
@tonidero tonidero deleted the debug-view branch August 3, 2023 09:58
tonidero pushed a commit that referenced this pull request Aug 10, 2023
**This is an automatic release.**

### Bugfixes
* Fix NoSuchElementException by using poll when accessing
serviceRequests (#1190) via Cesar de la Vega (@vegaro)
### Other Changes
* Debug view: rename package (#1191) via Toni Rico (@tonidero)
* Debugview: Add snapshot tests for debug view using Paparazzi (#1187)
via Toni Rico (@tonidero)
* Debug view: Add offerings section and purchasing capabilities (#1186)
via Toni Rico (@tonidero)
* Debug view: Initial UI + Usage in MagicWeatherCompose (#1075) via Toni
Rico (@tonidero)
* Remove customEntitlementComputation flavor for non-purchases modules
(#1180) via Toni Rico (@tonidero)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants