runable
This commit is contained in:
68
lib/features/settings/domain/entities/app_settings.dart
Normal file
68
lib/features/settings/domain/entities/app_settings.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/app_constants.dart';
|
||||
|
||||
/// App settings domain entity
|
||||
class AppSettings extends Equatable {
|
||||
final ThemeMode themeMode;
|
||||
final String language;
|
||||
final String currency;
|
||||
final double taxRate;
|
||||
final String storeName;
|
||||
final bool enableSync;
|
||||
final DateTime? lastSyncAt;
|
||||
|
||||
const AppSettings({
|
||||
required this.themeMode,
|
||||
required this.language,
|
||||
required this.currency,
|
||||
required this.taxRate,
|
||||
required this.storeName,
|
||||
required this.enableSync,
|
||||
this.lastSyncAt,
|
||||
});
|
||||
|
||||
AppSettings copyWith({
|
||||
ThemeMode? themeMode,
|
||||
String? language,
|
||||
String? currency,
|
||||
double? taxRate,
|
||||
String? storeName,
|
||||
bool? enableSync,
|
||||
DateTime? lastSyncAt,
|
||||
}) {
|
||||
return AppSettings(
|
||||
themeMode: themeMode ?? this.themeMode,
|
||||
language: language ?? this.language,
|
||||
currency: currency ?? this.currency,
|
||||
taxRate: taxRate ?? this.taxRate,
|
||||
storeName: storeName ?? this.storeName,
|
||||
enableSync: enableSync ?? this.enableSync,
|
||||
lastSyncAt: lastSyncAt ?? this.lastSyncAt,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create default settings
|
||||
factory AppSettings.defaultSettings() {
|
||||
return const AppSettings(
|
||||
themeMode: ThemeMode.system,
|
||||
language: AppConstants.defaultLanguage,
|
||||
currency: AppConstants.defaultCurrency,
|
||||
taxRate: AppConstants.defaultTaxRate,
|
||||
storeName: AppConstants.appName,
|
||||
enableSync: true,
|
||||
lastSyncAt: null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
themeMode,
|
||||
language,
|
||||
currency,
|
||||
taxRate,
|
||||
storeName,
|
||||
enableSync,
|
||||
lastSyncAt,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user