feat(App): update Finlytic Flutter app UI and blocs

This commit is contained in:
2026-08-09 21:01:46 +02:00
parent e7427b7464
commit a708d2977c
591 changed files with 1095105 additions and 0 deletions
@@ -0,0 +1,209 @@
import 'package:equatable/equatable.dart';
class CandleModel extends Equatable {
final DateTime timestamp;
final double open;
final double high;
final double low;
final double close;
final double volume;
const CandleModel({
required this.timestamp,
required this.open,
required this.high,
required this.low,
required this.close,
required this.volume,
});
factory CandleModel.fromJson(Map<String, dynamic> json) {
return CandleModel(
timestamp: DateTime.tryParse(json['timestamp']?.toString() ?? '') ?? DateTime.now(),
open: (json['open'] as num?)?.toDouble() ?? 0.0,
high: (json['high'] as num?)?.toDouble() ?? 0.0,
low: (json['low'] as num?)?.toDouble() ?? 0.0,
close: (json['close'] as num?)?.toDouble() ?? 0.0,
volume: (json['volume'] as num?)?.toDouble() ?? 0.0,
);
}
@override
List<Object?> get props => [timestamp, open, high, low, close, volume];
}
class IndicatorModel extends Equatable {
final DateTime timestamp;
final double? ema20;
final double? sma50;
final double? sma200;
final double? rsi14;
final double? macdLine;
final double? macdSignal;
final double? macdHistogram;
final double? atr14;
final double? vwap;
final double? supertrendUpper;
final double? supertrendLower;
final String? supertrendDirection;
final double? recommendedStopLoss;
const IndicatorModel({
required this.timestamp,
this.ema20,
this.sma50,
this.sma200,
this.rsi14,
this.macdLine,
this.macdSignal,
this.macdHistogram,
this.atr14,
this.vwap,
this.supertrendUpper,
this.supertrendLower,
this.supertrendDirection,
this.recommendedStopLoss,
});
factory IndicatorModel.fromJson(Map<String, dynamic> json) {
return IndicatorModel(
timestamp: DateTime.tryParse(json['timestamp']?.toString() ?? '') ?? DateTime.now(),
ema20: (json['ema20'] as num?)?.toDouble(),
sma50: (json['sma50'] as num?)?.toDouble(),
sma200: (json['sma200'] as num?)?.toDouble(),
rsi14: (json['rsi14'] as num?)?.toDouble(),
macdLine: (json['macdLine'] as num?)?.toDouble(),
macdSignal: (json['macdSignal'] as num?)?.toDouble(),
macdHistogram: (json['macdHistogram'] as num?)?.toDouble(),
atr14: (json['atr14'] as num?)?.toDouble(),
vwap: (json['vwap'] as num?)?.toDouble(),
supertrendUpper: (json['supertrendUpper'] as num?)?.toDouble(),
supertrendLower: (json['supertrendLower'] as num?)?.toDouble(),
supertrendDirection: json['supertrendDirection']?.toString(),
recommendedStopLoss: (json['recommendedStopLoss'] as num?)?.toDouble(),
);
}
@override
List<Object?> get props => [
timestamp, ema20, sma50, sma200, rsi14, macdLine, macdSignal,
macdHistogram, atr14, vwap, supertrendUpper, supertrendLower,
supertrendDirection, recommendedStopLoss
];
}
class StrategySignalModel extends Equatable {
final String title;
final DateTime date;
final double price;
final String type; // BUY or SELL
const StrategySignalModel({
required this.title,
required this.date,
required this.price,
required this.type,
});
factory StrategySignalModel.fromJson(Map<String, dynamic> json) {
return StrategySignalModel(
title: json['title']?.toString() ?? '',
date: DateTime.tryParse(json['date']?.toString() ?? '') ?? DateTime.now(),
price: (json['price'] as num?)?.toDouble() ?? 0.0,
type: json['type']?.toString() ?? 'BUY',
);
}
@override
List<Object?> get props => [title, date, price, type];
}
class TechnicalAnalysisModel extends Equatable {
final String symbol;
final String trend;
final String rsi;
final String macd;
final String overallSignal;
final String sma50;
final String sma200;
final double vix;
final String sp500Trend;
final double dxy;
final double? stopLossAtr;
final List<CandleModel> candles;
final List<IndicatorModel> indicators;
final List<String> patterns;
final List<StrategySignalModel> signals;
const TechnicalAnalysisModel({
required this.symbol,
required this.trend,
required this.rsi,
required this.macd,
required this.overallSignal,
required this.sma50,
required this.sma200,
this.vix = 16.5,
this.sp500Trend = 'Bullish',
this.dxy = 104.2,
this.stopLossAtr,
this.candles = const [],
this.indicators = const [],
this.patterns = const [],
this.signals = const [],
});
factory TechnicalAnalysisModel.fromJson(Map<String, dynamic> json) {
var rawCandles = json['candles'] as List<dynamic>? ?? [];
var candlesList = rawCandles.map((c) => CandleModel.fromJson(c as Map<String, dynamic>)).toList();
var rawIndicators = json['indicators'] as List<dynamic>? ?? [];
var indicatorsList = rawIndicators.map((i) => IndicatorModel.fromJson(i as Map<String, dynamic>)).toList();
var rawSignals = json['signals'] as List<dynamic>? ?? [];
var signalsList = rawSignals.map((s) => StrategySignalModel.fromJson(s as Map<String, dynamic>)).toList();
var rawPatterns = json['patterns'] as List<dynamic>? ?? [];
var patternsList = rawPatterns.map((p) => p.toString()).toList();
return TechnicalAnalysisModel(
symbol: json['symbol']?.toString() ?? json['isin']?.toString() ?? json['ticker']?.toString() ?? '',
trend: json['trend']?.toString() ?? json['Trend']?.toString() ?? 'Bullisch ▲',
rsi: json['rsi']?.toString() ?? json['Rsi']?.toString() ?? '58.7',
macd: json['macd']?.toString() ?? json['Macd']?.toString() ?? '0.45',
overallSignal: json['overallSignal']?.toString() ?? json['OverallSignal']?.toString() ?? 'HOLD',
sma50: json['sma50']?.toString() ?? json['Sma50']?.toString() ?? '49.50',
sma200: json['sma200']?.toString() ?? json['Sma200']?.toString() ?? '42.50',
vix: (json['vix'] as num?)?.toDouble() ?? 16.5,
sp500Trend: json['sp500Trend']?.toString() ?? 'Bullish',
dxy: (json['dxy'] as num?)?.toDouble() ?? 104.2,
stopLossAtr: (json['stopLossAtr'] as num?)?.toDouble(),
candles: candlesList,
indicators: indicatorsList,
patterns: patternsList,
signals: signalsList,
);
}
Map<String, dynamic> toJson() {
return {
'symbol': symbol,
'trend': trend,
'rsi': rsi,
'macd': macd,
'overallSignal': overallSignal,
'sma50': sma50,
'sma200': sma200,
'vix': vix,
'sp500Trend': sp500Trend,
'dxy': dxy,
'stopLossAtr': stopLossAtr,
};
}
@override
List<Object?> get props => [
symbol, trend, rsi, macd, overallSignal, sma50, sma200, vix,
sp500Trend, dxy, stopLossAtr, candles, indicators, patterns, signals
];
}