Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add beta light/dark mode 1.1 #122

Merged
merged 9 commits into from
Nov 29, 2023
45 changes: 45 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
platform :ios, '11.0'
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
# target 'RunnerTests' do
# inherit! :search_paths
# end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
33 changes: 33 additions & 0 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,43 @@ const categoryColorList = [
category10,
];

const darkCategoryColorList = [
darkCategory1,
darkCategory2,
darkCategory3,
darkCategory4,
darkCategory5,
darkCategory6,
darkCategory7,
darkCategory8,
darkCategory9,
];

const accountColorList = [
account1,
account2,
account3,
account4,
account5,
];

const darkAccountColorList = [
darkAccount1,
darkAccount2,
darkAccount3,
darkAccount4,
darkAccount5,
];

List<Color> categoryColorListTheme = categoryColorList;
List<Color> accountColorListTheme = accountColorList;

void updateColorsBasedOnTheme(bool isDarkModeEnabled) {
if (isDarkModeEnabled) {
categoryColorListTheme = darkCategoryColorList;
accountColorListTheme = darkAccountColorList;
} else {
categoryColorListTheme = categoryColorList;
accountColorListTheme = accountColorList;
}
}
39 changes: 38 additions & 1 deletion lib/constants/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const category3 = Color(0xFFFF4754);
const category4 = Color(0xFFD336B6);
const category5 = Color(0xFF7236D3);
const category6 = Color(0xFF2675E3);
const category7 = Color(0xFF16ADDF);
const category7 = Color(0xFF16ADDF);//inesistente sul figma
const category8 = Color(0xFF12BFCE);
const category9 = Color(0xFF12BA95);
const category10 = Color(0xFF0BC11D);
Expand All @@ -51,3 +51,40 @@ const account2 = Color(0xFFFB8500);
const account3 = Color(0xFF356CA3);
const account4 = Color(0xFF8ECAE6);
const account5 = Color(0xFF3E9B12);

//dark colors

const darkGreen = Color(0xFF31B943);
const darkRed = Color(0xFFD83131);
const darkWhite = Color(0xFF181E25);
const darkBlack = Color(0xFFFFFFFF);

const darkBlue1 = Color(0xFFE3E5E8);
const darkBlue2 = Color(0xFF002247);
const darkBlue3 = Color(0xFF012C5A);
const darkBlue4 = Color(0xFF033D78);
const darkBlue5 = Color(0xFF2C5987);
const darkBlue6 = Color(0xFF6C94BC);
const darkBlue7 = Color(0xFF181E25);

const darkGrey1 = Color(0xFFA8AAAC);
const darkGrey2 = Color(0xFFC6C7C8);
const darkGrey3 = Color(0xFF181E25);
const darkGrey4 = Color(0xFF2E3338);

const darkCategory1 = Color(0xFFE3B912);
const darkCategory2 = Color(0xFFF6740C);
const darkCategory3 = Color(0xFFFA3240);
const darkCategory4 = Color(0xFFBF2AA4);
const darkCategory5 = Color(0xFF672BC7);
const darkCategory6 = Color(0xFF1B6BD9);
const darkCategory7 = Color(0xFF0FB1C0);
const darkCategory8 = Color(0xFF0EB38F);
const darkCategory9 = Color(0xFF0AAF1A);
// const darkCategory10 = Color(0xFF);

