turbo-native-initializer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/CODE_OF_CONDUCT.md +84 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +53 -0
  6. data/Rakefile +2 -0
  7. data/exe/turbo-native-initializer +3 -0
  8. data/lib/turbo-native-initializer.rb +1 -0
  9. data/lib/turbo_native_initializer/generator.rb +79 -0
  10. data/lib/turbo_native_initializer/templates/android_stack/app/.gitignore +1 -0
  11. data/lib/turbo_native_initializer/templates/android_stack/app/build.gradle.kts.tt +44 -0
  12. data/lib/turbo_native_initializer/templates/android_stack/app/proguard-rules.pro +21 -0
  13. data/lib/turbo_native_initializer/templates/android_stack/app/src/debug/AndroidManifest.xml.tt +4 -0
  14. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/AndroidManifest.xml.tt +29 -0
  15. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/assets/json/configuration.json +11 -0
  16. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/base/NavDestination.kt.tt +69 -0
  17. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebFragment.kt.tt +37 -0
  18. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebHomeFragment.kt.tt +15 -0
  19. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebModalFragment.kt.tt +17 -0
  20. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainActivity.kt.tt +18 -0
  21. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainSessionNavHostFragment.kt.tt +37 -0
  22. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/util/Constants.kt.tt +8 -0
  23. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_enter.xml +10 -0
  24. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_exit.xml +7 -0
  25. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_pop_enter.xml +15 -0
  26. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_pop_exit.xml +15 -0
  27. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/overshoot_interpolator.xml +4 -0
  28. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/drawable/ic_close.xml +5 -0
  29. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/drawable/ic_launcher_foreground.xml +17 -0
  30. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/activity_main.xml.tt +17 -0
  31. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/fragment_web_home.xml +36 -0
  32. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/toolbar_progress.xml +13 -0
  33. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/menu/web.xml +14 -0
  34. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  35. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  36. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  37. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  38. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  39. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  40. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  41. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  42. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/values/colors.xml +5 -0
  43. data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/values/themes.xml.tt +5 -0
  44. data/lib/turbo_native_initializer/templates/android_stack/build.gradle.kts +5 -0
  45. data/lib/turbo_native_initializer/templates/android_stack/gradle/wrapper/gradle-wrapper.jar +0 -0
  46. data/lib/turbo_native_initializer/templates/android_stack/gradle/wrapper/gradle-wrapper.properties +6 -0
  47. data/lib/turbo_native_initializer/templates/android_stack/gradle.properties +23 -0
  48. data/lib/turbo_native_initializer/templates/android_stack/gradlew +185 -0
  49. data/lib/turbo_native_initializer/templates/android_stack/gradlew.bat +89 -0
  50. data/lib/turbo_native_initializer/templates/android_stack/local.properties +10 -0
  51. data/lib/turbo_native_initializer/templates/android_stack/settings.gradle.kts.tt +17 -0
  52. data/lib/turbo_native_initializer/templates/android_tabs/app/.gitignore +1 -0
  53. data/lib/turbo_native_initializer/templates/android_tabs/app/build.gradle.kts.tt +44 -0
  54. data/lib/turbo_native_initializer/templates/android_tabs/app/proguard-rules.pro +21 -0
  55. data/lib/turbo_native_initializer/templates/android_tabs/app/src/debug/AndroidManifest.xml.tt +4 -0
  56. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/AndroidManifest.xml.tt +29 -0
  57. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/assets/json/configuration.json +11 -0
  58. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/base/NavDestination.kt.tt +69 -0
  59. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebFragment.kt.tt +29 -0
  60. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebHomeFragment.kt.tt +15 -0
  61. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebModalFragment.kt.tt +17 -0
  62. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainActivity.kt.tt +47 -0
  63. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/TabOneSessionNavHostFragment.kt.tt +37 -0
  64. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/TabTwoSessionNavHostFragment.kt.tt +37 -0
  65. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/util/Constants.kt.tt +8 -0
  66. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_enter.xml +10 -0
  67. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_exit.xml +7 -0
  68. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_pop_enter.xml +15 -0
  69. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_pop_exit.xml +15 -0
  70. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/overshoot_interpolator.xml +4 -0
  71. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_close.xml +5 -0
  72. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_home.xml +5 -0
  73. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_launcher_foreground.xml +17 -0
  74. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_settings.xml +5 -0
  75. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/activity_main.xml.tt +34 -0
  76. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/fragment_web_home.xml +36 -0
  77. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/toolbar_progress.xml +13 -0
  78. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/menu/bottom_navigation_menu.xml +12 -0
  79. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/menu/web.xml +14 -0
  80. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  81. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  82. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  83. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  84. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  85. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  86. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  87. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  88. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/values/colors.xml +5 -0
  89. data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/values/themes.xml.tt +5 -0
  90. data/lib/turbo_native_initializer/templates/android_tabs/build.gradle.kts +5 -0
  91. data/lib/turbo_native_initializer/templates/android_tabs/gradle/wrapper/gradle-wrapper.jar +0 -0
  92. data/lib/turbo_native_initializer/templates/android_tabs/gradle/wrapper/gradle-wrapper.properties +6 -0
  93. data/lib/turbo_native_initializer/templates/android_tabs/gradle.properties +23 -0
  94. data/lib/turbo_native_initializer/templates/android_tabs/gradlew +185 -0
  95. data/lib/turbo_native_initializer/templates/android_tabs/gradlew.bat +89 -0
  96. data/lib/turbo_native_initializer/templates/android_tabs/local.properties +10 -0
  97. data/lib/turbo_native_initializer/templates/android_tabs/settings.gradle.kts.tt +17 -0
  98. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Configuration/Info.plist +29 -0
  99. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Configuration/path-configuration.json +10 -0
  100. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/ErrorPresenter.swift +74 -0
  101. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/TurboNavigationController.swift +123 -0
  102. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/ViewController.swift +20 -0
  103. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Delegates/AppDelegate.swift +8 -0
  104. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Delegates/SceneDelegate.swift.tt +139 -0
  105. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  106. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  107. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/turbo.png +0 -0
  108. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/Contents.json +6 -0
  109. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/Contents.json +21 -0
  110. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/turbo.png +0 -0
  111. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Base.lproj/LaunchScreen.storyboard +39 -0
  112. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Base.lproj/Main.storyboard.tt +32 -0
  113. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/TurboNativeProject.swift.tt +10 -0
  114. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.pbxproj.tt +436 -0
  115. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  116. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  117. data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +14 -0
  118. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Configuration/Info.plist +29 -0
  119. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Configuration/path-configuration.json +10 -0
  120. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/ErrorPresenter.swift +74 -0
  121. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/TurboNavigationController.swift +123 -0
  122. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/ViewController.swift +20 -0
  123. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Delegates/AppDelegate.swift +8 -0
  124. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Delegates/SceneDelegate.swift.tt +156 -0
  125. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  126. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  127. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/turbo.png +0 -0
  128. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/Contents.json +6 -0
  129. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/Contents.json +21 -0
  130. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/turbo.png +0 -0
  131. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Base.lproj/LaunchScreen.storyboard +39 -0
  132. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Base.lproj/Main.storyboard +69 -0
  133. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/TurboNativeProject.swift.tt +10 -0
  134. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.pbxproj.tt +436 -0
  135. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  136. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  137. data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +14 -0
  138. data/lib/turbo_native_initializer/version.rb +3 -0
  139. data/lib/turbo_native_initializer.rb +5 -0
  140. metadata +199 -0
