After correcting the design on chart

This commit is contained in:
Your Name 2026-09-18 19:23:56 +02:00
parent 4abe46f200
commit f242c9d210
5 changed files with 250 additions and 4 deletions

View File

@ -650,7 +650,7 @@ code + .copy-button {
<script type="text/javascript">
function configurationCacheProblems() { return (
// begin-report-data
{"diagnostics":[{"problem":[{"text":"Executing Gradle on JVM versions 16 and lower has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This will fail with an error in Gradle 9.0."}],"contextualLabel":"Executing Gradle on JVM versions 16 and lower has been deprecated.","documentationLink":"https://docs.gradle.org/8.12/userguide/upgrading_version_8.html#minimum_daemon_jvm_version","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"executing-gradle-on-jvm-versions-and-lower","displayName":"Executing Gradle on JVM versions 16 and lower has been deprecated."}],"solutions":[[{"text":"Use JVM 17 or greater to execute Gradle. Projects can continue to use older JVM versions via toolchains."}]]}],"problemsReport":{"totalProblemCount":1,"requestedTasks":"","documentationLink":"https://docs.gradle.org/8.12/userguide/problems-report.html","documentationLinkCaption":"Problem report","summaries":[]}}
{"diagnostics":[{"problem":[{"text":"Executing Gradle on JVM versions 16 and lower has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This will fail with an error in Gradle 9.0."}],"contextualLabel":"Executing Gradle on JVM versions 16 and lower has been deprecated.","documentationLink":"https://docs.gradle.org/8.12/userguide/upgrading_version_8.html#minimum_daemon_jvm_version","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"executing-gradle-on-jvm-versions-and-lower","displayName":"Executing Gradle on JVM versions 16 and lower has been deprecated."}],"solutions":[[{"text":"Use JVM 17 or greater to execute Gradle. Projects can continue to use older JVM versions via toolchains."}]]},{"problem":[{"text":"No variants exist that would match the request"}],"severity":"ERROR","contextualLabel":"Dependency requires at least JVM runtime version 11. This build uses a Java 8 JVM.","documentationLink":"https://docs.gradle.org/8.12/userguide/variant_model.html#sec:variant-select-errors","problemId":[{"name":"dependency-variant-resolution","displayName":"Variant resolution"},{"name":"no-compatible-variants","displayName":"No variants exist that would match the request"}]}],"problemsReport":{"totalProblemCount":2,"requestedTasks":"","documentationLink":"https://docs.gradle.org/8.12/userguide/problems-report.html","documentationLinkCaption":"Problem report","summaries":[]}}
// end-report-data
);}
</script>

View File

@ -0,0 +1,69 @@
/// Synthetic chart instrument for Candle Predict (display identity only).
///
/// OHLC always comes from the Prediqo backend — never from an external market.
///
/// Candle Predict uses a **single** active instrument. To change what the chart
/// shows, edit [candlePredictInstrument] (symbol, displayName, quoteCurrency).
class CandlePredictInstrument {
const CandlePredictInstrument({
required this.id,
required this.symbol,
required this.displayName,
required this.quoteCurrency,
this.instrumentType = 'SYNTHETIC',
this.priceDigits = 2,
});
/// Stable internal key (not shown on the chart).
final String id;
/// Short ticker, e.g. FO.
final String symbol;
/// Human-readable name, e.g. Full Option.
final String displayName;
/// Quote unit for the price, e.g. USDT.
final String quoteCurrency;
final String instrumentType;
/// Decimal places for price labels on the chart.
final int priceDigits;
/// Pair ticker, e.g. FO/USDT.
String get pairSymbol => '$symbol/$quoteCurrency';
/// Header line, e.g. FO/USDT — Full Option.
String get chartTitle => '$pairSymbol — $displayName';
/// Price subtitle, e.g. FO/USDT — 105.50.
String priceLabel(double price) =>
'$pairSymbol — ${price.toStringAsFixed(priceDigits)}';
CandlePredictInstrument copyWith({
String? id,
String? symbol,
String? displayName,
String? quoteCurrency,
String? instrumentType,
int? priceDigits,
}) {
return CandlePredictInstrument(
id: id ?? this.id,
symbol: symbol ?? this.symbol,
displayName: displayName ?? this.displayName,
quoteCurrency: quoteCurrency ?? this.quoteCurrency,
instrumentType: instrumentType ?? this.instrumentType,
priceDigits: priceDigits ?? this.priceDigits,
);
}
}
/// Active chart instrument — edit these fields to rename / rebrand the pair.
const candlePredictInstrument = CandlePredictInstrument(
id: 'fo',
symbol: 'FO',
displayName: 'Full Option',
quoteCurrency: 'USDT',
);

View File

@ -4,6 +4,7 @@ import '../../../../core/theme/app_colors.dart';
import '../../../../data/models/prediction_models.dart';
import '../../../../l10n/app_strings.dart';
import '../../bloc/prediction_bloc.dart';
import '../../domain/candle_predict_instrument.dart';
/// Horizontally scrollable candlestick chart (latest candles on the right).
/// Y-scale fits the **visible** window so candle size stays consistent across intervals.
@ -217,7 +218,7 @@ class _CandleChartWidgetState extends State<CandleChartWidget> {
),
if (widget.isLoadingOlder)
const Positioned(
left: 8,
right: 8,
top: 8,
child: SizedBox(
width: 16,
@ -225,6 +226,50 @@ class _CandleChartWidgetState extends State<CandleChartWidget> {
child: CircularProgressIndicator(strokeWidth: 2),
),
),
Positioned(
left: 10,
top: 8,
child: IgnorePointer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
candlePredictInstrument.pairSymbol,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w800,
color: Colors.white.withValues(alpha: 0.92),
shadows: const [
Shadow(blurRadius: 8, color: Colors.black54),
],
),
),
Text(
candlePredictInstrument.displayName,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.white.withValues(alpha: 0.72),
shadows: const [
Shadow(blurRadius: 6, color: Colors.black54),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(
candlePredictInstrument.priceLabel(candles.last.close),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontFamily: 'monospace',
fontWeight: FontWeight.w600,
color: const Color(0xFFD6B25E).withValues(alpha: 0.95),
shadows: const [
Shadow(blurRadius: 6, color: Colors.black54),
],
),
),
),
],
),
),
),
],
);
},

