Компоненты/Круглый лоадер

Круглый лоадер

31 января 2025

Три точки, бегущие волной.

Установка

npx astra-rn add circle-loader
pnpm dlx astra-rn add circle-loader
yarn dlx astra-rn add circle-loader
bunx --bun astra-rn add circle-loader

Файлы

index.tsx
НазадКинопараллаксДалееКруговая карусель

Вручную

Поставьте зависимости:

npm install react-native-reanimated react-native-svg
pnpm add react-native-reanimated react-native-svg
yarn add react-native-reanimated react-native-svg
bun add react-native-reanimated react-native-svg

Скопируйте эти файлы в src/shared/components/molecules/circle-loader/:

Проверьте алиас путей. Импорты в коде выше записаны так, как их пишет astra-rn add: @/shared/components, @/shared/utils и @/shared/hooks. Нужен алиас "@/*": ["./src/*"] в tsconfig.json — или поправьте импорты под свои пути.

Использование

import { View, StyleSheet } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { StatusBar } from "expo-status-bar";
import { useFonts } from "expo-font";

import { CircleLoadingIndicator } from "@/shared/components/molecules/circle-loader";
import { Showcase, useCustomize } from "~/showcase";

const CUSTOMIZE = [
  { key: "color", label: "Цвет точек", type: "color", default: "#ffffff" },
  { key: "radius", label: "Радиус точки", type: "slider", min: 2, max: 12, step: 1, unit: "px", default: 10 },
  { key: "spacing", label: "Промежуток", type: "slider", min: 0, max: 40, step: 1, unit: "px", default: 12 },
  { key: "duration", label: "Длительность", type: "slider", min: 150, max: 2000, step: 50, unit: "ms", default: 500 },
  { key: "background", label: "Фон", type: "color", default: "#0a0a0a" },
] as const;

export default function App() {
  const custom = useCustomize(CUSTOMIZE);
  return (
    <Showcase>
      <GestureHandlerRootView
        style={[styles.container, { backgroundColor: custom.background }]}
      >
        <StatusBar style="light" />

        <View style={styles.content}>
          <CircleLoadingIndicator
            dotSpacing={custom.spacing}
            dotRadius={custom.radius}
            dotColor={custom.color}
            style={{
              marginTop: 60,
            }}
            duration={custom.duration}
          />
        </View>
      </GestureHandlerRootView>
    </Showcase>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#0a0a0a",
    justifyContent: "center",
    alignItems: "center",
  },
  content: {
    paddingHorizontal: 20,
    gap: 0,
  },
  title: {
    fontSize: 28,
    fontWeight: "700",
    color: "#fff",
  },
  subtitle: {
    fontSize: 15,
    color: "#555",
  },
  card: {
    backgroundColor: "#141414",
    borderRadius: 16,
    overflow: "hidden",
    marginTop: 20,
  },
  triggerContent: {
    padding: 16,
  },
  triggerLeft: {
    flexDirection: "row",
    alignItems: "center",
    gap: 12,
  },
  triggerText: {
    fontSize: 16,
    fontWeight: "500",
    color: "#fff",
  },
  item: {
    flexDirection: "row",
    alignItems: "center",
    gap: 12,
    padding: 14,
    backgroundColor: "#1a1a1a",
    borderRadius: 12,
    marginBottom: 6,
  },
  itemText: {
    fontSize: 15,
    color: "#fff",
  },
  destructiveText: {
    color: "#ff453a",
  },
});

Пропсы

Пропс
Описание
dotColor?

Тип string

dotRadius?

Тип number

dotSpacing?

Тип number

duration?

Тип number

style?

Тип StyleProp<ViewStyle>