@@ -0,0 +1,69 @@
1
+ package <%= package_name %>.base
2
+
3
+ import android.net.Uri
4
+ import android.view.MenuItem
5
+ import androidx.browser.customtabs.CustomTabColorSchemeParams
6
+ import androidx.browser.customtabs.CustomTabsIntent
7
+ import androidx.browser.customtabs.CustomTabsIntent.SHARE_STATE_ON
8
+ import androidx.navigation.NavOptions
9
+ import androidx.navigation.navOptions
10
+ import dev.hotwire.turbo.config.TurboPathConfigurationProperties
11
+ import dev.hotwire.turbo.config.context
12
+ import <%= package_name %>.R
13
+ import <%= package_name %>.util.BASE_URL
14
+ import dev.hotwire.turbo.nav.TurboNavDestination
15
+ import dev.hotwire.turbo.nav.TurboNavPresentationContext.MODAL
16
+
17
+ interface NavDestination : TurboNavDestination {
18
+ val menuProgress: MenuItem?
19
+ get() = toolbarForNavigation()?.menu?.findItem(R.id.menu_progress)
20
+
21
+ override fun shouldNavigateTo(newLocation: String): Boolean {
22
+ return when (isNavigable(newLocation)) {
23
+ true -> true
24
+ else -> { launchCustomTab(newLocation); false }
25
+ }
26
+ }
27
+
28
+ override fun getNavigationOptions(
29
+ newLocation: String,
30
+ newPathProperties: TurboPathConfigurationProperties
31
+ ): NavOptions {
32
+ return when (newPathProperties.context) {
33
+ MODAL -> slideAnimation()
34
+ else -> super.getNavigationOptions(newLocation, newPathProperties)
35
+ }
36
+ }
37
+
38
+ private fun isNavigable(location: String): Boolean {
39
+ return location.startsWith(BASE_URL)
40
+ }
41
+
42
+ private fun launchCustomTab(location: String) {
43
+ val context = fragment.context ?: return
44
+ val color = context.getColor(R.color.white)
45
+ val colorParams = CustomTabColorSchemeParams.Builder()
46
+ .setToolbarColor(color)
47
+ .setNavigationBarColor(color)
48
+ .build()
49
+
50
+ CustomTabsIntent.Builder()
51
+ .setShowTitle(true)
52
+ .setShareState(SHARE_STATE_ON)
53
+ .setUrlBarHidingEnabled(false)
54
+ .setDefaultColorSchemeParams(colorParams)
55
+ .build()
56
+ .launchUrl(context, Uri.parse(location))
57
+ }
58
+
59
+ private fun slideAnimation(): NavOptions {
60
+ return navOptions {
61
+ anim {
62
+ enter = R.anim.nav_slide_enter
63
+ exit = R.anim.nav_slide_exit
64
+ popEnter = R.anim.nav_slide_pop_enter
65
+ popExit = R.anim.nav_slide_pop_exit
66
+ }
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,29 @@
1
+ package <%= package_name %>.features.web
2
+
3
+ import android.os.Bundle
4
+ import android.view.View
5
+ import <%= package_name %>.R
6
+ import <%= package_name %>.base.NavDestination
7
+ import dev.hotwire.turbo.fragments.TurboWebFragment
8
+ import dev.hotwire.turbo.nav.TurboNavGraphDestination
9
+ import dev.hotwire.turbo.visit.TurboVisitAction.REPLACE
10
+ import dev.hotwire.turbo.visit.TurboVisitOptions
11
+
12
+ @TurboNavGraphDestination(uri = "turbo://fragment/web")
13
+ open class WebFragment : TurboWebFragment(), NavDestination {
14
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
15
+ super.onViewCreated(view, savedInstanceState); setupMenu()
16
+ }
17
+
18
+ override fun onFormSubmissionStarted(location: String) {
19
+ menuProgress?.isVisible = true
20
+ }
21
+
22
+ override fun onFormSubmissionFinished(location: String) {
23
+ menuProgress?.isVisible = false
24
+ }
25
+
26
+ private fun setupMenu() {
27
+ toolbarForNavigation()?.inflateMenu(R.menu.web)
28
+ }
29
+ }
@@ -0,0 +1,15 @@
1
+ package <%= package_name %>.features.web
2
+
3
+ import android.os.Bundle
4
+ import android.view.LayoutInflater
5
+ import android.view.View
6
+ import android.view.ViewGroup
7
+ import <%= package_name %>.R
8
+ import dev.hotwire.turbo.nav.TurboNavGraphDestination
9
+
10
+ @TurboNavGraphDestination(uri = "turbo://fragment/web/home")
11
+ class WebHomeFragment : WebFragment() {
12
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
13
+ return inflater.inflate(R.layout.fragment_web_home, container, false)
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ package <%= package_name %>.features.web
2
+
3
+ import android.os.Bundle
4
+ import android.view.View
5
+ import dev.hotwire.turbo.nav.TurboNavGraphDestination
6
+ import <%= package_name %>.R
7
+
8
+ @TurboNavGraphDestination(uri = "turbo://fragment/web/modal")
9
+ class WebModalFragment : WebFragment() {
10
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
11
+ super.onViewCreated(view, savedInstanceState); initToolbar()
12
+ }
13
+
14
+ private fun initToolbar() {
15
+ toolbarForNavigation()?.navigationIcon = context?.getDrawable(R.drawable.ic_close)
16
+ }
17
+ }
@@ -0,0 +1,47 @@
1
+ package <%= package_name %>.main
2
+
3
+ import android.os.Bundle
4
+ import android.widget.ViewFlipper
5
+ import androidx.appcompat.app.AppCompatActivity
6
+ import com.google.android.material.bottomnavigation.BottomNavigationView
7
+ import dev.hotwire.turbo.activities.TurboActivity
8
+ import dev.hotwire.turbo.delegates.TurboActivityDelegate
9
+ import <%= package_name %>.R
10
+
11
+ class MainActivity : AppCompatActivity(), TurboActivity {
12
+ override lateinit var delegate: TurboActivityDelegate
13
+
14
+ override fun onCreate(savedInstanceState: Bundle?) {
15
+ super.onCreate(savedInstanceState)
16
+ setContentView(R.layout.activity_main)
17
+
18
+ delegate = TurboActivityDelegate(this, R.id.tab_one_nav_host)
19
+ delegate.registerNavHostFragment(R.id.tab_one_nav_host)
20
+ delegate.registerNavHostFragment(R.id.tab_two_nav_host)
21
+
22
+ setupBottomNavigationView()
23
+ }
24
+
25
+ private fun setupBottomNavigationView() {
26
+ val viewFliper = findViewById<ViewFlipper>(R.id.view_flipper)
27
+ val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottom_navigation_view)
28
+
29
+ bottomNavigationView.setOnItemSelectedListener {
30
+ when (it.itemId) {
31
+ R.id.tab_item_one -> {
32
+ viewFliper.displayedChild = 0
33
+ delegate.currentNavHostFragmentId = R.id.tab_one_nav_host
34
+ true
35
+ }
36
+ R.id.tab_item_two -> {
37
+ viewFliper.displayedChild = 1
38
+ delegate.currentNavHostFragmentId = R.id.tab_two_nav_host
39
+ true
40
+ }
41
+ else -> {
42
+ throw RuntimeException("Invalid tab")
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,37 @@
1
+ package <%= package_name %>.main
2
+
3
+ import android.webkit.WebView
4
+ import androidx.appcompat.app.AppCompatActivity
5
+ import androidx.fragment.app.Fragment
6
+ import dev.hotwire.turbo.config.TurboPathConfiguration
7
+ import <%= package_name %>.features.web.WebFragment
8
+ import <%= package_name %>.features.web.WebHomeFragment
9
+ import <%= package_name %>.features.web.WebModalFragment
10
+ import <%= package_name %>.util.CURRENT_URL_1
11
+ import dev.hotwire.turbo.session.TurboSessionNavHostFragment
12
+ import kotlin.reflect.KClass
13
+
14
+ @Suppress("unused")
15
+ class TabOneSessionNavHostFragment : TurboSessionNavHostFragment() {
16
+ override val sessionName = "main"
17
+
18
+ override val startLocation = CURRENT_URL_1
19
+
20
+ override val registeredActivities: List<KClass<out AppCompatActivity>>
21
+ get() = listOf()
22
+
23
+ override val registeredFragments: List<KClass<out Fragment>>
24
+ get() = listOf(WebFragment::class, WebHomeFragment::class, WebModalFragment::class)
25
+
26
+ override val pathConfigurationLocation: TurboPathConfiguration.Location
27
+ get() = TurboPathConfiguration.Location(assetFilePath = "json/configuration.json")
28
+
29
+ override fun onSessionCreated() {
30
+ super.onSessionCreated()
31
+ session.webView.settings.userAgentString = customUserAgent(session.webView)
32
+ }
33
+
34
+ private fun customUserAgent(webView: WebView): String {
35
+ return "Turbo Native Android ${webView.settings.userAgentString}"
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ package <%= package_name %>.main
2
+
3
+ import android.webkit.WebView
4
+ import androidx.appcompat.app.AppCompatActivity
5
+ import androidx.fragment.app.Fragment
6
+ import dev.hotwire.turbo.config.TurboPathConfiguration
7
+ import <%= package_name %>.features.web.WebFragment
8
+ import <%= package_name %>.features.web.WebHomeFragment
9
+ import <%= package_name %>.features.web.WebModalFragment
10
+ import <%= package_name %>.util.CURRENT_URL_2
11
+ import dev.hotwire.turbo.session.TurboSessionNavHostFragment
12
+ import kotlin.reflect.KClass
13
+
14
+ @Suppress("unused")
15
+ class TabTwoSessionNavHostFragment : TurboSessionNavHostFragment() {
16
+ override val sessionName = "main"
17
+
18
+ override val startLocation = CURRENT_URL_2
19
+
20
+ override val registeredActivities: List<KClass<out AppCompatActivity>>
21
+ get() = listOf()
22
+
23
+ override val registeredFragments: List<KClass<out Fragment>>
24
+ get() = listOf(WebFragment::class, WebHomeFragment::class, WebModalFragment::class)
25
+
26
+ override val pathConfigurationLocation: TurboPathConfiguration.Location
27
+ get() = TurboPathConfiguration.Location(assetFilePath = "json/configuration.json")
28
+
29
+ override fun onSessionCreated() {
30
+ super.onSessionCreated()
31
+ session.webView.settings.userAgentString = customUserAgent(session.webView)
32
+ }
33
+
34
+ private fun customUserAgent(webView: WebView): String {
35
+ return "Turbo Native Android ${webView.settings.userAgentString}"
36
+ }
37
+ }
@@ -0,0 +1,8 @@
1
+ package <%= package_name %>.util
2
+
3
+ private const val DEVELOPMENT_URL = "http://10.0.2.2:3000"
4
+ private const val PRODUCTION_URL = "https://turbo-native-demo.glitch.me"
5
+
6
+ const val BASE_URL = PRODUCTION_URL
7
+ const val CURRENT_URL_1 = "$BASE_URL/"
8
+ const val CURRENT_URL_2 = "$BASE_URL/"
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <set xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:shareInterpolator="false">
4
+
5
+ <translate
6
+ android:interpolator="@anim/overshoot_interpolator"
7
+ android:fromYDelta="40%p"
8
+ android:toYDelta="0%p"
9
+ android:duration="300"/>
10
+ </set>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <set xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <alpha
4
+ android:fromAlpha="1.0"
5
+ android:toAlpha="1.0"
6
+ android:duration="300"/>
7
+ </set>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <set xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:shareInterpolator="false">
4
+
5
+ <alpha
6
+ android:fromAlpha="0.0"
7
+ android:toAlpha="1.0"
8
+ android:duration="300"/>
9
+
10
+ <translate
11
+ android:interpolator="@anim/overshoot_interpolator"
12
+ android:fromYDelta="-10%p"
13
+ android:toYDelta="0%p"
14
+ android:duration="300"/>
15
+ </set>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <set xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:shareInterpolator="false">
4
+
5
+ <alpha
6
+ android:fromAlpha="1.0"
7
+ android:toAlpha="0.0"
8
+ android:duration="300"/>
9
+
10
+ <translate
11
+ android:interpolator="@android:interpolator/decelerate_cubic"
12
+ android:fromYDelta="0%p"
13
+ android:toYDelta="100%p"
14
+ android:duration="300"/>
15
+ </set>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <overshootInterpolator
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:tension="1.1" />
@@ -0,0 +1,5 @@
1
+ <vector android:height="24dp" android:tint="#000000"
2
+ android:viewportHeight="24" android:viewportWidth="24"
3
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+ <path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
5
+ </vector>
@@ -0,0 +1,5 @@
1
+ <vector android:height="24dp" android:tint="#000000"
2
+ android:viewportHeight="24" android:viewportWidth="24"
3
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+ <path android:fillColor="@android:color/white" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
5
+ </vector>
@@ -0,0 +1,17 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="108dp"
3
+ android:height="108dp"
4
+ android:viewportWidth="108"
5
+ android:viewportHeight="108">
6
+ <group android:scaleX="0.21352941"
7
+ android:scaleY="0.21352941"
8
+ android:translateX="17.7"
9
+ android:translateY="17.7">
10
+ <path
11
+ android:pathData="M197.2,163.5c-1.7,-7.3 -6.3,-13.5 -12.6,-17.4c-4.4,-2.7 -9.4,-4.1 -14.6,-4c-0.7,0 -1.5,0 -2.2,0.1c-1.5,0.1 -2.9,0.4 -4.3,0.7c-5.8,1.3 -11.1,4.5 -14.9,9.1c-0.9,1 -1.8,2.2 -2.5,3.4c-2.7,4.4 -4.1,9.4 -4.1,14.6c0,0.7 0,1.5 0.1,2.2c0.1,1.5 0.3,3 0.7,4.4c1.4,5.8 4.6,11 9.1,14.8c1.1,0.9 2.3,1.8 3.5,2.5c4.4,2.7 9.4,4.1 14.6,4.1c0.7,0 1.5,0 2.2,-0.1c1.5,-0.1 3,-0.3 4.4,-0.7c12.6,-3.1 21.4,-14.3 21.4,-27.2c0,-0.7 0,-1.5 -0.1,-2.2C197.8,166.3 197.5,164.9 197.2,163.5z"
12
+ android:fillColor="#FFFFFF"/>
13
+ <path
14
+ android:pathData="M285.8,170c0,-64 -51.9,-115.8 -115.8,-115.8H0v51.6h73.6c-12.7,19 -19.4,41.3 -19.4,64.2c0,64 51.9,115.8 115.8,115.8h170v-51.6h-73.6C279,215.2 285.8,192.9 285.8,170zM254,172.9c-13.1,-4.7 -23.6,-7.2 -32.3,-8c0.1,1.7 0.2,3.4 0.2,5.1c0,2.7 -0.2,5.3 -0.6,7.9c9.9,8.2 19.1,19 27.8,32.8c3.7,5.8 1.9,13.5 -3.9,17.2s-13.5,1.9 -17.2,-3.9c-4.9,-8 -10.7,-15.3 -17.2,-22c-3.1,3.9 -6.7,7.4 -10.7,10.3c0.2,7.4 -0.4,14.7 -1.8,21.9c-1.9,9.7 -4.5,19.2 -8,28.5c-2.4,6.5 -9.5,9.9 -16,7.5c-1.7,-0.6 -3.2,-1.6 -4.5,-2.9c-3.4,-3.4 -4.6,-8.5 -2.9,-13.1c1.1,-3.1 2,-5.9 2.9,-8.7c1.3,-4.1 2.3,-7.8 3.1,-11.3c0.9,-4.1 1.6,-8.2 2,-12.4c-1.7,0.1 -3.4,0.2 -5.1,0.2c-2.6,0 -5.3,-0.2 -7.9,-0.6c-7.6,9.2 -18.2,18.6 -32.7,27.8c-5.8,3.7 -13.5,1.9 -17.2,-3.9s-1.9,-13.5 3.9,-17.2c8,-4.9 15.3,-10.7 22,-17.2c-3.9,-3 -7.3,-6.7 -10.2,-10.7c-1,0.1 -1.9,0.1 -2.9,0.1c-12.7,0 -28.2,-2.8 -47.5,-9.8c-6.5,-2.4 -9.8,-9.5 -7.5,-16c2.4,-6.5 9.6,-9.8 15.7,-7.6c13.1,4.7 23.6,7.2 32.3,8c-0.1,-1.7 -0.2,-3.4 -0.2,-5.1c0,-2.6 0.2,-5.3 0.6,-7.9c-9.2,-7.6 -18.6,-18.2 -27.8,-32.7c-3.7,-5.9 -1.9,-13.6 3.9,-17.3c5.9,-3.7 13.6,-1.9 17.3,3.9c4.9,8 10.7,15.3 17.2,22c3.1,-3.9 6.7,-7.4 10.7,-10.3c-0.2,-7.4 0.4,-14.7 1.8,-21.9c1.9,-9.7 4.5,-19.2 8,-28.5c2.4,-6.5 9.5,-9.8 16,-7.5c1.7,0.6 3.2,1.6 4.5,2.9c3.4,3.4 4.6,8.5 2.9,13.1c-1.1,3.1 -2,5.9 -2.9,8.7c-1.3,4.1 -2.3,7.8 -3.1,11.3c-0.9,4.1 -1.6,8.2 -2,12.4c1.7,-0.1 3.4,-0.2 5.1,-0.2c2.7,0 5.3,0.2 7.9,0.6c8.2,-9.9 19,-19.1 32.8,-27.8c5.8,-3.7 13.5,-1.9 17.2,3.9c3.7,5.9 1.9,13.6 -3.9,17.3c-8,4.9 -15.3,10.7 -22,17.2c4,3 7.4,6.7 10.3,10.7c13.3,-0.5 29.5,2.1 50.4,9.7c6.4,2.4 9.6,9.4 7.4,15.8C267.6,171.7 260.5,175.2 254,172.9z"
15
+ android:fillColor="#FFFFFF"/>
16
+ </group>
17
+ </vector>
@@ -0,0 +1,5 @@
1
+ <vector android:height="24dp" android:tint="#000000"
2
+ android:viewportHeight="24" android:viewportWidth="24"
3
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+ <path android:fillColor="@android:color/white" android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
5
+ </vector>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".main.MainActivity">
8
+
9
+ <ViewFlipper
10
+ android:id="@+id/view_flipper"
11
+ android:layout_width="match_parent"
12
+ android:layout_height="0dp"
13
+ app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
14
+ app:layout_constraintTop_toTopOf="parent">
15
+ <androidx.fragment.app.FragmentContainerView
16
+ android:id="@+id/tab_one_nav_host"
17
+ android:name="<%= package_name %>.main.TabOneSessionNavHostFragment"
18
+ android:layout_width="match_parent"
19
+ android:layout_height="match_parent" />
20
+ <androidx.fragment.app.FragmentContainerView
21
+ android:id="@+id/tab_two_nav_host"
22
+ android:name="<%= package_name %>.main.TabTwoSessionNavHostFragment"
23
+ android:layout_width="match_parent"
24
+ android:layout_height="match_parent" />
25
+ </ViewFlipper>
26
+
27
+ <com.google.android.material.bottomnavigation.BottomNavigationView
28
+ android:id="@+id/bottom_navigation_view"
29
+ android:layout_width="match_parent"
30
+ android:layout_height="wrap_content"
31
+ app:layout_constraintBottom_toBottomOf="parent"
32
+ app:menu="@menu/bottom_navigation_menu" />
33
+
34
+ </androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <androidx.constraintlayout.widget.ConstraintLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent">
7
+
8
+ <com.google.android.material.appbar.AppBarLayout
9
+ android:id="@+id/app_bar"
10
+ android:layout_width="match_parent"
11
+ android:layout_height="56dp"
12
+ app:layout_constraintEnd_toEndOf="parent"
13
+ app:layout_constraintStart_toStartOf="parent"
14
+ app:layout_constraintTop_toTopOf="parent">
15
+
16
+ <FrameLayout
17
+ android:layout_width="match_parent"
18
+ android:layout_height="match_parent">
19
+
20
+ <com.google.android.material.appbar.MaterialToolbar
21
+ android:id="@+id/toolbar"
22
+ android:layout_width="match_parent"
23
+ android:layout_height="wrap_content" />
24
+
25
+ </FrameLayout>
26
+
27
+ </com.google.android.material.appbar.AppBarLayout>
28
+
29
+ <include
30
+ layout="@layout/turbo_view"
31
+ android:layout_width="match_parent"
32
+ android:layout_height="0dp"
33
+ app:layout_constraintBottom_toBottomOf="parent"
34
+ app:layout_constraintTop_toBottomOf="@+id/app_bar" />
35
+
36
+ </androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:layout_width="wrap_content"
4
+ android:layout_height="match_parent">
5
+
6
+ <ProgressBar
7
+ android:layout_width="40dp"
8
+ android:layout_height="24dp"
9
+ android:layout_gravity="center"
10
+ android:layout_marginEnd="12dp"
11
+ android:indeterminateTint="?colorSecondary" />
12
+
13
+ </FrameLayout>
@@ -0,0 +1,12 @@
1
+ <menu xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <item
3
+ android:id="@+id/tab_item_one"
4
+ android:enabled="true"
5
+ android:icon="@drawable/ic_home"
6
+ android:title="Home"/>
7
+ <item
8
+ android:id="@+id/tab_item_two"
9
+ android:enabled="true"
10
+ android:icon="@drawable/ic_settings"
11
+ android:title="Settings"/>
12
+ </menu>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools">
5
+
6
+ <item
7
+ android:id="@+id/menu_progress"
8
+ android:title="Loading..."
9
+ android:visible="false"
10
+ app:actionLayout="@layout/toolbar_progress"
11
+ app:showAsAction="always"
12
+ tools:ignore="AlwaysShowAction" />
13
+
14
+ </menu>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <background android:drawable="@color/black"/>
4
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
5
+ </adaptive-icon>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <background android:drawable="@color/black"/>
4
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
5
+ </adaptive-icon>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <color name="black">#FF000000</color>
4
+ <color name="white">#FFFFFFFF</color>
5
+ </resources>
@@ -0,0 +1,5 @@
1
+ <resources xmlns:tools="http://schemas.android.com/tools">
2
+ <style name="Theme.<%= name %>" parent="Theme.Material3.DayNight.NoActionBar">
3
+ <!-- Customize your theme here. -->
4
+ </style>
5
+ </resources>
@@ -0,0 +1,5 @@
1
+ // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+ plugins {
3
+ id("com.android.application") version "8.1.1" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.0" apply false
5
+ }
@@ -0,0 +1,6 @@
1
+ #Sat Aug 26 21:08:07 BRT 2023
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5
+ zipStoreBase=GRADLE_USER_HOME
6
+ zipStorePath=wrapper/dists
@@ -0,0 +1,23 @@
1
+ # Project-wide Gradle settings.
2
+ # IDE (e.g. Android Studio) users:
3
+ # Gradle settings configured through the IDE *will override*
4
+ # any settings specified in this file.
5
+ # For more details on how to configure your build environment visit
6
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
7
+ # Specifies the JVM arguments used for the daemon process.
8
+ # The setting is particularly useful for tweaking memory settings.
9
+ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10
+ # When configured, Gradle will run in incubating parallel mode.
11
+ # This option should only be used with decoupled projects. More details, visit
12
+ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13
+ # org.gradle.parallel=true
14
+ # AndroidX package structure to make it clearer which packages are bundled with the
15
+ # Android operating system, and which are packaged with your app's APK
16
+ # https://developer.android.com/topic/libraries/support-library/androidx-rn
17
+ android.useAndroidX=true
18
+ # Kotlin code style for this project: "official" or "obsolete":
19
+ kotlin.code.style=official
20
+ # Enables namespacing of each library's R class so that its R class includes only the
21
+ # resources declared in the library itself and none from the library's dependencies,
22
+ # thereby reducing the size of the R class for that library
23
+ android.nonTransitiveRClass=true