-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from hotwired/form-submission-status
Implement the form submission adapter APIs
- Loading branch information
Showing
15 changed files
with
158 additions
and
7 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
22 changes: 21 additions & 1 deletion
22
demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebBottomSheetFragment.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,8 +1,28 @@ | ||
package dev.hotwire.turbo.demo.features.web | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import dev.hotwire.turbo.demo.R | ||
import dev.hotwire.turbo.demo.base.NavDestination | ||
import dev.hotwire.turbo.fragments.TurboWebBottomSheetDialogFragment | ||
import dev.hotwire.turbo.nav.TurboNavGraphDestination | ||
|
||
@TurboNavGraphDestination(uri = "turbo://fragment/web/modal/sheet") | ||
class WebBottomSheetFragment : TurboWebBottomSheetDialogFragment(), NavDestination | ||
class WebBottomSheetFragment : TurboWebBottomSheetDialogFragment(), NavDestination { | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setupMenu() | ||
} | ||
|
||
override fun onFormSubmissionStarted(location: String) { | ||
menuProgress?.isVisible = true | ||
} | ||
|
||
override fun onFormSubmissionFinished(location: String) { | ||
menuProgress?.isVisible = false | ||
} | ||
|
||
private fun setupMenu() { | ||
toolbarForNavigation()?.inflateMenu(R.menu.web) | ||
} | ||
} |
21 changes: 20 additions & 1 deletion
21
demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebFragment.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,19 +1,38 @@ | ||
package dev.hotwire.turbo.demo.features.web | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import dev.hotwire.turbo.demo.R | ||
import dev.hotwire.turbo.demo.base.NavDestination | ||
import dev.hotwire.turbo.demo.util.SIGN_IN_URL | ||
import dev.hotwire.turbo.fragments.TurboWebFragment | ||
import dev.hotwire.turbo.nav.TurboNavGraphDestination | ||
import dev.hotwire.turbo.visit.TurboVisitAction | ||
import dev.hotwire.turbo.visit.TurboVisitAction.REPLACE | ||
import dev.hotwire.turbo.visit.TurboVisitOptions | ||
|
||
@TurboNavGraphDestination(uri = "turbo://fragment/web") | ||
open class WebFragment : TurboWebFragment(), NavDestination { | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
setupMenu() | ||
} | ||
|
||
override fun onFormSubmissionStarted(location: String) { | ||
menuProgress?.isVisible = true | ||
} | ||
|
||
override fun onFormSubmissionFinished(location: String) { | ||
menuProgress?.isVisible = false | ||
} | ||
|
||
override fun onVisitErrorReceived(location: String, errorCode: Int) { | ||
when (errorCode) { | ||
401 -> navigate(SIGN_IN_URL, TurboVisitOptions(action = REPLACE)) | ||
else -> super.onVisitErrorReceived(location, errorCode) | ||
} | ||
} | ||
|
||
private fun setupMenu() { | ||
toolbarForNavigation()?.inflateMenu(R.menu.web) | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent"> | ||
|
||
<ProgressBar | ||
android:layout_width="40dp" | ||
android:layout_height="24dp" | ||
android:layout_gravity="center" | ||
android:layout_marginEnd="12dp" | ||
android:indeterminateTint="?colorSecondary" /> | ||
|
||
</FrameLayout> |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<item | ||
android:id="@+id/menu_progress" | ||
android:title="@string/menu_progress" | ||
android:visible="false" | ||
app:actionLayout="@layout/toolbar_progress" | ||
app:showAsAction="always" | ||
tools:ignore="AlwaysShowAction" /> | ||
|
||
</menu> |
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
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
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
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