Skip to content

Commit

Permalink
custom error views to android
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaronixon committed Sep 9, 2023
1 parent 52b690f commit cc90f67
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

## [0.0.5] - 2023-09-10

- Added android custom error screen

## [0.0.4] - 2023-09-09

- Added accent color (iOS)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
turbo-native-initializer (0.0.4)
turbo-native-initializer (0.0.5)
thor

GEM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ open class WebFragment : TurboWebFragment(), NavDestination {
else -> super.onVisitErrorReceived(location, errorCode)
}
}

override fun createErrorView(statusCode: Int): View {
return layoutInflater.inflate(R.layout.error_web, null)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:tint="@color/color_brand"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,5.99L19.53,19H4.47L12,5.99M12,2L1,21h22L12,2L12,2z"/>
<path android:fillColor="@android:color/white" android:pathData="M13,16l-2,0l0,2l2,0z"/>
<path android:fillColor="@android:color/white" android:pathData="M13,10l-2,0l0,5l2,0z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toTopOf="@+id/error_message"
app:srcCompat="@drawable/ic_warning" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/error_message"
style="?textAppearanceDisplaySmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Error loading page"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias=".45"
tools:layout_editor_absoluteX="24dp" />

<com.google.android.material.textview.MaterialTextView
style="?textAppearanceTitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="Pull-to-refresh to try again"
app:layout_constraintTop_toBottomOf="@id/error_message"
tools:layout_editor_absoluteX="24dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import dev.hotwire.turbo.fragments.TurboWebFragment
import dev.hotwire.turbo.nav.TurboNavGraphDestination

@TurboNavGraphDestination(uri = "turbo://fragment/web")
open class WebFragment : TurboWebFragment(), NavDestination
open class WebFragment : TurboWebFragment(), NavDestination {
override fun createErrorView(statusCode: Int): View {
return layoutInflater.inflate(R.layout.error_web, null)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:tint="@color/color_brand"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,5.99L19.53,19H4.47L12,5.99M12,2L1,21h22L12,2L12,2z"/>
<path android:fillColor="@android:color/white" android:pathData="M13,16l-2,0l0,2l2,0z"/>
<path android:fillColor="@android:color/white" android:pathData="M13,10l-2,0l0,5l2,0z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toTopOf="@+id/error_message"
app:srcCompat="@drawable/ic_warning" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/error_message"
style="?textAppearanceDisplaySmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Error loading page"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias=".45"
tools:layout_editor_absoluteX="24dp" />

<com.google.android.material.textview.MaterialTextView
style="?textAppearanceTitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="Pull-to-refresh to try again"
app:layout_constraintTop_toBottomOf="@id/error_message"
tools:layout_editor_absoluteX="24dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion lib/turbo_native_initializer/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TurboNativeInitializer
VERSION = "0.0.4"
VERSION = "0.0.5"
end

0 comments on commit cc90f67

Please sign in to comment.