Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
✨ made user preferences persistent. fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
adeeteya committed Feb 16, 2022
1 parent fbf8696 commit 037c492
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 9 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Each image has been pre-analyzed by an AI algorithm called [pypy-agender](https:
## 💻 Installation links

- [Website](https://adityar224.github.io/Random-Face-Generator/#/)
- [Android app](https://github.com/adityar224/Random-Face-Generator/releases/download/1.0.2/Random-Face-Generator-1.0.2.apk)
- [Windows Installer](https://github.com/adityar224/Random-Face-Generator/releases/download/1.0.2/Random-Face-Generator-Setup-1.0.2.exe)
- [Android app](https://github.com/adityar224/Random-Face-Generator/releases/download/1.1.0/Random-Face-Generator-1.1.0.apk)
- [Windows Installer](https://github.com/adityar224/Random-Face-Generator/releases/download/1.1.0/Random-Face-Generator-Setup-1.1.0.exe)

## ✨ Features

Expand Down Expand Up @@ -43,13 +43,15 @@ Each image has been pre-analyzed by an AI algorithm called [pypy-agender](https:
| ------------------------------------------------------- | --------------------------------------------------- |
| [**http**](https://pub.dev/packages/http) | Api Calls |
| [**flutter_lints**](https://pub.dev/packages/flutter_lints) | For linting |
| [**hive**](https://pub.dev/packages/hive) | For preference persistence |
| [**hive_flutter**](https://pub.dev/packages/hive_flutter) | Extension for hive |

Please star⭐ the repo if you like what you see😊.

## 🤓 Author

**[Aditya R](https://github.com/adityar224)**

## 🔖 LICENCE
## 🔖 LICENSE
Copyright (c) 2022 Aditya R
[MIT](https://github.com/adityar224/Random-Face-Generator/blob/master/LICENSE)
[MIT LICENSE](https://github.com/adityar224/Random-Face-Generator/blob/master/LICENSE)
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const String kDefaultUrl = "https://fakeface.rest/face/json";
const String kInitialUrl = "https://thispersondoesnotexist.com/image";
const String kCorsProxyUrl =
"https://random-face-generator-proxy.herokuapp.com/";
const String kHiveSystemPrefs = "system_prefs";
const kLightBackgroundColor = Color(0xFFE0E5EC);
const kLightSourceColor = Color(0x99FFFFFF);
const kLightShadowColor = Color(0x99A3B1C6);
Expand Down
5 changes: 4 additions & 1 deletion lib/custom_theme.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:random_face_generator/constants.dart';

class CustomTheme with ChangeNotifier {
static bool _isDark = ThemeMode.system == ThemeMode.dark;
static bool _isDark = Hive.box(kHiveSystemPrefs)
.get("darkMode", defaultValue: ThemeMode.system == ThemeMode.dark);

void switchTheme() {
_isDark = !_isDark;
notifyListeners();
Hive.box(kHiveSystemPrefs).put("darkMode", _isDark);
}

IconData get icon => (_isDark) ? Icons.light_mode : Icons.dark_mode;
Expand Down
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:http/http.dart' as http;
import 'package:random_face_generator/constants.dart';
import 'package:random_face_generator/custom_theme.dart';
Expand All @@ -11,10 +12,12 @@ import 'package:random_face_generator/neumorphic_icon_button.dart';
import 'package:random_face_generator/neumorphic_radio_button.dart';
import 'package:random_face_generator/neumorphic_text_button.dart';

void main() {
void main() async {
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(statusBarColor: Colors.transparent),
);
await Hive.initFlutter();
await Hive.openBox(kHiveSystemPrefs);
runApp(
const MaterialApp(
home: Home(),
Expand Down
120 changes: 120 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -67,6 +88,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
hive:
dependency: "direct main"
description:
name: hive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
hive_flutter:
dependency: "direct main"
description:
name: hive_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
http:
dependency: "direct main"
description:
Expand Down Expand Up @@ -116,6 +151,76 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -177,5 +282,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
sdks:
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: This app Generates Random Faces which do not actually exist.

publish_to: 'none'

version: 1.0.2+1
version: 1.1.0+2

environment:
sdk: ">=2.15.1 <3.0.0"
Expand All @@ -13,6 +13,8 @@ dependencies:
sdk: flutter

http: ^0.13.4
hive: ^2.0.5
hive_flutter: ^1.1.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 037c492

Please sign in to comment.