View File

@ -1,8 +1,14 @@
import { Box, CircularProgress, Typography } from '@mui/material';
import { Box, CircularProgress, Stack, Typography } from '@mui/material';
import { CandlestickSeries, ColorType, createChart, type IChartApi, type ISeriesApi } from 'lightweight-charts';
import { memo, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import type { OhlcCandle } from '../types';
import {
getActiveInstrument,
instrumentChartTitle,
instrumentPairSymbol,
instrumentPriceLabel,
} from '../instrumentConfig';
/** Fixed viewport: always show this many candles at the same pixel width. */
const VISIBLE_CANDLE_COUNT = 20;
@ -78,6 +84,12 @@ export const CandlestickChart = memo(function CandlestickChart({
hasMoreOlderRef.current = hasMoreOlder;
loadingOlderRef.current = loadingOlder;
const instrument = getActiveInstrument();
const lastClose = candles.length ? candles[candles.length - 1]!.close : null;
const pairSymbol = instrumentPairSymbol(instrument);
const chartTitle = instrumentChartTitle(instrument);
const priceLine = lastClose != null ? instrumentPriceLabel(lastClose, instrument) : pairSymbol;
useEffect(() => {
if (!containerRef.current) return;
@ -244,13 +256,67 @@ export const CandlestickChart = memo(function CandlestickChart({
'linear-gradient(180deg, rgba(18,23,36,0.95) 0%, rgba(11,14,20,0.85) 100%)',
}}
/>
<Stack
spacing={0.15}
role="group"
aria-label={chartTitle}
sx={{
position: 'absolute',
top: 10,
left: 12,
zIndex: 2,
pointerEvents: 'none',
userSelect: 'none',
maxWidth: '70%',
}}
>
<Typography
variant="subtitle2"
sx={{
fontWeight: 800,
letterSpacing: 0.4,
lineHeight: 1.2,
color: 'rgba(255,255,255,0.92)',
textShadow: '0 1px 8px rgba(0,0,0,0.55)',
}}
>
{pairSymbol}
</Typography>
<Typography
variant="caption"
sx={{
opacity: 0.72,
lineHeight: 1.2,
color: 'rgba(255,255,255,0.78)',
textShadow: '0 1px 6px rgba(0,0,0,0.5)',
}}
>
{instrument.displayName}
</Typography>
{lastClose != null && (
<Typography
variant="caption"
sx={{
mt: 0.25,
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
fontWeight: 600,
opacity: 0.85,
color: 'rgba(214,178,94,0.95)',
textShadow: '0 1px 6px rgba(0,0,0,0.5)',
}}
aria-label={priceLine}
>
{priceLine}
</Typography>
)}
</Stack>
{loadingOlder && (
<CircularProgress
size={22}
sx={{
position: 'absolute',
top: 12,
left: 12,
right: 12,
color: 'primary.main',
}}
/>

View File

@ -0,0 +1,66 @@
/**
* Synthetic chart instrument for Candle Predict.
*
* Display-only identity — OHLC always comes from our backend engine, never from
* TradingView / Binance / any external market feed.
*
* Candle Predict uses a single active instrument. To change it, edit
* {@link CANDLE_PREDICT_INSTRUMENT} below (symbol, name, quote currency).
* Helpers always resolve through {@link getActiveInstrument}.
*/
export type InstrumentType = 'SYNTHETIC';
export type SyntheticInstrumentConfig = {
/** Stable internal key (not shown on the chart). */
id: string;
/** Short ticker, e.g. FO */
symbol: string;
/** Human-readable name, e.g. Full Option */
displayName: string;
/** Quote unit for the price, e.g. USDT */
quoteCurrency: string;
instrumentType: InstrumentType;
/** Decimal places for price labels on the chart. */
priceDigits: number;
};
/**
* Active chart instrument — edit this object to rename / rebrand the pair.
* Keep a single entry; multi-instrument switching is not required today.
*/
export const CANDLE_PREDICT_INSTRUMENT: SyntheticInstrumentConfig = {
id: 'fo',
symbol: 'FO',
displayName: 'Full Option',
quoteCurrency: 'USDT',
instrumentType: 'SYNTHETIC',
priceDigits: 2,
};
/** Returns the instrument currently shown on the Candle Predict chart. */
export function getActiveInstrument(): SyntheticInstrumentConfig {
return CANDLE_PREDICT_INSTRUMENT;
}
/** Pair ticker shown on the chart, e.g. FO/USDT */
export function instrumentPairSymbol(
instrument: SyntheticInstrumentConfig = getActiveInstrument()
): string {
return `${instrument.symbol}/${instrument.quoteCurrency}`;
}
/** Header line, e.g. FO/USDT — Full Option */
export function instrumentChartTitle(
instrument: SyntheticInstrumentConfig = getActiveInstrument()
): string {
return `${instrumentPairSymbol(instrument)} — ${instrument.displayName}`;
}
/** Price subtitle, e.g. FO/USDT — 105.50 */
export function instrumentPriceLabel(
price: number,
instrument: SyntheticInstrumentConfig = getActiveInstrument()
): string {
return `${instrumentPairSymbol(instrument)} — ${price.toFixed(instrument.priceDigits)}`;
}