Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
refactor: rename some vars to resolve name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
CCXXXI committed Oct 19, 2021
1 parent f8e11d7 commit 20cd8f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import 'package:window_size/window_size.dart';

import 'home/home_view.dart';
import 'settings/theme.dart';
import 'utils/database.dart' as db;
import 'utils/database.dart';
import 'utils/log.dart';
import 'utils/sentry.dart';
import 'utils/string.dart';

void main() async {
await db.initDatabase();
await initDatabase();
Settings.init();
initLog();
if (GetPlatform.isDesktop && !GetPlatform.isWeb) initDesktop();
Expand All @@ -31,7 +31,7 @@ class MyApp extends StatelessWidget {
navigatorObservers: [SentryNavigatorObserver()],
title: appName,
home: HomePage(),
theme: theme,
theme: appTheme,
);
}
}
Expand Down
30 changes: 15 additions & 15 deletions lib/settings/settings_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,61 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:quiver/iterables.dart';

import '../utils/database.dart' as db;
import '../utils/database.dart';
import '../utils/log.dart';
import '../utils/string.dart';
import '../utils/web.dart';
import 'theme.dart' as theme;
import 'theme.dart';

class SettingsLogic extends GetxController with L {
final Dio dio;

SettingsLogic({Dio? dio}) : dio = dio ?? defaultDio;

void modeOnChanged(String v) {
db.theme
theme
..mode = v
..save();
theme.updateTheme();
updateTheme();
}

void fontOnChanged(String v) {
db.theme
theme
..font = v
..save();
theme.updateTheme();
updateTheme();
}

void overrideColorOnChanged(bool v) {
db.theme
theme
..overrideColor = v
..save();
theme.updateTheme();
updateTheme();
}

void primaryOnChanged(Color v) {
db.theme
theme
..primary = v
..save();
theme.updateTheme();
updateTheme();
}

void secondaryOnChanged(Color v) {
db.theme
theme
..secondary = v
..save();
theme.updateTheme();
updateTheme();
}

void surfaceOnChanged(Color v) {
db.theme
theme
..surface = v
..save();
theme.updateTheme();
updateTheme();
}

void launchPageOnChanged(String v) {
db.misc
misc
..launchPage = v
..save();
}
Expand Down
22 changes: 11 additions & 11 deletions lib/settings/theme.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../utils/database.dart' as db;
import '../utils/database.dart';
import '../utils/string.dart';

// region colorScheme
bool get _dark =>
db.theme.mode_ == ThemeMode.dark ||
db.theme.mode_ == ThemeMode.system && Get.isPlatformDarkMode;
theme.mode_ == ThemeMode.dark ||
theme.mode_ == ThemeMode.system && Get.isPlatformDarkMode;

ColorScheme get _colorScheme => (_dark ? ColorScheme.dark : ColorScheme.light)(
primary: db.theme.primary,
onPrimary: db.theme.onPrimary,
secondary: db.theme.secondary,
onSecondary: db.theme.onSecondary,
surface: db.theme.surface,
onSurface: db.theme.onSurface,
primary: theme.primary,
onPrimary: theme.onPrimary,
secondary: theme.secondary,
onSecondary: theme.onSecondary,
surface: theme.surface,
onSurface: theme.onSurface,
);
// endregion

ThemeData get theme => ThemeData.from(
ThemeData get appTheme => ThemeData.from(
colorScheme: _colorScheme,
textTheme:
db.theme.applyFont(_dark ? Typography().white : Typography().black),
theme.applyFont(_dark ? Typography().white : Typography().black),
);

// void updateTheme() => Get.changeTheme(theme);
Expand Down

0 comments on commit 20cd8f1

Please sign in to comment.