const darkAccount1 = Color(0xFFE0A30C);
const darkAccount2 = Color(0xFFDC7807);
const darkAccount3 = Color(0xFF33679B);
const darkAccount4 = Color(0xFF61B4DB);
const darkAccount5 = Color(0xFF398F10);
36 changes: 25 additions & 11 deletions lib/custom_widgets/accounts_sum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AccountsSum extends StatelessWidget with Functions {
),
child: Container(
decoration: BoxDecoration(
color: accountColorList[account.color].withOpacity(0.2),
color: accountColorListTheme[account.color].withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
),
child: Material(
Expand Down Expand Up @@ -72,26 +72,33 @@ class AccountsSum extends StatelessWidget with Functions {
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: accountColorList[account.color],
color: accountColorListTheme[account.color],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(accountIconList[account.symbol], size: 20.0, color: white),
child: Icon(accountIconList[account.symbol],
size: 20.0,
color: white), //capire se cambiare colore icona
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(account.name, style: Theme.of(context).textTheme.bodyLarge),
Text(account.name,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(color: darkBlue7)),//impostato manualmente darkBlue7, da rivedere
FutureBuilder<num?>(
future: BankAccountMethods().getAccountSum(account.id),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Show a loading indicator while waiting for the future to complete
return Transform.scale(
scale: 0.5,
child: CircularProgressIndicator(),
child: const CircularProgressIndicator(),
);
} else if (snapshot.hasError) {
// Show an error message if the future encounters an error
Expand All @@ -100,18 +107,25 @@ class AccountsSum extends StatelessWidget with Functions {
// Display the result once the future completes successfully
final accountSum = snapshot.data ?? 0;
return RichText(
textScaleFactor: MediaQuery.of(context).textScaleFactor,
textScaleFactor:
MediaQuery.of(context).textScaleFactor,
text: TextSpan(
children: [
TextSpan(
text: numToCurrency(accountSum),
style: Theme.of(context).textTheme.titleSmall,
style:
Theme.of(context).textTheme.titleSmall!.copyWith(color: darkBlue7),
),
TextSpan(
text: "€",
style: Theme.of(context).textTheme.bodyMedium?.apply(
fontFeatures: [const FontFeature.subscripts()],
),
style: Theme.of(context)
.textTheme
.bodyMedium
?.apply(
fontFeatures: [
const FontFeature.subscripts()
],
).copyWith(color: darkBlue7),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/custom_widgets/alert_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import '/main.dart';
import '../utils/app_theme.dart';

///
/// Builder class to create a customized dialog with some options
Expand Down
4 changes: 2 additions & 2 deletions lib/custom_widgets/transactions_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class TransactionRow extends ConsumerWidget with Functions {
children: [
Material(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.primaryContainer,
child: InkWell(
onTap: () {
ref.read(selectedTransactionUpdateProvider.notifier).state = transaction;
Expand Down Expand Up @@ -224,7 +224,7 @@ class TransactionRow extends ConsumerWidget with Functions {
decoration: BoxDecoration(
shape: BoxShape.circle,
color: category?.color != null
? categoryColorList[category!.color]
? categoryColorListTheme[category!.color]
: Theme.of(context).colorScheme.secondary,
),
child: Padding(
Expand Down
110 changes: 11 additions & 99 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,116 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sossoldi/providers/theme_provider.dart';
import 'package:sossoldi/utils/app_theme.dart';
import 'routes.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'constants/style.dart';

void main() {
initializeDateFormatting('it_IT', null).then((_) => runApp(const ProviderScope(child: Launcher())));
initializeDateFormatting('it_IT', null)
.then((_) => runApp(const ProviderScope(child: Launcher())));
}

ColorScheme customColorScheme = const ColorScheme(
primary: blue1,
secondary: blue5,
surface: grey3,
background: white,
error: red,
onPrimary: white,
onSecondary: white,
onSurface: blue1,
onBackground: blue1,
onError: black,
brightness: Brightness.light,
);

ThemeData customThemeData = ThemeData(
colorScheme: customColorScheme,
appBarTheme: const AppBarTheme(
color: grey3,
elevation: 0,
centerTitle: true,
iconTheme: IconThemeData(color: blue5),
titleTextStyle: TextStyle(
color: blue1,
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
fontFamily: 'SF Pro Text',
textTheme: const TextTheme(
// display
displayLarge: TextStyle(
fontSize: 34.0,
fontWeight: FontWeight.w700,
),
displayMedium: TextStyle(
fontSize: 34.0,
fontWeight: FontWeight.w600,
color: Colors.black,
),

// headline
headlineLarge: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w700,
),
headlineMedium: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w600,
),

// title
titleLarge: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
),
titleMedium: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
titleSmall: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w400,
),

// body
bodyLarge: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w700,
),
bodyMedium: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
),
bodySmall: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w400,
),

// label
labelLarge: TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w700,
),
labelMedium: TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w400,
),
labelSmall: TextStyle(
fontSize: 8.0,
fontWeight: FontWeight.w700,
),
),
);

class Launcher extends StatelessWidget {
class Launcher extends ConsumerWidget {
const Launcher({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final appThemeState = ref.watch(appThemeStateNotifier);
return MaterialApp(
title: 'Sossoldi',
theme: customThemeData,
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
themeMode:
appThemeState.isDarkModeEnabled ? ThemeMode.dark : ThemeMode.light,
onGenerateRoute: makeRoute,
initialRoute: '/',
);
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/accounts/account_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _AccountListState extends ConsumerState<AccountList> with Functions {
itemBuilder: (context, i) {
BankAccount account = accounts[i];
IconData? icon = accountIconList[account.symbol];
Color? color = accountColorList[account.color];
Color? color = accountColorListTheme[account.color];
return DefaultContainer(
onTap: () async {
await ref.read(accountsProvider.notifier).selectedAccount(account).whenComplete(() => Navigator.of(context).pushNamed('/add-account'));
Expand Down
Loading
Loading