Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 9dc0f42

Browse files
committed
#294 fixed detekt errors in sample/mpp-library module
1 parent 6fa16a1 commit 9dc0f42

File tree

27 files changed

+93
-61
lines changed

27 files changed

+93
-61
lines changed

sample/mpp-library/src/androidMain/kotlin/PreviewView.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
import android.content.Context
66
import android.util.AttributeSet
7-
import com.icerockdev.library.SharedFactory
8-
import com.icerockdev.library.universal.WidgetsScreen
97
import dev.icerock.moko.widgets.core.BasePreviewView
10-
import dev.icerock.moko.widgets.core.Theme
118
import dev.icerock.moko.widgets.core.screen.Screen
129

1310
class PreviewView @JvmOverloads constructor(
14-
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
11+
context: Context,
12+
attrs: AttributeSet? = null,
13+
defStyleAttr: Int = 0
1514
) : BasePreviewView(context, attrs, defStyleAttr) {
1615

1716
override fun createScreen(): Screen<*> {

sample/mpp-library/src/androidMain/kotlin/com/icerockdev/library/custom/MaterialButtonWidgetViewFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import dev.icerock.moko.widgets.core.bind
1717
import dev.icerock.moko.widgets.core.style.view.WidgetSize
1818
import dev.icerock.moko.widgets.core.utils.bind
1919

20+
@Suppress("EmptyDefaultConstructor")
2021
actual class MaterialButtonWidgetViewFactory actual constructor() : ViewFactory<ButtonWidget<out WidgetSize>> {
2122

2223
override fun <WS : WidgetSize> build(

sample/mpp-library/src/commonMain/kotlin/App.kt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ import dev.icerock.moko.widgets.sample.ScrollContentScreen
7979
import dev.icerock.moko.widgets.sample.SelectGalleryScreen
8080
import dev.icerock.moko.widgets.sample.TabsSampleScreen
8181

82+
@Suppress("EmptyDefaultConstructor")
8283
class App() : BaseApplication() {
8384

8485
object SystemInputId : InputWidget.Id
8586
object FloatingLabelInputId : InputWidget.Id
8687
object MultilineInputId : InputWidget.Id
8788

89+
@Suppress("MagicNumber")
8890
override val androidStatusBarColor: Color? = Color(0x4444AAFF)
8991

9092
override fun setup(): ScreenDesc<Args.Empty> {
@@ -93,8 +95,10 @@ class App() : BaseApplication() {
9395
padding = PaddingValues(padding = 16.0f)
9496
)
9597
factory[SystemInputId] = SystemInputViewFactory(margins = MarginValues(bottom = 16.0f))
96-
factory[FloatingLabelInputId] = FloatingLabelInputViewFactory(margins = MarginValues(bottom = 16.0f))
97-
factory[MultilineInputId] = MultilineInputViewFactory(margins = MarginValues(bottom = 16.0f))
98+
factory[FloatingLabelInputId] =
99+
FloatingLabelInputViewFactory(margins = MarginValues(bottom = 16.0f))
100+
factory[MultilineInputId] =
101+
MultilineInputViewFactory(margins = MarginValues(bottom = 16.0f))
98102
}
99103

100104
return registerScreen(RootNavigationScreen::class) {
@@ -109,7 +113,7 @@ class App() : BaseApplication() {
109113

110114
private fun registerGalleryScreen(
111115
theme: Theme,
112-
router: NavigationScreen.Router
116+
router: NavigationScreen.Router,
113117
): TypedScreenDesc<Args.Empty, SelectGalleryScreen> {
114118
return registerScreen(SelectGalleryScreen::class) {
115119
SelectGalleryScreen(
@@ -133,7 +137,7 @@ class App() : BaseApplication() {
133137

134138
private fun buildInputGalleryRouteInfo(
135139
theme: Theme,
136-
router: NavigationScreen.Router
140+
router: NavigationScreen.Router,
137141
): SelectGalleryScreen.RouteInfo {
138142
val inputScreen = registerScreen(InputWidgetGalleryScreen::class) {
139143
InputWidgetGalleryScreen(
@@ -162,7 +166,7 @@ class App() : BaseApplication() {
162166

163167
private fun buildSearchRouteInfo(
164168
theme: Theme,
165-
router: NavigationScreen.Router
169+
router: NavigationScreen.Router,
166170
): SelectGalleryScreen.RouteInfo {
167171
val searchScreen = registerScreen(ProductsSearchScreen::class) {
168172
ProductsSearchScreen(theme)
@@ -176,7 +180,7 @@ class App() : BaseApplication() {
176180

177181
private fun buildTabsRouteInfo(
178182
theme: Theme,
179-
router: NavigationScreen.Router
183+
router: NavigationScreen.Router,
180184
): SelectGalleryScreen.RouteInfo {
181185
val tabsTheme = Theme(theme) {
182186
TabsSampleScreen.configureDefaultTheme(this)
@@ -193,7 +197,7 @@ class App() : BaseApplication() {
193197

194198
private fun buildCollectionRouteInfo(
195199
theme: Theme,
196-
router: NavigationScreen.Router
200+
router: NavigationScreen.Router,
197201
): SelectGalleryScreen.RouteInfo {
198202
val collectionTheme = Theme(theme) {
199203
factory[CollectionWidget.DefaultCategory] = SimpleCollectionViewFactory(
@@ -215,9 +219,10 @@ class App() : BaseApplication() {
215219
)
216220
}
217221

222+
@Suppress("MagicNumber")
218223
private fun buildPostsRouteInfo(
219224
theme: Theme,
220-
router: NavigationScreen.Router
225+
router: NavigationScreen.Router,
221226
): SelectGalleryScreen.RouteInfo {
222227
val postsTheme = Theme(theme) {
223228
factory[PostsScreen.Id.Collection] = SimpleCollectionViewFactory(
@@ -240,7 +245,7 @@ class App() : BaseApplication() {
240245

241246
private fun buildPermissionsRouteInfo(
242247
theme: Theme,
243-
router: NavigationScreen.Router
248+
router: NavigationScreen.Router,
244249
): SelectGalleryScreen.RouteInfo {
245250
val screen = registerScreen(PermissionsScreen::class) {
246251
PermissionsScreen(theme)
@@ -254,7 +259,7 @@ class App() : BaseApplication() {
254259

255260
private fun buildMediaRouteInfo(
256261
theme: Theme,
257-
router: NavigationScreen.Router
262+
router: NavigationScreen.Router,
258263
): SelectGalleryScreen.RouteInfo {
259264
val screen = registerScreen(MediaScreen::class) {
260265
MediaScreen(theme)
@@ -266,8 +271,9 @@ class App() : BaseApplication() {
266271
)
267272
}
268273

274+
@Suppress("LongMethod", "MagicNumber")
269275
private fun oldDemo(
270-
router: NavigationScreen.Router
276+
router: NavigationScreen.Router,
271277
): TypedScreenDesc<Args.Empty, LoginScreen> {
272278
val sharedFactory = SharedFactory()
273279
val theme = AppTheme.baseTheme
@@ -322,7 +328,9 @@ class App() : BaseApplication() {
322328
val bottomRouter = createRouter()
323329

324330
val templateScreen = registerScreen(TemplateScreen::class) {
325-
TemplateScreen(navTitle = "Template".desc(), labelText = "Template Screen".desc(), theme = theme)
331+
TemplateScreen(navTitle = "Template".desc(),
332+
labelText = "Template Screen".desc(),
333+
theme = theme)
326334
}
327335

328336
val cartNavigation = registerScreen(CartNavigationScreen::class) {
@@ -433,7 +441,7 @@ class App() : BaseApplication() {
433441
}
434442

435443
class RegisterScreen(
436-
private val theme: Theme
444+
private val theme: Theme,
437445
) : WidgetScreen<Args.Empty>(), Resultable<RegisterScreen.Result>, NavigationItem {
438446
override val navigationBar: NavigationBar = NavigationBar.Normal(title = "Registration".desc())
439447

@@ -458,7 +466,7 @@ class RegisterScreen(
458466

459467
class LogoutScreen(
460468
private val theme: Theme,
461-
private val logoutRoute: Route<Unit>
469+
private val logoutRoute: Route<Unit>,
462470
) : WidgetScreen<Args.Empty>() {
463471
override fun createContentWidget() = with(theme) {
464472
container(size = WidgetSize.AsParent) {
@@ -475,9 +483,10 @@ class LogoutScreen(
475483
}
476484

477485
// TODO required for Android side... should be reworked if any ideas will be
486+
@Suppress("MagicNumber")
478487
class MainBottomNavigationScreen(
479488
router: Router,
480-
builder: BottomNavigationItem.Builder.() -> Unit
489+
builder: BottomNavigationItem.Builder.() -> Unit,
481490
) : BottomNavigationScreen(router, builder), NavigationItem {
482491
override val navigationBar: NavigationBar = NavigationBar.None
483492

@@ -493,12 +502,15 @@ class MainBottomNavigationScreen(
493502

494503
class RootNavigationScreen<T>(initialScreen: TypedScreenDesc<Args.Empty, T>, router: Router) :
495504
NavigationScreen<T>(initialScreen, router) where T : Screen<Args.Empty>, T : NavigationItem {
505+
506+
@Suppress("MagicNumber")
496507
override val androidStatusBarColor: Color? = Color(0x11AA11FF)
497508
}
498509

499-
class ProductsNavigationScreen(initialScreen: TypedScreenDesc<Args.Empty, ProductsScreen>, router: Router) :
500-
NavigationScreen<ProductsScreen>(initialScreen, router)
510+
class ProductsNavigationScreen(
511+
initialScreen: TypedScreenDesc<Args.Empty, ProductsScreen>,
512+
router: Router,
513+
) : NavigationScreen<ProductsScreen>(initialScreen, router)
501514

502515
class CartNavigationScreen(initialScreen: TypedScreenDesc<Args.Empty, CartScreen>, router: Router) :
503516
NavigationScreen<CartScreen>(initialScreen, router)
504-

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/AppTheme.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import dev.icerock.moko.widgets.core.style.view.TextStyle
3535
import dev.icerock.moko.widgets.core.style.view.rgba
3636
import dev.icerock.moko.widgets.core.utils.platformSpecific
3737

38+
@Suppress("MagicNumber")
3839
object AppTheme {
3940
object PostsCollection : CollectionWidget.Category
4041

@@ -189,8 +190,6 @@ object AppTheme {
189190
androidElevationEnabled = false
190191
)
191192
}
192-
193-
194193
// val errorTextStyle: TextStyle = TextStyle(
195194
// size = 12,
196195
// color = Color.redError,

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/custom/MaterialButtonWidgetViewFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ import dev.icerock.moko.widgets.core.widget.ButtonWidget
88
import dev.icerock.moko.widgets.core.ViewFactory
99
import dev.icerock.moko.widgets.core.style.view.WidgetSize
1010

11+
@Suppress("EmptyDefaultConstructor")
1112
expect class MaterialButtonWidgetViewFactory() : ViewFactory<ButtonWidget<out WidgetSize>>

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/sample/McommerceProfileSample.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ interface McommerceProfileViewModelContract {
8484
fun onSavePressed()
8585
}
8686

87+
@Suppress("EmptyDefaultConstructor")
8788
class McommerceProfileViewModel() : ViewModel(), McommerceProfileViewModelContract {
8889
override val nameField: FormField<String, StringDesc> = FormField("Aleksey", liveBlock { null })
8990
override val phoneField: FormField<String, StringDesc> =

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/sample/PostsSample.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class PostsScreen(
5757
}
5858
}
5959

60-
6160
interface PostsViewModelContract {
6261
val posts: LiveData<List<PostItem>>
6362

@@ -73,6 +72,7 @@ interface PostsViewModelContract {
7372
}
7473

7574
class PostsViewModel : ViewModel(), PostsViewModelContract {
75+
@Suppress("MagicNumber")
7676
private val _postsTitle: MutableLiveData<List<String>> = MutableLiveData(
7777
initialValue = List(20) { "Test $it post" }
7878
)

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/sample/UsersSample.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import kotlinx.coroutines.launch
2626

2727
class UsersScreen(
2828
private val theme: Theme,
29-
private val viewModel: UsersViewModelContract
29+
private val viewModel: UsersViewModelContract,
3030
) {
3131
fun createWidget(): Widget<WidgetSize.Const<SizeSpec.AsParent, SizeSpec.AsParent>> {
3232
return with(theme) {
@@ -70,7 +70,7 @@ interface UsersViewModelContract {
7070
}
7171

7272
class UsersViewModel(
73-
private val unitsFactory: UnitsFactory
73+
private val unitsFactory: UnitsFactory,
7474
) : ViewModel(), UsersViewModelContract {
7575
private val _loadNextPage = MutableLiveData(false)
7676
private val _items: MutableLiveData<List<Pair<String, String>>> = MutableLiveData(
@@ -119,6 +119,7 @@ class UsersViewModel(
119119
private var refreshJob: Job? = null
120120
private var nextPageJob: Job? = null
121121

122+
@Suppress("MagicNumber")
122123
override fun refresh(completion: () -> Unit) {
123124
if (refreshJob?.isActive == true || nextPageJob?.isActive == true) {
124125
completion()
@@ -135,6 +136,7 @@ class UsersViewModel(
135136
}
136137
}
137138

139+
@Suppress("MagicNumber")
138140
override fun loadNextPage() {
139141
if (refreshJob?.isActive == true || nextPageJob?.isActive == true) return
140142

@@ -155,22 +157,22 @@ class UsersViewModel(
155157
itemId: Long,
156158
name: String,
157159
avatarUrl: String,
158-
onClick: () -> Unit
160+
onClick: () -> Unit,
159161
): TableUnitItem
160162

161163
fun createUserCollectionUnit(
162164
itemId: Long,
163165
name: String,
164166
avatarUrl: String,
165-
onClick: () -> Unit
167+
onClick: () -> Unit,
166168
): CollectionUnitItem
167169

168170
fun createLoadingTableUnit(
169-
itemId: Long
171+
itemId: Long,
170172
): TableUnitItem
171173

172174
fun createLoadingCollectionUnit(
173-
itemId: Long
175+
itemId: Long,
174176
): CollectionUnitItem
175177
}
176178
}

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/units/LoadingUnitWidget.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import dev.icerock.moko.widgets.core.units.WidgetsCollectionUnitItem
1616
import dev.icerock.moko.widgets.core.units.WidgetsTableUnitItem
1717

1818
class LoadingUnitWidget(
19-
private val theme: Theme
19+
private val theme: Theme,
2020
) {
21+
@Suppress("MagicNumber")
2122
fun createWidget(data: LiveData<Unit>): Widget<WidgetSize.Const<SizeSpec.AsParent, SizeSpec.Exact>> {
2223
return with(theme) {
2324
container(
@@ -31,7 +32,7 @@ class LoadingUnitWidget(
3132
size = WidgetSize.Const(
3233
width = SizeSpec.Exact(24f),
3334
height = SizeSpec.Exact(24f)
34-
)//,
35+
) // ,
3536
// factory = DefaultProgressBarWidgetViewFactory(
3637
// DefaultProgressBarWidgetViewFactoryBase.Style(
3738
// color = Colors.black
@@ -45,7 +46,7 @@ class LoadingUnitWidget(
4546

4647
class TableUnitItem(
4748
theme: Theme,
48-
itemId: Long
49+
itemId: Long,
4950
) : WidgetsTableUnitItem<Unit>(itemId, Unit) {
5051
private val unitWidget = LoadingUnitWidget(theme)
5152

@@ -58,7 +59,7 @@ class LoadingUnitWidget(
5859

5960
class CollectionUnitItem(
6061
theme: Theme,
61-
itemId: Long
62+
itemId: Long,
6263
) : WidgetsCollectionUnitItem<Unit>(itemId, Unit) {
6364
private val unitWidget = LoadingUnitWidget(theme)
6465

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/units/PostCollectionUnitItem.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import dev.icerock.moko.widgets.core.widget.linear
1919
import dev.icerock.moko.widgets.core.style.view.SizeSpec
2020
import dev.icerock.moko.widgets.core.style.view.WidgetSize
2121
import dev.icerock.moko.widgets.core.widget.text
22-
import dev.icerock.moko.widgets.core.units.UnitItemRoot
2322
import dev.icerock.moko.widgets.core.units.WidgetsCollectionUnitItem
2423

2524
class PostCollectionUnitItem(
@@ -82,6 +81,7 @@ class PostCollectionUnitItem(
8281
}
8382
}
8483

84+
@Suppress("CommentSpacing")
8585
private fun Theme.createFooter(
8686
data: LiveData<PostsViewModelContract.PostItem>
8787
): Widget<out WidgetSize> {
@@ -112,8 +112,9 @@ class PostCollectionUnitItem(
112112
)
113113
)
114114

115+
@Suppress("CommentSpacing")
115116
return container(
116-
size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent)//,
117+
size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent)
117118
// factory = DefaultContainerWidgetViewFactory(
118119
// DefaultContainerWidgetViewFactoryBase.Style(
119120
// background = Background(
@@ -131,7 +132,7 @@ class PostCollectionUnitItem(
131132
) {
132133
center {
133134
linear(
134-
size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent)//,
135+
size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent) // ,
135136
// factory = DefaultLinearWidgetViewFactory(
136137
// DefaultLinearWidgetViewFactoryBase.Style(
137138
// padding = PaddingValues(8f)

0 commit comments

Comments
 (0)