Skip to content

Commit

Permalink
Make LayoutScope implement BaseResourcesScope
Browse files Browse the repository at this point in the history
Summary: As per title. This will allow using extensions such as `dimenRes(...)`, `toPixels()` etc inside of `LayoutScope.layout()` function.

Reviewed By: adityasharat

Differential Revision: D47749621

fbshipit-source-id: 1b3962880df0e68bfd8d95a47519124a41151bdf
  • Loading branch information
zielinskimz authored and facebook-github-bot committed Jul 26, 2023
1 parent ed59bef commit 2e78310
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@
package com.facebook.rendercore.primitives

import android.content.Context
import com.facebook.rendercore.BaseResourcesScope
import com.facebook.rendercore.LayoutContext
import com.facebook.rendercore.ResourceCache
import com.facebook.rendercore.ResourceResolver

/**
* The scope for the [Primitive] layout method. Provides access to [LayoutContext], the previous
* layout data and utility methods that may help to compute the [PrimitiveLayoutResult].
*/
class LayoutScope
internal constructor(val layoutContext: LayoutContext<Any?>, val previousLayoutData: Any?) {
val androidContext: Context
internal constructor(val layoutContext: LayoutContext<Any?>, val previousLayoutData: Any?) :
BaseResourcesScope {
override val androidContext: Context
get() = layoutContext.androidContext

override val resourceResolver: ResourceResolver
get() =
ResourceResolver(
androidContext, ResourceCache.getLatest(androidContext.resources.configuration))
}

0 comments on commit 2e78310

Please sign in to comment.