Compare commits
	
		
			2 Commits
		
	
	
		
			087b732fa5
			...
			4edf0f7352
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4edf0f7352 | |||
| 5529b3dafc | 
| @@ -7,10 +7,9 @@ import androidx.activity.compose.setContent | ||||
| import androidx.compose.foundation.background | ||||
| import androidx.compose.foundation.layout.Box | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||
| import androidx.compose.foundation.layout.Spacer | ||||
| import androidx.compose.foundation.layout.height | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.magnifier | ||||
| import androidx.compose.foundation.rememberScrollState | ||||
| import androidx.compose.foundation.verticalScroll | ||||
| import androidx.compose.material.icons.Icons | ||||
| @@ -39,7 +38,6 @@ import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.input.nestedscroll.nestedScroll | ||||
| import androidx.compose.ui.text.style.TextOverflow | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.TextUnit | ||||
| import androidx.compose.ui.unit.dp | ||||
| import androidx.compose.ui.unit.sp | ||||
| import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost | ||||
| @@ -51,14 +49,12 @@ import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine | ||||
| import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer | ||||
| import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart | ||||
| import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState | ||||
| import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent | ||||
| import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent | ||||
| import com.patrykandpatrick.vico.compose.common.component.shapeComponent | ||||
| import com.patrykandpatrick.vico.compose.common.fill | ||||
| import com.patrykandpatrick.vico.compose.common.shape.rounded | ||||
| import com.patrykandpatrick.vico.compose.common.vicoTheme | ||||
| import com.patrykandpatrick.vico.core.cartesian.Zoom | ||||
| import com.patrykandpatrick.vico.core.cartesian.axis.BaseAxis | ||||
| import com.patrykandpatrick.vico.core.cartesian.axis.HorizontalAxis | ||||
| import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis | ||||
| import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer | ||||
| @@ -71,15 +67,10 @@ import com.patrykandpatrick.vico.core.common.component.LineComponent | ||||
| import com.patrykandpatrick.vico.core.common.component.TextComponent | ||||
| import com.patrykandpatrick.vico.core.common.shape.CorneredShape | ||||
| import ru.vendetti.bitcoin_summarizer.ui.theme.BitcoinSummarizerTheme | ||||
| import ru.vendetti.bitcoin_summarizer.ui.theme.EnglishViolet | ||||
| import ru.vendetti.bitcoin_summarizer.ui.theme.Flame | ||||
| import ru.vendetti.bitcoin_summarizer.ui.theme.Green2 | ||||
| import java.text.DateFormat | ||||
| import java.text.DecimalFormat | ||||
| import java.text.SimpleDateFormat | ||||
| import java.time.format.DateTimeFormatter | ||||
| import java.util.Date | ||||
| import kotlin.math.roundToInt | ||||
|  | ||||
| class MainActivity : ComponentActivity() { | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
| @@ -125,14 +116,14 @@ fun CryptoScreen() { | ||||
|  | ||||
|     LaunchedEffect(fearGreedDataList) { | ||||
|         modelProducer.runTransaction { | ||||
|             var numberValues = Array<Int>(fearGreedDataList.count()) { | ||||
|             var numberValues = Array(fearGreedDataList.count()) { | ||||
|                 index -> | ||||
|                     fearGreedDataList[fearGreedDataList.count() - index - 1] | ||||
|                         .value.toInt() | ||||
|             } | ||||
|  | ||||
|             if(numberValues.isEmpty()) | ||||
|                 numberValues = Array<Int>(1) {0} | ||||
|                 numberValues = Array(1) {0} | ||||
|  | ||||
|             lineSeries { series(numberValues.toList()) } | ||||
|         } | ||||
| @@ -159,7 +150,7 @@ fun CryptoScreen() { | ||||
|                 ), | ||||
|                 title = { | ||||
|                     Text( | ||||
|                         "Bitcoin Summarizer!", | ||||
|                         "Bitcoin Summarizer", | ||||
|                         maxLines = 1, | ||||
|                         overflow = TextOverflow.Ellipsis | ||||
|                     ) | ||||
| @@ -220,7 +211,7 @@ fun CryptoScreen() { | ||||
|                             label = rememberAxisLabelComponent(MaterialTheme.colorScheme.onPrimary) | ||||
|                         ), | ||||
|                         bottomAxis = HorizontalAxis.rememberBottom( | ||||
|                             title = "last $fearGreedIndexDaysCount days", | ||||
|                             title = "последние $fearGreedIndexDaysCount дней", | ||||
|                             titleComponent = rememberTextComponent(MaterialTheme.colorScheme.onPrimary), | ||||
|                             line = rememberAxisLineComponent(fill(MaterialTheme.colorScheme.onPrimary)), | ||||
|                             label = rememberAxisLabelComponent(MaterialTheme.colorScheme.onPrimary) | ||||
| @@ -229,7 +220,7 @@ fun CryptoScreen() { | ||||
|                             remember { | ||||
|                                 HorizontalLine( | ||||
|                                     y = { 25.toDouble() }, | ||||
|                                     line = LineComponent(fill(Flame), 2f), | ||||
|                                     line = LineComponent(fill(Flame), 1f), | ||||
|                                     labelComponent = TextComponent( | ||||
|                                         background = | ||||
|                                         shapeComponent( | ||||
| @@ -240,14 +231,14 @@ fun CryptoScreen() { | ||||
|                                             ) | ||||
|                                         ), | ||||
|                                     ), | ||||
|                                     label = { "Fear" }, | ||||
|                                     label = { "Страх" }, | ||||
|                                     verticalLabelPosition = Position.Vertical.Top | ||||
|                                 ) | ||||
|                             }, | ||||
|                             remember { | ||||
|                                 HorizontalLine( | ||||
|                                     y = { 70.toDouble() }, | ||||
|                                     line = LineComponent(fill(Green2), 2f), | ||||
|                                     line = LineComponent(fill(Green2), 1f), | ||||
|                                     labelComponent = TextComponent( | ||||
|                                         background = | ||||
|                                         shapeComponent( | ||||
| @@ -258,7 +249,7 @@ fun CryptoScreen() { | ||||
|                                             ) | ||||
|                                         ), | ||||
|                                     ), | ||||
|                                     label = { "Greed" }, | ||||
|                                     label = { "Жадность" }, | ||||
|                                     verticalLabelPosition = Position.Vertical.Bottom | ||||
|                                 ) | ||||
|                             } | ||||
| @@ -267,13 +258,16 @@ fun CryptoScreen() { | ||||
|                     modelProducer = modelProducer, | ||||
|                 ) | ||||
|                 /* Fear Greed Chart End */ | ||||
|                 Spacer(modifier = Modifier.height(16.dp)) | ||||
|                 HorizontalDivider(thickness = 2.dp) | ||||
|                 Spacer(modifier = Modifier.height(16.dp)) | ||||
|                 Text( | ||||
|                     "Данные о Биткойне", | ||||
|                     "Данные о Биткоине", | ||||
|                     modifier = Modifier | ||||
|                         .align(alignment = Alignment.CenterHorizontally), | ||||
|                     fontSize = 24.sp | ||||
|                 ) | ||||
|                 Spacer(modifier = Modifier.height(16.dp)) | ||||
|                 val formatter = DecimalFormat("0.00") | ||||
|                 Text("Текущая цена: \n \$ ${formatter.format(bitcoinTicker.priceUsd.toFloat())}\n") | ||||
|                 Text("Суточный оборот: \n \$ ${bitcoinTicker.volume24hUsd}\n") | ||||
| @@ -293,12 +287,14 @@ fun CryptoScreen() { | ||||
|                 Text("Время последнего обновления: \n ${humanDate}\n") | ||||
|  | ||||
|                 HorizontalDivider(thickness = 2.dp) | ||||
|                 Spacer(modifier = Modifier.height(16.dp)) | ||||
|                 Text( | ||||
|                     "Глобальные данные", | ||||
|                     modifier = Modifier | ||||
|                         .align(alignment = Alignment.CenterHorizontally), | ||||
|                     fontSize = 24.sp | ||||
|                 ) | ||||
|                 Spacer(modifier = Modifier.height(16.dp)) | ||||
|                 Text("Общая капитализация крипторынка: \n \$ ${globalData.totalMarketCapUsd}\n") | ||||
|                 Text("Всего тикеров: \n ${globalData.activeCryptocurrencies}\n") | ||||
|                 Text("Суточный оборот всех криптовалют: \n \$ ${globalData.total24hVolumeUsd}\n") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user