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
@override | |
void paint(Canvas canvas, Size size) { | |
final center = size.bottomCenter(Offset(0, -dotRadius)); | |
var radius = startBarRadius; | |
for (var layer = 0; layer < layers; layer++) { | |
final lengthOfHalfCircle = pi * radius; | |
final dotsNumber = (lengthOfHalfCircle / _dotsSizeWithSpacing).floor(); |
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
@override | |
void paint(Canvas canvas, Size size) { | |
final center = size.bottomCenter(Offset(0, -dotRadius)); | |
final lengthOfHalfCircle = pi * startBarRadius; | |
final dotsNumber = (lengthOfHalfCircle / _dotsSizeWithSpacing).floor(); | |
final angleStep = _halfCircle / (dotsNumber - 1); | |
var angle = _startAngle; |
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
class _DiagramPainter extends CustomPainter { | |
_DiagramPainter({ | |
required this.dotRadius, | |
required this.startBarRadius, | |
required this.layers, | |
required this.layersSpacing, | |
required this.dotsSpacing, | |
required this.progress, | |
required Color dotColor, | |
required Color progressDotColor, |
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
class HalfCircleProgressBar extends StatelessWidget { | |
const HalfCircleProgressBar({ | |
Key? key, | |
required this.progress, | |
required this.dotColor, | |
required this.progressDotColor, | |
this.dotRadius = _defaultDotRadius, | |
this.startBarRadius = _defaultStartBarRadius, | |
this.layers = _defaultLayers, | |
this.layersSpacing = _defaultLayersSpacing, |
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
class DestinationFragment : Fragment() { | |
//code... | |
@Inject | |
internal lateinit var renderer: Renderer<DestinationViewState> | |
private val viewModel by lazy { /* code ... */ } | |
//code... |
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
//EmptyQuery state | |
class EmptyQueryViewStateRenderer @Inject constructor(): ViewStateRenderer<DestinationViewState> { | |
override fun render(view: View, viewState: DestinationViewState) { | |
view.text_message.visibility = View.VISIBLE | |
view.progress.visibility = View.GONE | |
view.recyclerView_destinations.visibility = View.GONE | |
view.text_message.text = "Enter the city you want to flight" | |
} | |
} |
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
class DestinationViewStateRendererPicker : ViewStateRendererPicker<DestinationViewState> { | |
override fun pick(viewState: DestinationViewState): KClass<out ViewStateRenderer<DestinationViewState>> = | |
when { | |
viewState.query.isBlank() -> EmptyQueryViewStateRenderer::class | |
viewState.isLoading -> LoadingViewStateRenderer::class | |
viewState.destinations.isEmpty() -> EmptyViewStateRenderer::class | |
else -> RegularViewStateRenderer::class | |
} | |
} |
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
data class DestinationViewState( | |
val destinations: List<SpannableCity> = listOf(), | |
val query: String = "", | |
val isLoading: Boolean = false | |
) |
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
interface ViewStateRenderer<VS> { | |
fun render(view: View, viewState: VS) | |
} |
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
interface ViewStateRendererPicker<VS> { | |
fun pick(viewState: VS): KClass<out ViewStateRenderer<VS>> | |
} |
NewerOlder