169 похожих чатов

1 ответов

7 просмотров

// @flow import { arc } from 'd3-shape'; import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; import Svg, { Path } from 'react-native-svg'; import { LIGHT_FONT, REGULAR_FONT, } from '../resources/constants'; type Props = { size: number, progress: number, color: string, text: string, notFilledColor: string, }; const styles = StyleSheet.create({ smallText: { fontFamily: REGULAR_FONT, fontSize: 13, fontWeight: 'normal', fontStyle: 'normal', letterSpacing: 0, textAlign: 'center', color: '#919193', }, absolute: { position: 'absolute', }, container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, text: { fontFamily: LIGHT_FONT, fontSize: 29, fontWeight: '300', fontStyle: 'normal', letterSpacing: 0, textAlign: 'center', color: '#000000', }, }); export default class CircleProgress extends React.PureComponent<Props> { static defaultProps = { notFilledColor: '#f5f5f7', }; render() { const { size, text, color, progress, notFilledColor, } = this.props; const realProgress = Number.isNaN(progress) ? 0 : Math.max(0, Math.min(1, progress)); const r1 = (size / 2) - 4; const r2 = size / 2; const backgroundPath = arc() .innerRadius(r1) .outerRadius(r2) .startAngle(0) .endAngle(realProgress * 2 * Math.PI); const backgroundPath2 = arc() .innerRadius(r1) .outerRadius(r2) .startAngle(0) .endAngle(2 * Math.PI); return ( <View style={[{ width: size, height: size }, styles.container]}> <View style={styles.absolute}> <Svg height={size} width={size} > <Path d={backgroundPath2()} fill={notFilledColor} x={size / 2} y={size / 2} /> <Path d={backgroundPath()} fill={color} x={size / 2} y={size / 2} /> </Svg> </View> <Text style={styles.text}> {Math.round(realProgress * 100)}% </Text> <Text numberOfLines={1} style={styles.smallText} > {text} </Text> </View> ); } }

Похожие вопросы

Обсуждают сегодня

Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
10
А чем вам питонисты не угодили?😂
.
79
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
Есть предложения, как подобное можно упростить?
Hemul GM
12
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
У меня вопросик назрел. Почему, создав класс без наследования и реализации деструктора Destroy, деструктор не вызывался при free. Потом указал наследование от tobject и overri...
Сергей Бычков
9
@y0zhig @shizzard А можно я опишу цель и может вообще ерланг мне не подходит. На текущий момент как я понимаю у ерланга есть легковесные потоки и задача выполняется в каком т...
Дмитрий Спиридонов
5
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
86
Такой вопросец - есть функция function MySuperDuperConcat(const a: array of AnsiString): AnsiString; Как мне в её теле сделать вот так? Result:=Concat(a); А не грустный вариан...
notme
15
just use free version ?? pycharm has a free version
Fan / Ac
9
Карта сайта