-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
131 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
android/src/main/java/com/lodev09/truesheet/TrueSheetBottomSheetBehavior.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 20 additions & 16 deletions
36
android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
package com.lodev09.truesheet | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.widget.FrameLayout | ||
import android.widget.LinearLayout | ||
import android.widget.RelativeLayout | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
import com.facebook.react.bridge.ReactContext | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
|
||
class TrueSheetView(context: Context): CoordinatorLayout(context) { | ||
class TrueSheetView(context: ReactContext): FrameLayout(context) { | ||
|
||
private lateinit var contents: RelativeLayout | ||
private set | ||
private lateinit var behavior: BottomSheetBehavior<*> | ||
private set | ||
private lateinit var contentView: View | ||
private lateinit var bottomSheetDialog: BottomSheetDialog | ||
|
||
override fun onViewAdded(child: View?) { | ||
super.onViewAdded(child) | ||
if (child != null) { | ||
removeView(child) | ||
bottomSheetDialog = BottomSheetDialog(context) | ||
bottomSheetDialog.setContentView(child) | ||
} | ||
} | ||
|
||
contents = child as RelativeLayout | ||
fun present() { | ||
bottomSheetDialog.show() | ||
} | ||
|
||
behavior = BottomSheetBehavior.from(contents).apply { | ||
// virtually disables 'third' breakpoint | ||
halfExpandedRatio = 0.9999999f | ||
isFitToContents = true | ||
isHideable = true | ||
// default to no collapsed state | ||
skipCollapsed = true | ||
setPeekHeight(Integer.MAX_VALUE) | ||
} | ||
fun dismiss() { | ||
bottomSheetDialog.dismiss() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
android/src/main/java/com/lodev09/truesheet/TrueSheetViewModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
android/src/main/java/com/lodev09/truesheet/utils/withPromise.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.lodev09.truesheet.utils | ||
|
||
import com.facebook.react.bridge.Promise | ||
|
||
inline fun withPromise(promise: Promise, closure: () -> Any?) { | ||
try { | ||
val result = closure() | ||
promise.resolve(result) | ||
} catch (e: Throwable) { | ||
e.printStackTrace() | ||
promise.reject("Error", e.message, e.cause) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters