Compare commits

...

4 Commits

Author SHA1 Message Date
f0d6cac3fd v0.2.24 (#61)
* bumped version.

* improved collapse.

* improved download speed.

* improved err handling.

* improved error handling.

* improved error handling.

* improved logging.

* improved logging.

* bumped version.
2022-06-27 00:47:22 -07:00
a90d52f348 v0.2.23 (#60)
* fixed #58

* bumped version.
2022-06-23 19:38:14 -07:00
cff4a3c5c4 v0.2.22 (#59)
* bumped version.

* cleaned up code.

* bumped version.

* fixed lint.

* updated android config.

* prevent backup of secure storage.

* small fix.

* cleaned up code.

* cleaned up.

* small fix
2022-06-22 23:44:49 -07:00
502faaf188 corrected spelling. 2022-06-22 10:28:27 -07:00
85 changed files with 1042 additions and 807 deletions

View File

@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {
android {
compileSdkVersion 31
compileSdkVersion 32
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@ -49,10 +49,9 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.jiaqifeng.hacki"
minSdkVersion 26
targetSdkVersion 30
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
@ -78,5 +77,5 @@ flutter {
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

View File

@ -16,8 +16,10 @@
</queries>
<application
android:label="hacki"
android:label="Hacki"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
@ -25,6 +27,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="sharedpref" path="FlutterSecureStorage"/>
</full-backup-content>

View File

@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View File

@ -1 +0,0 @@
- Bugfixes.

View File

@ -1 +0,0 @@
- Updates to UI.

View File

@ -1 +0,0 @@
- Updates to UI.

View File

@ -1 +0,0 @@
- Updates to UI.

View File

@ -1 +0,0 @@
- Tapping on comments in notification and history screen will lead you directly to the comment.

View File

@ -1,3 +0,0 @@
- Tapping on comment in notification or history screen will now lead you directly to the comment.
- Fixed the bug where reply box cannot be expanded in editing mode.
- Fixed inconsistent font size in history screen.

View File

@ -1 +0,0 @@
- Added offline mode.

View File

@ -1,2 +0,0 @@
- Added offline mode.
- Bugfixes.

View File

@ -1,2 +0,0 @@
- Added offline mode.
- Bugfixes.

View File

@ -1,2 +0,0 @@
- Added offline mode.
- Bugfixes.

View File

@ -1,3 +0,0 @@
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,3 +0,0 @@
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,3 +0,0 @@
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,4 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.

View File

@ -1,5 +0,0 @@
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -1,6 +0,0 @@
- You can now add filters for searching.
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -1,6 +0,0 @@
- You can now add filters for searching.
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -1,6 +0,0 @@
- You can now add filters for searching.
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -1,6 +0,0 @@
- You can now add filters for searching.
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -1,7 +0,0 @@
- You can share links.
- You can now add filters for searching.
- You can now participate in polls.
- Pick up where you left off.
- Swipe left on comment tile to view its parents without scrolling all the way up.
- Huge performance boost.
- Bugfixes.

View File

@ -0,0 +1,2 @@
- Offline mode now includes web pages.
- You can now sort comments in story screen.

View File

@ -0,0 +1,2 @@
- Offline mode now includes web pages.
- You can now sort comments in story screen.

View File

@ -0,0 +1,2 @@
- Offline mode now includes web pages.
- You can now sort comments in story screen.

View File

@ -568,7 +568,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = QMWX3X2NF7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@ -577,7 +577,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.2.21;
MARKETING_VERSION = 0.2.24;
PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -705,7 +705,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = QMWX3X2NF7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@ -714,7 +714,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.2.21;
MARKETING_VERSION = 0.2.24;
PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -736,7 +736,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = QMWX3X2NF7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@ -745,7 +745,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.2.21;
MARKETING_VERSION = 0.2.24;
PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -7,7 +7,9 @@ import 'package:hacki/config/locator.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:logger/logger.dart';
import 'package:responsive_builder/responsive_builder.dart';
import 'package:rxdart/rxdart.dart';
part 'stories_event.dart';
part 'stories_state.dart';
@ -281,12 +283,6 @@ class StoriesBloc extends Bloc<StoriesEvent, StoriesState> {
includingWebPage: event.includingWebPage,
isPrioritized: false,
);
emit(
state.copyWith(
downloadStatus: StoriesDownloadStatus.finished,
),
);
} catch (_) {
emit(
state.copyWith(
@ -321,41 +317,50 @@ class StoriesBloc extends Bloc<StoriesEvent, StoriesState> {
await _cacheRepository.cacheStory(story: story);
if (story.url.isNotEmpty && includingWebPage) {
locator.get<Logger>().i('downloading ${story.url}');
await _cacheRepository.cacheUrl(url: story.url);
}
final Completer<void> completer = Completer<void>();
_storiesRepository
.fetchAllChildrenComments(ids: story.kids)
.listen((Comment? comment) async {
if (comment != null) {
await _cacheRepository.cacheComment(comment: comment);
}
}).onDone(() {
completer.complete();
add(StoryDownloaded(skipped: false));
});
await completer.future;
.whereType<Comment>()
.listen(
(Comment comment) => unawaited(
_cacheRepository.cacheComment(comment: comment),
),
)
.onDone(() => add(StoryDownloaded(skipped: false)));
}
}
void onStoryDownloaded(StoryDownloaded event, Emitter<StoriesState> emit) {
if (event.skipped) {
final int updatedStoriesToBeDownloaded = state.storiesToBeDownloaded - 1;
emit(
state.copyWith(
storiesToBeDownloaded: state.storiesToBeDownloaded - 1,
storiesToBeDownloaded: updatedStoriesToBeDownloaded,
downloadStatus:
state.storiesDownloaded == updatedStoriesToBeDownloaded
? StoriesDownloadStatus.finished
: null,
),
);
} else {
final int updatedStoriesDownloaded = state.storiesDownloaded + 1;
final int updatedStoriesToBeDownloaded =
updatedStoriesDownloaded > state.storiesToBeDownloaded
? state.storiesToBeDownloaded + 1
: state.storiesToBeDownloaded;
emit(
state.copyWith(
storiesDownloaded: updatedStoriesDownloaded,
storiesToBeDownloaded:
updatedStoriesDownloaded > state.storiesToBeDownloaded
? state.storiesToBeDownloaded + 1
: state.storiesToBeDownloaded,
storiesToBeDownloaded: updatedStoriesToBeDownloaded,
downloadStatus:
updatedStoriesDownloaded == updatedStoriesToBeDownloaded
? StoriesDownloadStatus.finished
: null,
),
);
}

View File

@ -0,0 +1,31 @@
import 'package:logger/logger.dart';
class CustomLogFilter extends LogFilter {
@override
// ignore: overridden_fields
Level? level = Level.verbose;
/// The minimal level allowed in production.
static const Level _minimalLevel = Level.info;
@override
bool shouldLog(LogEvent event) {
bool shouldLog = false;
if (event.level.index >= _minimalLevel.index) {
return true;
}
assert(
() {
if (event.level.index >= level!.index) {
shouldLog = true;
}
return true;
}(),
'',
);
return shouldLog;
}
}

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:hacki/config/custom_log_filter.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/services/services.dart';
import 'package:logger/logger.dart';
@ -19,8 +19,5 @@ Future<void> setUpLocator() async {
..registerSingleton<CacheRepository>(CacheRepository())
..registerSingleton<CacheService>(CacheService())
..registerSingleton<LocalNotification>(LocalNotification())
..registerSingleton<Logger>(Logger())
..registerSingleton<RouteObserver<ModalRoute<dynamic>>>(
RouteObserver<ModalRoute<dynamic>>(),
);
..registerSingleton<Logger>(Logger(filter: CustomLogFilter()));
}

View File

@ -75,16 +75,7 @@ class CommentsCubit extends Cubit<CommentsState> {
final Item updatedItem = state.offlineReading
? item
: await _storiesRepository.fetchItemBy(id: item.id) ?? item;
final List<int> kids = () {
switch (state.order) {
case CommentsOrder.natural:
return updatedItem.kids;
case CommentsOrder.newestFirst:
return updatedItem.kids.sorted((int a, int b) => b.compareTo(a));
case CommentsOrder.oldestFirst:
return updatedItem.kids.sorted((int a, int b) => a.compareTo(b));
}
}();
final List<int> kids = sortKids(updatedItem.kids);
emit(state.copyWith(item: updatedItem));
@ -127,16 +118,7 @@ class CommentsCubit extends Cubit<CommentsState> {
final Item item = state.item;
final Item updatedItem =
await _storiesRepository.fetchItemBy(id: item.id) ?? item;
final List<int> kids = () {
switch (state.order) {
case CommentsOrder.natural:
return updatedItem.kids;
case CommentsOrder.newestFirst:
return updatedItem.kids.sorted((int a, int b) => b.compareTo(a));
case CommentsOrder.oldestFirst:
return updatedItem.kids.sorted((int a, int b) => a.compareTo(b));
}
}();
final List<int> kids = sortKids(updatedItem.kids);
_streamSubscription = _storiesRepository
.fetchCommentsStream(ids: kids)
@ -200,6 +182,17 @@ class CommentsCubit extends Cubit<CommentsState> {
init();
}
List<int> sortKids(List<int> kids) {
switch (state.order) {
case CommentsOrder.natural:
return kids;
case CommentsOrder.newestFirst:
return kids.sorted((int a, int b) => b.compareTo(a));
case CommentsOrder.oldestFirst:
return kids.sorted((int a, int b) => a.compareTo(b));
}
}
void _onDone() {
_streamSubscription?.cancel();
_streamSubscription = null;

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/main.dart';
import 'package:hacki/screens/screens.dart' show ItemScreen, ItemScreenArgs;
import 'package:hacki/styles/styles.dart';
extension StateExtension on State {
void showSnackBar({
@ -12,7 +13,7 @@ extension StateExtension on State {
}) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.deepOrange,
backgroundColor: Palette.deepOrange,
content: Text(content),
action: action != null && label != null
? SnackBarAction(

View File

@ -15,6 +15,7 @@ import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/repositories/repositories.dart' show PreferenceRepository;
import 'package:hacki/screens/screens.dart';
import 'package:hacki/services/fetcher.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:rxdart/rxdart.dart' show BehaviorSubject;
@ -182,19 +183,19 @@ class HackiApp extends StatelessWidget {
],
child: AdaptiveTheme(
light: ThemeData(
primarySwatch: Colors.orange,
primarySwatch: Palette.orange,
),
dark: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.orange,
canvasColor: trueDarkMode ? Colors.black : null,
primarySwatch: Palette.orange,
canvasColor: trueDarkMode ? Palette.black : null,
),
initial: savedThemeMode ?? AdaptiveThemeMode.system,
builder: (ThemeData theme, ThemeData darkTheme) {
final ThemeData trueDarkTheme = ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.orange,
canvasColor: Colors.black,
primarySwatch: Palette.orange,
canvasColor: Palette.black,
);
return FutureBuilder<AdaptiveThemeMode?>(
future: AdaptiveTheme.getThemeMode(),
@ -220,9 +221,6 @@ class HackiApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
theme: useTrueDark ? trueDarkTheme : theme,
navigatorKey: navigatorKey,
navigatorObservers: <NavigatorObserver>[
locator.get<RouteObserver<ModalRoute<dynamic>>>(),
],
onGenerateRoute: CustomRouter.onGenerateRoute,
initialRoute: HomeScreen.routeName,
),

View File

@ -5,6 +5,7 @@ import 'package:hacki/config/locator.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/repositories/postable_repository.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:logger/logger.dart';
class AuthRepository extends PostableRepository {
AuthRepository({
@ -38,10 +39,15 @@ class AuthRepository extends PostableRepository {
final bool success = await performDefaultPost(uri, data);
if (success) {
await _preferenceRepository.setAuth(
username: username,
password: password,
);
try {
await _preferenceRepository.setAuth(
username: username,
password: password,
);
} catch (_) {
locator.get<Logger>().e(_);
return false;
}
}
return success;

View File

@ -1,7 +1,9 @@
import 'package:flutter/foundation.dart';
import 'package:hacki/config/locator.dart';
import 'package:hacki/models/models.dart';
import 'package:hive/hive.dart';
import 'package:http/http.dart';
import 'package:logger/logger.dart';
/// [CacheRepository] is for storing stories and comments for offline reading.
/// It's using [Hive] as its database which is being stored in temp directory.
@ -9,12 +11,12 @@ class CacheRepository {
CacheRepository({
Future<Box<List<int>>>? storyIdBox,
Future<Box<Map<dynamic, dynamic>>>? storyBox,
Future<Box<String>>? webPageBox,
Future<LazyBox<String>>? webPageBox,
Future<LazyBox<Map<dynamic, dynamic>>>? commentBox,
}) : _storyIdBox = storyIdBox ?? Hive.openBox<List<int>>(_storyIdBoxName),
_storyBox =
storyBox ?? Hive.openBox<Map<dynamic, dynamic>>(_storyBoxName),
_webPageBox = webPageBox ?? Hive.openBox<String>(_webPageBoxName),
_webPageBox = webPageBox ?? Hive.openLazyBox<String>(_webPageBoxName),
_commentBox = commentBox ??
Hive.openLazyBox<Map<dynamic, dynamic>>(_commentBoxName);
@ -25,7 +27,7 @@ class CacheRepository {
final Future<Box<List<int>>> _storyIdBox;
final Future<Box<Map<dynamic, dynamic>>> _storyBox;
final Future<LazyBox<Map<dynamic, dynamic>>> _commentBox;
final Future<Box<String>> _webPageBox;
final Future<LazyBox<String>> _webPageBox;
Future<bool> get hasCachedStories =>
_storyBox.then((Box<Map<dynamic, dynamic>> box) => box.isNotEmpty);
@ -34,39 +36,92 @@ class CacheRepository {
required StoryType of,
required List<int> ids,
}) async {
final Box<List<int>> box = await _storyIdBox;
late final Box<List<int>> box;
try {
box = await _storyIdBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyIdBoxName);
box = await _storyIdBox;
}
return box.put(of.name, ids);
}
Future<void> cacheStory({required Story story}) async {
final Box<Map<dynamic, dynamic>> box = await _storyBox;
late final Box<Map<dynamic, dynamic>> box;
try {
box = await _storyBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyBoxName);
box = await _storyBox;
}
return box.put(story.id.toString(), story.toJson());
}
Future<void> cacheUrl({required String url}) async {
final Box<String> box = await _webPageBox;
final String html = await compute(downloadWebPage, url);
late final LazyBox<String> box;
try {
box = await _webPageBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_webPageBoxName);
box = await _webPageBox;
}
final String html = await compute(_downloadWebPage, url);
return box.put(url, html);
}
Future<String?> getHtml({required String url}) async {
final Box<String> box = await _webPageBox;
return box.get(url);
try {
final LazyBox<String> box = await _webPageBox;
return box.get(url);
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_webPageBoxName);
return null;
}
}
Future<bool> hasCachedWebPage({required String url}) async {
final Box<String> box = await _webPageBox;
return box.containsKey(url);
try {
final LazyBox<String> box = await _webPageBox;
return box.containsKey(url);
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_webPageBoxName);
return false;
}
}
Future<List<int>> getCachedStoryIds({required StoryType of}) async {
final Box<List<int>> box = await _storyIdBox;
final List<int>? ids = box.get(of.name);
return ids ?? <int>[];
try {
final Box<List<int>> box = await _storyIdBox;
final List<int>? ids = box.get(of.name);
return ids ?? <int>[];
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyIdBoxName);
return <int>[];
}
}
Stream<Story> getCachedStoriesStream({required List<int> ids}) async* {
final Box<Map<dynamic, dynamic>> box = await _storyBox;
late final Box<Map<dynamic, dynamic>> box;
try {
box = await _storyBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyBoxName);
return;
}
for (final int id in ids) {
final Map<dynamic, dynamic>? json = box.get(id.toString());
@ -83,7 +138,16 @@ class CacheRepository {
}
Future<Story?> getCachedStory({required int id}) async {
final Box<Map<dynamic, dynamic>> box = await _storyBox;
late final Box<Map<dynamic, dynamic>> box;
try {
box = await _storyBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyBoxName);
return null;
}
final Map<dynamic, dynamic>? json = box.get(id.toString());
if (json == null) {
return null;
@ -93,18 +157,33 @@ class CacheRepository {
}
Future<void> cacheComment({required Comment comment}) async {
final LazyBox<Map<dynamic, dynamic>> box = await _commentBox;
late final LazyBox<Map<dynamic, dynamic>> box;
try {
box = await _commentBox;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_commentBoxName);
box = await _commentBox;
}
return box.put(comment.id.toString(), comment.toJson());
}
Future<Comment?> getCachedComment({required int id}) async {
final LazyBox<Map<dynamic, dynamic>> box = await _commentBox;
final Map<dynamic, dynamic>? json = await box.get(id.toString());
if (json == null) {
try {
final LazyBox<Map<dynamic, dynamic>> box = await _commentBox;
final Map<dynamic, dynamic>? json = await box.get(id.toString());
if (json == null) {
return null;
}
final Comment comment = Comment.fromJson(json.cast<String, dynamic>());
return comment;
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_commentBoxName);
return null;
}
final Comment comment = Comment.fromJson(json.cast<String, dynamic>());
return comment;
}
Stream<Comment> getCachedCommentsStream({
@ -127,23 +206,47 @@ class CacheRepository {
}
Future<int> deleteAllStoryIds() async {
final Box<List<int>> box = await _storyIdBox;
return box.clear();
try {
final Box<List<int>> box = await _storyIdBox;
return box.clear();
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyIdBoxName);
return 0;
}
}
Future<int> deleteAllStories() async {
final Box<Map<dynamic, dynamic>> box = await _storyBox;
return box.clear();
try {
final Box<Map<dynamic, dynamic>> box = await _storyBox;
return box.clear();
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_storyBoxName);
return 0;
}
}
Future<int> deleteAllComments() async {
final LazyBox<Map<dynamic, dynamic>> box = await _commentBox;
return box.clear();
try {
final LazyBox<Map<dynamic, dynamic>> box = await _commentBox;
return box.clear();
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_commentBoxName);
return 0;
}
}
Future<int> deleteAllWebPages() async {
final Box<String> box = await _webPageBox;
return box.clear();
try {
final LazyBox<String> box = await _webPageBox;
return box.clear();
} catch (_) {
locator.get<Logger>().e(_);
await Hive.deleteBoxFromDisk(_webPageBoxName);
return 0;
}
}
Future<int> deleteAll() async {
@ -153,12 +256,13 @@ class CacheRepository {
.whenComplete(deleteAllWebPages);
}
static Future<String> downloadWebPage(String link) async {
static Future<String> _downloadWebPage(String link) async {
try {
final Client client = Client();
final Uri url = Uri.parse(link);
final Response response = await client.get(url);
final String body = response.body;
client.close();
return body;
} catch (_) {
return '''Web page not available.''';

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hacki/config/locator.dart';
import 'package:logger/logger.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:synced_shared_preferences/synced_shared_preferences.dart';
@ -140,8 +142,29 @@ class PreferenceRepository {
required String username,
required String password,
}) async {
await _secureStorage.write(key: _usernameKey, value: username);
await _secureStorage.write(key: _passwordKey, value: password);
const AndroidOptions androidOptions = AndroidOptions(resetOnError: true);
try {
await _secureStorage.write(
key: _usernameKey,
value: username,
aOptions: androidOptions,
);
await _secureStorage.write(
key: _passwordKey,
value: password,
aOptions: androidOptions,
);
} catch (_) {
try {
await _secureStorage.deleteAll(
aOptions: androidOptions,
);
} catch (_) {
locator.get<Logger>().e(_);
}
rethrow;
}
}
Future<void> removeAuth() async {

View File

@ -24,6 +24,7 @@ import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/screens/screens.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/services/services.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import 'package:responsive_builder/responsive_builder.dart';
@ -45,7 +46,7 @@ class HomeScreen extends StatefulWidget {
}
class _HomeScreenState extends State<HomeScreen>
with SingleTickerProviderStateMixin, RouteAware {
with SingleTickerProviderStateMixin {
final CacheService cacheService = locator.get<CacheService>();
final Throttle featureDiscoveryDismissThrottle = Throttle(
delay: _throttleDelay,
@ -60,18 +61,6 @@ class _HomeScreenState extends State<HomeScreen>
static const Duration _throttleDelay = Duration(seconds: 1);
@override
void didPopNext() {
super.didPopNext();
if (context.read<StoriesBloc>().deviceScreenType ==
DeviceScreenType.mobile) {
Future<void>.delayed(
const Duration(milliseconds: 500),
cacheService.resetCollapsedComments,
);
}
}
@override
void initState() {
super.initState();
@ -99,24 +88,14 @@ class _HomeScreenState extends State<HomeScreen>
siriSuggestionSubject.stream.listen(onSiriSuggestionTapped);
}
SchedulerBinding.instance
..addPostFrameCallback((_) {
FeatureDiscovery.discoverFeatures(
context,
const <String>{
Constants.featureLogIn,
},
);
})
..addPostFrameCallback((_) {
final ModalRoute<dynamic>? route = ModalRoute.of(context);
if (route == null) return;
locator
.get<RouteObserver<ModalRoute<dynamic>>>()
.subscribe(this, route);
});
SchedulerBinding.instance.addPostFrameCallback((_) {
FeatureDiscovery.discoverFeatures(
context,
const <String>{
Constants.featureLogIn,
},
);
});
tabController = TabController(vsync: this, length: 6)
..addListener(() {
@ -171,8 +150,8 @@ class _HomeScreenState extends State<HomeScreen>
HapticFeedback.lightImpact();
context.read<PinCubit>().unpinStory(story);
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
backgroundColor: Palette.red,
foregroundColor: Palette.white,
icon: preferenceState.showComplexStoryTile
? Icons.close
: null,
@ -181,7 +160,7 @@ class _HomeScreenState extends State<HomeScreen>
],
),
child: Container(
color: Colors.orangeAccent.withOpacity(0.2),
color: Palette.orangeAccent.withOpacity(0.2),
child: StoryTile(
key: ValueKey<String>('${story.id}-PinnedStoryTile'),
story: story,
@ -194,9 +173,9 @@ class _HomeScreenState extends State<HomeScreen>
),
if (state.pinnedStories.isNotEmpty)
const Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
padding: EdgeInsets.symmetric(horizontal: Dimens.pt12),
child: Divider(
color: Colors.orangeAccent,
color: Palette.orangeAccent,
),
),
],
@ -209,27 +188,32 @@ class _HomeScreenState extends State<HomeScreen>
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: PreferredSize(
preferredSize: const Size(0, 40),
preferredSize: const Size(
Dimens.zero,
Dimens.pt40,
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top - 8,
height: MediaQuery.of(context).padding.top - Dimens.pt8,
),
Theme(
data: ThemeData(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
highlightColor: Palette.transparent,
splashColor: Palette.transparent,
primaryColor: Theme.of(context).primaryColor,
),
child: TabBar(
isScrollable: true,
controller: tabController,
indicatorColor: Colors.orange,
indicatorColor: Palette.orange,
indicator: CircleTabIndicator(
color: Colors.orange,
radius: 2,
color: Palette.orange,
radius: Dimens.pt2,
),
indicatorPadding: const EdgeInsets.only(
bottom: Dimens.pt8,
),
indicatorPadding: const EdgeInsets.only(bottom: 8),
onTap: (_) {
HapticFeedback.selectionClick();
},
@ -242,10 +226,12 @@ class _HomeScreenState extends State<HomeScreen>
child: Text(
StoriesBloc.types.elementAt(i).label,
style: TextStyle(
fontSize: currentIndex == i ? 14 : 10,
fontSize: currentIndex == i
? TextDimens.pt14
: TextDimens.pt10,
color: currentIndex == i
? Colors.orange
: Colors.grey,
? Palette.orange
: Palette.grey,
),
),
),
@ -263,8 +249,8 @@ class _HomeScreenState extends State<HomeScreen>
targetColor: Theme.of(context).primaryColor,
tapTarget: const Icon(
Icons.person,
size: 16,
color: Colors.white,
size: TextDimens.pt16,
color: Palette.white,
),
featureId: Constants.featureLogIn,
title: const Text('Log in for more'),
@ -274,7 +260,7 @@ class _HomeScreenState extends State<HomeScreen>
'posted in the past, and get in-app '
'notification when there is new reply to '
'your comments or stories.',
style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: TextDimens.pt16),
),
child: BlocBuilder<NotificationCubit,
NotificationState>(
@ -292,19 +278,21 @@ class _HomeScreenState extends State<HomeScreen>
showBadge: state.unreadCommentsIds.isNotEmpty,
borderRadius: BorderRadius.circular(100),
badgeContent: Container(
height: 3,
width: 3,
height: Dimens.pt3,
width: Dimens.pt3,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
color: Palette.white,
),
),
child: Icon(
Icons.person,
size: currentIndex == 5 ? 16 : 12,
size: currentIndex == 5
? TextDimens.pt16
: TextDimens.pt12,
color: currentIndex == 5
? Colors.orange
: Colors.grey,
? Palette.orange
: Palette.grey,
),
);
},
@ -506,10 +494,10 @@ class _MobileHomeScreen extends StatelessWidget {
Positioned.fill(child: homeScreen),
if (!context.read<ReminderCubit>().state.hasShown)
const Positioned(
left: 24,
right: 24,
bottom: 36,
height: 40,
left: Dimens.pt24,
right: Dimens.pt24,
bottom: Dimens.pt36,
height: Dimens.pt40,
child: CountdownReminder(),
),
],
@ -533,7 +521,7 @@ class _TabletHomeScreen extends StatelessWidget {
double homeScreenWidth = 428;
if (sizeInfo.screenSize.width < homeScreenWidth * 2) {
homeScreenWidth = 345.0;
homeScreenWidth = 345;
}
return BlocBuilder<SplitViewCubit, SplitViewState>(
@ -543,26 +531,26 @@ class _TabletHomeScreen extends StatelessWidget {
return Stack(
children: <Widget>[
AnimatedPositioned(
left: 0,
top: 0,
bottom: 0,
width: state.expanded ? 0 : homeScreenWidth,
left: Dimens.zero,
top: Dimens.zero,
bottom: Dimens.zero,
width: state.expanded ? Dimens.zero : homeScreenWidth,
duration: const Duration(milliseconds: 300),
curve: Curves.elasticOut,
child: homeScreen,
),
Positioned(
left: 24,
bottom: 36,
height: 40,
width: homeScreenWidth - 24,
left: Dimens.pt24,
bottom: Dimens.pt36,
height: Dimens.pt40,
width: homeScreenWidth - Dimens.pt24,
child: const CountdownReminder(),
),
AnimatedPositioned(
right: 0,
top: 0,
bottom: 0,
left: state.expanded ? 0 : homeScreenWidth,
right: Dimens.zero,
top: Dimens.zero,
bottom: Dimens.zero,
left: state.expanded ? Dimens.zero : homeScreenWidth,
duration: const Duration(milliseconds: 300),
curve: Curves.elasticOut,
child: const _TabletStoryView(),

View File

@ -19,6 +19,7 @@ import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/screens/item/widgets/widgets.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/services/services.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:responsive_builder/responsive_builder.dart';
@ -65,25 +66,31 @@ class ItemScreen extends StatefulWidget {
static Route<dynamic> route(ItemScreenArgs args) {
return MaterialPageRoute<ItemScreen>(
settings: const RouteSettings(name: routeName),
builder: (BuildContext context) => MultiBlocProvider(
providers: <BlocProvider<dynamic>>[
BlocProvider<CommentsCubit>(
create: (_) => CommentsCubit(
offlineReading: context.read<StoriesBloc>().state.offlineReading,
item: args.item,
)..init(
onlyShowTargetComment: args.onlyShowTargetComment,
targetParents: args.targetComments,
),
builder: (BuildContext context) => RepositoryProvider<CacheService>(
create: (BuildContext context) => CacheService(),
lazy: false,
child: MultiBlocProvider(
providers: <BlocProvider<dynamic>>[
BlocProvider<CommentsCubit>(
create: (BuildContext context) => CommentsCubit(
offlineReading:
context.read<StoriesBloc>().state.offlineReading,
item: args.item,
cacheService: context.read<CacheService>(),
)..init(
onlyShowTargetComment: args.onlyShowTargetComment,
targetParents: args.targetComments,
),
),
BlocProvider<EditCubit>(
lazy: false,
create: (BuildContext context) => EditCubit(),
),
],
child: ItemScreen(
item: args.item,
parentComments: args.targetComments ?? <Comment>[],
),
BlocProvider<EditCubit>(
lazy: false,
create: (BuildContext context) => EditCubit(),
),
],
child: ItemScreen(
item: args.item,
parentComments: args.targetComments ?? <Comment>[],
),
),
);
@ -99,27 +106,32 @@ class ItemScreen extends StatefulWidget {
return true;
}
},
child: MultiBlocProvider(
key: ValueKey<ItemScreenArgs>(args),
providers: <BlocProvider<dynamic>>[
BlocProvider<CommentsCubit>(
create: (BuildContext context) => CommentsCubit(
offlineReading: context.read<StoriesBloc>().state.offlineReading,
item: args.item,
)..init(
onlyShowTargetComment: args.onlyShowTargetComment,
targetParents: args.targetComments,
),
child: RepositoryProvider<CacheService>(
create: (BuildContext context) => CacheService(),
child: MultiBlocProvider(
key: ValueKey<ItemScreenArgs>(args),
providers: <BlocProvider<dynamic>>[
BlocProvider<CommentsCubit>(
create: (BuildContext context) => CommentsCubit(
offlineReading:
context.read<StoriesBloc>().state.offlineReading,
item: args.item,
cacheService: context.read<CacheService>(),
)..init(
onlyShowTargetComment: args.onlyShowTargetComment,
targetParents: args.targetComments,
),
),
BlocProvider<EditCubit>(
lazy: false,
create: (BuildContext context) => EditCubit(),
),
],
child: ItemScreen(
item: args.item,
parentComments: args.targetComments ?? <Comment>[],
splitViewEnabled: true,
),
BlocProvider<EditCubit>(
lazy: false,
create: (BuildContext context) => EditCubit(),
),
],
child: ItemScreen(
item: args.item,
parentComments: args.targetComments ?? <Comment>[],
splitViewEnabled: true,
),
),
);
@ -239,13 +251,15 @@ class _ItemScreenState extends State<ItemScreen> {
enablePullUp: !state.onlyShowTargetComment,
enablePullDown: !state.onlyShowTargetComment,
header: WaterDropMaterialHeader(
backgroundColor: Colors.orange,
backgroundColor: Palette.orange,
offset: topPadding,
),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
const double height = 55;
late final Widget body;
if (mode == LoadStatus.idle) {
body = const Text('');
} else if (mode == LoadStatus.loading) {
@ -262,7 +276,7 @@ class _ItemScreenState extends State<ItemScreen> {
body = const Text('');
}
return SizedBox(
height: 55,
height: height,
child: Center(child: body),
);
},
@ -276,7 +290,7 @@ class _ItemScreenState extends State<ItemScreen> {
} else {
context.read<CommentsCubit>().refresh();
if (widget.item.isPoll) {
if (state.item.isPoll) {
context.read<PollCubit>().refresh();
}
}
@ -290,7 +304,7 @@ class _ItemScreenState extends State<ItemScreen> {
),
if (!widget.splitViewEnabled)
const Padding(
padding: EdgeInsets.only(bottom: 6),
padding: EdgeInsets.only(bottom: Dimens.pt6),
child: OfflineBanner(),
),
Slidable(
@ -301,23 +315,27 @@ class _ItemScreenState extends State<ItemScreen> {
onPressed: (_) {
HapticFeedback.lightImpact();
if (widget.item !=
context.read<EditCubit>().state.replyingTo) {
if (state.item.id !=
context
.read<EditCubit>()
.state
.replyingTo
?.id) {
commentEditingController.clear();
}
context
.read<EditCubit>()
.onReplyTapped(widget.item);
.onReplyTapped(state.item);
focusNode.requestFocus();
},
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.message,
),
SlidableAction(
onPressed: (_) => onMoreTapped(widget.item),
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
onPressed: (_) => onMoreTapped(state.item),
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.more_horiz,
),
],
@ -326,22 +344,22 @@ class _ItemScreenState extends State<ItemScreen> {
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 6,
right: 6,
left: Dimens.pt6,
right: Dimens.pt6,
),
child: Row(
children: <Widget>[
Text(
state.item.by,
style: const TextStyle(
color: Colors.orange,
color: Palette.orange,
),
),
const Spacer(),
Text(
state.item.postedDate,
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
],
@ -362,10 +380,10 @@ class _ItemScreenState extends State<ItemScreen> {
),
child: Padding(
padding: const EdgeInsets.only(
left: 6,
right: 6,
bottom: 12,
top: 12,
left: Dimens.pt6,
right: Dimens.pt6,
bottom: Dimens.pt12,
top: Dimens.pt12,
),
child: Text(
state.item.title,
@ -373,7 +391,7 @@ class _ItemScreenState extends State<ItemScreen> {
style: TextStyle(
fontWeight: FontWeight.bold,
color: state.item.url.isNotEmpty
? Colors.orange
? Palette.orange
: null,
),
),
@ -381,25 +399,25 @@ class _ItemScreenState extends State<ItemScreen> {
)
else
const SizedBox(
height: 6,
height: Dimens.pt6,
),
if (state.item.text.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
horizontal: Dimens.pt10,
),
child: SelectableLinkify(
text: widget.item.text,
text: state.item.text,
style: TextStyle(
fontSize:
MediaQuery.of(context).textScaleFactor *
15,
TextDimens.pt15,
),
linkStyle: TextStyle(
fontSize:
MediaQuery.of(context).textScaleFactor *
15,
color: Colors.orange,
TextDimens.pt15,
color: Palette.orange,
),
onOpen: (LinkableElement link) {
if (link.url.contains(
@ -425,10 +443,10 @@ class _ItemScreenState extends State<ItemScreen> {
),
if (state.item.text.isNotEmpty)
const SizedBox(
height: 8,
height: Dimens.pt8,
),
const Divider(
height: 0,
height: Dimens.zero,
),
if (state.onlyShowTargetComment) ...<Widget>[
Center(
@ -440,21 +458,21 @@ class _ItemScreenState extends State<ItemScreen> {
),
),
const Divider(
height: 0,
height: Dimens.zero,
),
] else ...<Widget>[
Row(
children: <Widget>[
if (state.item is Story) ...<Widget>[
const SizedBox(
width: 12,
width: Dimens.pt12,
),
Text(
'''${state.item.score} karma, ${state.item.descendants} comment${state.item.descendants > 1 ? 's' : ''}''',
),
] else ...<Widget>[
const SizedBox(
width: 4,
width: Dimens.pt4,
),
TextButton(
onPressed: context
@ -463,10 +481,10 @@ class _ItemScreenState extends State<ItemScreen> {
child: state.fetchParentStatus ==
CommentsStatus.loading
? const SizedBox(
height: 12,
width: 12,
height: Dimens.pt12,
width: Dimens.pt12,
child: CustomCircularProgressIndicator(
strokeWidth: 2,
strokeWidth: Dimens.pt2,
),
)
: const Text('View parent thread'),
@ -482,7 +500,7 @@ class _ItemScreenState extends State<ItemScreen> {
child: Text(
'Natural',
style: TextStyle(
fontSize: 14,
fontSize: TextDimens.pt14,
),
),
),
@ -491,7 +509,7 @@ class _ItemScreenState extends State<ItemScreen> {
child: Text(
'Newest first',
style: TextStyle(
fontSize: 14,
fontSize: TextDimens.pt14,
),
),
),
@ -500,7 +518,7 @@ class _ItemScreenState extends State<ItemScreen> {
child: Text(
'Oldest first',
style: TextStyle(
fontSize: 14,
fontSize: TextDimens.pt14,
),
),
),
@ -509,12 +527,12 @@ class _ItemScreenState extends State<ItemScreen> {
context.read<CommentsCubit>().onOrderChanged,
),
const SizedBox(
width: 4,
width: Dimens.pt4,
),
],
),
const Divider(
height: 0,
height: Dimens.zero,
),
],
if (state.comments.isEmpty &&
@ -525,7 +543,7 @@ class _ItemScreenState extends State<ItemScreen> {
const Center(
child: Text(
'Nothing yet',
style: TextStyle(color: Colors.grey),
style: TextStyle(color: Palette.grey),
),
),
],
@ -537,15 +555,19 @@ class _ItemScreenState extends State<ItemScreen> {
level: comment.level,
myUsername:
authState.isLoggedIn ? authState.username : null,
opUsername: widget.item.by,
opUsername: state.item.by,
onReplyTapped: (Comment cmt) {
HapticFeedback.lightImpact();
if (cmt.deleted || cmt.dead) {
return;
}
if (cmt !=
context.read<EditCubit>().state.replyingTo) {
if (cmt.id !=
context
.read<EditCubit>()
.state
.replyingTo
?.id) {
commentEditingController.clear();
}
@ -619,9 +641,9 @@ class _ItemScreenState extends State<ItemScreen> {
SplitViewState state,
) {
return Positioned(
top: 0,
left: 0,
right: 0,
top: Dimens.zero,
left: Dimens.zero,
right: Dimens.zero,
child: CustomAppBar(
backgroundColor: Theme.of(context)
.canvasColor
@ -640,9 +662,9 @@ class _ItemScreenState extends State<ItemScreen> {
},
),
Positioned(
bottom: 0,
left: 0,
right: 0,
bottom: Dimens.zero,
left: Dimens.zero,
right: Dimens.zero,
child: ReplyBox(
splitViewEnabled: true,
focusNode: focusNode,
@ -702,15 +724,17 @@ class _ItemScreenState extends State<ItemScreen> {
}
void onRightMoreTapped(Comment comment) {
const double bottomSheetHeight = 140;
HapticFeedback.lightImpact();
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: 140,
height: bottomSheetHeight,
color: Theme.of(context).canvasColor,
child: Material(
color: Colors.transparent,
color: Palette.transparent,
child: Column(
children: <Widget>[
ListTile(
@ -758,28 +782,32 @@ class _ItemScreenState extends State<ItemScreen> {
return Center(
child: Material(
color: Theme.of(context).canvasColor,
borderRadius: const BorderRadius.all(Radius.circular(4)),
borderRadius: const BorderRadius.all(
Radius.circular(
Dimens.pt4,
),
),
child: SizedBox(
height: size.height * 0.8,
width: size.width * widthFactor,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 12,
horizontal: Dimens.pt8,
vertical: Dimens.pt12,
),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
const SizedBox(
width: 8,
width: Dimens.pt8,
),
const Text('Parents:'),
const Spacer(),
IconButton(
icon: const Icon(
Icons.close,
size: 16,
size: Dimens.pt16,
),
onPressed: () => Navigator.pop(context),
padding: EdgeInsets.zero,
@ -799,7 +827,7 @@ class _ItemScreenState extends State<ItemScreen> {
actionable: false,
),
const Divider(
height: 0,
height: Dimens.zero,
),
],
],
@ -893,7 +921,7 @@ class _ItemScreenState extends State<ItemScreen> {
height: item is Comment ? 430 : 450,
color: Theme.of(context).canvasColor,
child: Material(
color: Colors.transparent,
color: Palette.transparent,
child: Column(
children: <Widget>[
BlocProvider<UserCubit>(
@ -923,7 +951,7 @@ class _ItemScreenState extends State<ItemScreen> {
Text(
'empty',
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
],
@ -933,7 +961,7 @@ class _ItemScreenState extends State<ItemScreen> {
state.user.about,
),
linkStyle: const TextStyle(
color: Colors.orange,
color: Palette.orange,
),
onOpen: (LinkableElement link) {
if (link.url.contains(
@ -964,12 +992,12 @@ class _ItemScreenState extends State<ItemScreen> {
ListTile(
leading: Icon(
FeatherIcons.chevronUp,
color: upvoted ? Colors.orange : null,
color: upvoted ? Palette.orange : null,
),
title: Text(
upvoted ? 'Upvoted' : 'Upvote',
style: upvoted
? const TextStyle(color: Colors.orange)
? const TextStyle(color: Palette.orange)
: null,
),
subtitle:
@ -979,12 +1007,12 @@ class _ItemScreenState extends State<ItemScreen> {
ListTile(
leading: Icon(
FeatherIcons.chevronDown,
color: downvoted ? Colors.orange : null,
color: downvoted ? Palette.orange : null,
),
title: Text(
downvoted ? 'Downvoted' : 'Downvote',
style: downvoted
? const TextStyle(color: Colors.orange)
? const TextStyle(color: Palette.orange)
: null,
),
onTap: context.read<VoteCubit>().downvote,
@ -1074,7 +1102,7 @@ class _ItemScreenState extends State<ItemScreen> {
content: Text(
'Flag this comment posted by ${item.by}?',
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
actions: <Widget>[
@ -1112,7 +1140,7 @@ class _ItemScreenState extends State<ItemScreen> {
' and ${isBlocked ? 'display' : 'hide'} '
'comments posted by this user?',
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
actions: <Widget>[
@ -1187,64 +1215,64 @@ class _ItemScreenState extends State<ItemScreen> {
children: <Widget>[
if (state.status == AuthStatus.loading)
const SizedBox(
height: 36,
width: 36,
height: Dimens.pt36,
width: Dimens.pt36,
child: Center(
child: CircularProgressIndicator(
color: Colors.orange,
color: Palette.orange,
),
),
)
else if (!state.isLoggedIn) ...<Widget>[
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 18,
horizontal: Dimens.pt18,
),
child: TextField(
controller: usernameController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Username',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
),
),
const SizedBox(
height: 16,
height: Dimens.pt16,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 18,
horizontal: Dimens.pt18,
),
child: TextField(
controller: passwordController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
obscureText: true,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Password',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
),
),
const SizedBox(
height: 16,
height: Dimens.pt16,
),
if (state.status == AuthStatus.failure)
Padding(
padding: const EdgeInsets.only(
left: 18,
left: Dimens.pt18,
),
child: Text(
'Something went wrong... $sadFace',
style: const TextStyle(
color: Colors.grey,
fontSize: 12,
color: Palette.grey,
fontSize: TextDimens.pt12,
),
),
),
@ -1258,8 +1286,8 @@ class _ItemScreenState extends State<ItemScreen> {
? Icons.check_box
: Icons.check_box_outline_blank,
color: state.agreedToEULA
? Colors.deepOrange
: Colors.grey,
? Palette.deepOrange
: Palette.grey,
),
onPressed: () => context
.read<AuthBloc>()
@ -1284,7 +1312,7 @@ class _ItemScreenState extends State<ItemScreen> {
child: const Text(
'End User Agreement',
style: TextStyle(
color: Colors.deepOrange,
color: Palette.deepOrange,
decoration: TextDecoration.underline,
fontWeight: FontWeight.w600,
),
@ -1299,7 +1327,7 @@ class _ItemScreenState extends State<ItemScreen> {
),
Padding(
padding: const EdgeInsets.only(
right: 12,
right: Dimens.pt12,
),
child: ButtonBar(
children: <Widget>[
@ -1330,15 +1358,15 @@ class _ItemScreenState extends State<ItemScreen> {
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
state.agreedToEULA
? Colors.deepOrange
: Colors.grey,
? Palette.deepOrange
: Palette.grey,
),
),
child: const Text(
'Log in',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
color: Palette.white,
),
),
),

View File

@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/item/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
class CustomAppBar extends AppBar {
CustomAppBar({
@ -18,7 +19,7 @@ class CustomAppBar extends AppBar {
}) : super(
key: key,
backgroundColor: backgroundColor,
elevation: 0,
elevation: Dimens.zero,
actions: <Widget>[
if (splitViewEnabled) ...<Widget>[
IconButton(
@ -26,7 +27,7 @@ class CustomAppBar extends AppBar {
expanded ?? false
? FeatherIcons.minimize2
: FeatherIcons.maximize2,
size: 20,
size: TextDimens.pt20,
),
onPressed: () {
HapticFeedback.lightImpact();

View File

@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/styles/styles.dart';
class FavIconButton extends StatelessWidget {
const FavIconButton({
@ -37,17 +38,17 @@ class FavIconButton extends StatelessWidget {
targetColor: Theme.of(context).primaryColor,
tapTarget: Icon(
isFav ? Icons.favorite : Icons.favorite_border,
color: Colors.white,
color: Palette.white,
),
featureId: Constants.featureAddStoryToFavList,
title: const Text('Fav a Story'),
description: const Text(
'Add it to your favorites.',
style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: TextDimens.pt16),
),
child: Icon(
isFav ? Icons.favorite : Icons.favorite_border,
color: isFav ? Colors.orange : Theme.of(context).iconTheme.color,
color: isFav ? Palette.orange : Theme.of(context).iconTheme.color,
),
),
onPressed: () {

View File

@ -4,6 +4,7 @@ import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
class LinkIconButton extends StatelessWidget {
@ -33,7 +34,7 @@ class LinkIconButton extends StatelessWidget {
targetColor: Theme.of(context).primaryColor,
tapTarget: const Icon(
Icons.stream,
color: Colors.white,
color: Palette.white,
),
featureId: Constants.featureOpenStoryInWebView,
title: const Text('Open in Browser'),
@ -41,7 +42,7 @@ class LinkIconButton extends StatelessWidget {
'Want more than just reading and replying? '
'You can tap here to open this story in a '
'browser.',
style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: TextDimens.pt16),
),
child: const Icon(
Icons.stream,

View File

@ -8,6 +8,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/styles/styles.dart';
class PinIconButton extends StatelessWidget {
const PinIconButton({
@ -43,7 +44,7 @@ class PinIconButton extends StatelessWidget {
targetColor: Theme.of(context).primaryColor,
tapTarget: Icon(
pinned ? Icons.push_pin : Icons.push_pin_outlined,
color: Colors.white,
color: Palette.white,
),
featureId: Constants.featurePinToTop,
title: const Text('Pin a Story'),
@ -51,12 +52,12 @@ class PinIconButton extends StatelessWidget {
'Pin this story to the top of your '
'home screen so that you can come'
' back later.',
style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: TextDimens.pt16),
),
child: Icon(
pinned ? Icons.push_pin : Icons.push_pin_outlined,
color: pinned
? Colors.orange
? Palette.orange
: Theme.of(context).iconTheme.color,
),
),

View File

@ -5,6 +5,7 @@ import 'package:flutter_fadein/flutter_fadein.dart';
import 'package:hacki/blocs/auth/auth_bloc.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/styles/styles.dart';
class PollView extends StatelessWidget {
const PollView({
@ -21,29 +22,29 @@ class PollView extends StatelessWidget {
return Column(
children: <Widget>[
const SizedBox(
height: 24,
height: Dimens.pt24,
),
if (state.status == PollStatus.loading) ...<Widget>[
const LinearProgressIndicator(),
const SizedBox(
height: 24,
height: Dimens.pt24,
),
] else ...<Widget>[
Row(
children: <Widget>[
const SizedBox(
width: 24,
width: Dimens.pt24,
),
Text(
'Total votes: ${state.totalVotes}',
style: const TextStyle(
fontSize: 14,
fontSize: TextDimens.pt14,
),
),
],
),
const SizedBox(
height: 12,
height: Dimens.pt12,
),
],
for (final PollOption option in state.pollOptions)
@ -97,9 +98,9 @@ class PollView extends StatelessWidget {
builder: (BuildContext context, VoteState voteState) {
return Padding(
padding: const EdgeInsets.only(
left: 12,
right: 24,
bottom: 4,
left: Dimens.pt12,
right: Dimens.pt24,
bottom: Dimens.pt4,
),
child: Row(
children: <Widget>[
@ -111,9 +112,9 @@ class PollView extends StatelessWidget {
icon: Icon(
Icons.arrow_drop_up,
color: voteState.vote == Vote.up
? Colors.orange
: Colors.grey,
size: 36,
? Palette.orange
: Palette.grey,
size: TextDimens.pt36,
),
),
Expanded(
@ -126,16 +127,16 @@ class PollView extends StatelessWidget {
Text(
'''${option.score} vote${option.score > 1 ? 's' : ''}''',
style: const TextStyle(
color: Colors.grey,
fontSize: 12,
color: Palette.grey,
fontSize: TextDimens.pt12,
),
),
const SizedBox(
height: 4,
height: Dimens.pt4,
),
LinearProgressIndicator(
value: option.ratio,
color: Colors.deepOrange,
color: Palette.deepOrange,
),
],
),
@ -161,7 +162,7 @@ class PollView extends StatelessWidget {
}) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.deepOrange,
backgroundColor: Palette.deepOrange,
content: Text(content),
action: action != null && label != null
? SnackBarAction(

View File

@ -6,6 +6,7 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/item.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/link_util.dart';
class ReplyBox extends StatefulWidget {
@ -34,6 +35,8 @@ class _ReplyBoxState extends State<ReplyBox> {
bool expanded = false;
double? expandedHeight;
static const double _collapsedHeight = 100;
@override
Widget build(BuildContext context) {
expandedHeight ??= MediaQuery.of(context).size.height;
@ -53,20 +56,21 @@ class _ReplyBoxState extends State<ReplyBox> {
return Padding(
padding: EdgeInsets.only(
bottom: expanded
? 0
? Dimens.zero
: widget.splitViewEnabled
? MediaQuery.of(context).viewInsets.bottom
: 0,
: Dimens.zero,
),
child: AnimatedContainer(
height: expanded ? expandedHeight : 100,
height: expanded ? expandedHeight : _collapsedHeight,
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
if (!context.read<SplitViewCubit>().state.enabled)
BoxShadow(
color: expanded ? Colors.transparent : Colors.black26,
blurRadius: 40,
color:
expanded ? Palette.transparent : Palette.black26,
blurRadius: Dimens.pt40,
),
],
),
@ -75,10 +79,10 @@ class _ReplyBoxState extends State<ReplyBox> {
children: <Widget>[
if (context.read<SplitViewCubit>().state.enabled)
const Divider(
height: 0,
height: Dimens.zero,
),
AnimatedContainer(
height: expanded ? 36 : 0,
height: expanded ? Dimens.pt36 : Dimens.zero,
duration: const Duration(milliseconds: 200),
),
Row(
@ -86,16 +90,16 @@ class _ReplyBoxState extends State<ReplyBox> {
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 12,
top: 8,
bottom: 8,
left: Dimens.pt12,
top: Dimens.pt8,
bottom: Dimens.pt8,
),
child: Text(
replyingTo == null
? 'Editing'
: 'Replying '
'${replyingTo.by}',
style: const TextStyle(color: Colors.grey),
style: const TextStyle(color: Palette.grey),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@ -111,8 +115,8 @@ class _ReplyBoxState extends State<ReplyBox> {
key: const Key('quote'),
icon: const Icon(
FeatherIcons.code,
color: Colors.orange,
size: 18,
color: Palette.orange,
size: TextDimens.pt18,
),
onPressed:
expanded ? showTextPopup : null,
@ -124,8 +128,8 @@ class _ReplyBoxState extends State<ReplyBox> {
expanded
? FeatherIcons.minimize2
: FeatherIcons.maximize2,
color: Colors.orange,
size: 18,
color: Palette.orange,
size: TextDimens.pt18,
),
onPressed: () {
setState(() {
@ -138,7 +142,7 @@ class _ReplyBoxState extends State<ReplyBox> {
key: const Key('close'),
icon: const Icon(
Icons.close,
color: Colors.orange,
color: Palette.orange,
),
onPressed: () {
widget.onCloseTapped();
@ -149,15 +153,15 @@ class _ReplyBoxState extends State<ReplyBox> {
if (isLoading)
const Padding(
padding: EdgeInsets.symmetric(
vertical: 12,
horizontal: 16,
vertical: Dimens.pt12,
horizontal: Dimens.pt16,
),
child: SizedBox(
height: 24,
width: 24,
height: Dimens.pt24,
width: Dimens.pt24,
child: CircularProgressIndicator(
color: Colors.orange,
strokeWidth: 2,
color: Palette.orange,
strokeWidth: Dimens.pt2,
),
),
)
@ -166,7 +170,7 @@ class _ReplyBoxState extends State<ReplyBox> {
key: const Key('send'),
icon: const Icon(
Icons.send,
color: Colors.orange,
color: Palette.orange,
),
onPressed: () {
widget.onSendTapped();
@ -177,7 +181,9 @@ class _ReplyBoxState extends State<ReplyBox> {
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(
horizontal: Dimens.pt16,
),
child: TextField(
focusNode: widget.focusNode,
controller: widget.textEditingController,
@ -187,7 +193,7 @@ class _ReplyBoxState extends State<ReplyBox> {
contentPadding: EdgeInsets.zero,
hintText: '...',
hintStyle: TextStyle(
color: Colors.grey,
color: Palette.grey,
),
focusedBorder: InputBorder.none,
border: InputBorder.none,
@ -220,8 +226,8 @@ class _ReplyBoxState extends State<ReplyBox> {
builder: (_) {
return AlertDialog(
insetPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 24,
horizontal: Dimens.pt12,
vertical: Dimens.pt24,
),
contentPadding: EdgeInsets.zero,
content: ConstrainedBox(
@ -233,14 +239,14 @@ class _ReplyBoxState extends State<ReplyBox> {
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 12,
top: 6,
left: Dimens.pt12,
top: Dimens.pt6,
),
child: Row(
children: <Widget>[
Text(
replyingTo?.by ?? '',
style: const TextStyle(color: Colors.grey),
style: const TextStyle(color: Palette.grey),
),
const Spacer(),
TextButton(
@ -252,8 +258,8 @@ class _ReplyBoxState extends State<ReplyBox> {
IconButton(
icon: const Icon(
Icons.close,
color: Colors.orange,
size: 18,
color: Palette.orange,
size: TextDimens.pt18,
),
onPressed: () => Navigator.pop(context),
),
@ -265,17 +271,17 @@ class _ReplyBoxState extends State<ReplyBox> {
thumbVisibility: true,
child: Padding(
padding: const EdgeInsets.only(
left: 12,
right: 6,
top: 6,
left: Dimens.pt12,
right: Dimens.pt6,
top: Dimens.pt6,
),
child: SingleChildScrollView(
child: SelectableLinkify(
scrollPhysics: const NeverScrollableScrollPhysics(),
linkStyle: TextStyle(
fontSize:
MediaQuery.of(context).textScaleFactor * 15,
color: Colors.orange,
fontSize: MediaQuery.of(context).textScaleFactor *
TextDimens.pt15,
color: Palette.orange,
),
onOpen: (LinkableElement link) =>
LinkUtil.launch(link.url),

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:hacki/styles/styles.dart';
class ScrollUpIconButton extends StatefulWidget {
const ScrollUpIconButton({
@ -35,8 +36,8 @@ class _ScrollUpIconButtonState extends State<ScrollUpIconButton> {
child: IconButton(
icon: const Icon(
FeatherIcons.chevronsUp,
color: Colors.orange,
size: 26,
color: Palette.orange,
size: TextDimens.pt26,
),
onPressed: () {
final double curPos = widget.scrollController.offset;

View File

@ -18,6 +18,7 @@ import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/screens/profile/widgets/widgets.dart';
import 'package:hacki/screens/screens.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:tuple/tuple.dart';
@ -91,7 +92,7 @@ class _ProfileScreenState extends State<ProfileScreen>
return Stack(
children: <Widget>[
Positioned.fill(
top: 50,
top: Dimens.pt50,
child: Visibility(
visible: pageType == _PageType.history,
child: BlocConsumer<HistoryCubit, HistoryState>(
@ -148,7 +149,7 @@ class _ProfileScreenState extends State<ProfileScreen>
),
),
Positioned.fill(
top: 50,
top: Dimens.pt50,
child: Visibility(
visible: pageType == _PageType.fav,
child: BlocConsumer<FavCubit, FavState>(
@ -192,7 +193,7 @@ class _ProfileScreenState extends State<ProfileScreen>
),
),
Positioned.fill(
top: 50,
top: Dimens.pt50,
child: Visibility(
visible: pageType == _PageType.search,
maintainState: true,
@ -200,7 +201,7 @@ class _ProfileScreenState extends State<ProfileScreen>
),
),
Positioned.fill(
top: 50,
top: Dimens.pt50,
child: Visibility(
visible: pageType == _PageType.notification,
child: notificationState.comments.isEmpty
@ -241,7 +242,7 @@ class _ProfileScreenState extends State<ProfileScreen>
),
),
Positioned.fill(
top: 50,
top: Dimens.pt50,
child: Visibility(
visible: pageType == _PageType.settings,
child: SingleChildScrollView(
@ -280,7 +281,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleNotificationMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('Complex Story Tile'),
@ -294,7 +295,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleDisplayMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('Show Metadata'),
@ -309,7 +310,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleMetadataMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('Show Web Page First'),
@ -324,7 +325,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleNavigationMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
if (Platform.isIOS)
SwitchListTile(
@ -340,7 +341,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleReaderMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('Mark Read Stories'),
@ -361,7 +362,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleMarkReadStoriesMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('Eye Candy'),
@ -373,7 +374,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleEyeCandyMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
SwitchListTile(
title: const Text('True Dark Mode'),
@ -387,7 +388,7 @@ class _ProfileScreenState extends State<ProfileScreen>
.read<PreferenceCubit>()
.toggleTrueDarkMode();
},
activeColor: Colors.orange,
activeColor: Palette.orange,
),
ListTile(
title: const Text(
@ -409,15 +410,17 @@ class _ProfileScreenState extends State<ProfileScreen>
showAboutDialog(
context: context,
applicationName: 'Hacki',
applicationVersion: 'v0.2.21',
applicationVersion: 'v0.2.24',
applicationIcon: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(12),
Radius.circular(
Dimens.pt12,
),
),
child: Image.asset(
Constants.hackiIconPath,
height: 50,
width: 50,
height: Dimens.pt50,
width: Dimens.pt50,
),
),
children: <Widget>[
@ -431,7 +434,7 @@ class _ProfileScreenState extends State<ProfileScreen>
FontAwesomeIcons.addressCard,
),
SizedBox(
width: 12,
width: Dimens.pt12,
),
Text('Developer'),
],
@ -447,7 +450,7 @@ class _ProfileScreenState extends State<ProfileScreen>
FontAwesomeIcons.github,
),
SizedBox(
width: 12,
width: Dimens.pt12,
),
Text('Source code'),
],
@ -465,7 +468,7 @@ class _ProfileScreenState extends State<ProfileScreen>
Icons.thumb_up,
),
SizedBox(
width: 12,
width: Dimens.pt12,
),
Text('Like the app?'),
],
@ -481,7 +484,7 @@ class _ProfileScreenState extends State<ProfileScreen>
FeatherIcons.coffee,
),
SizedBox(
width: 12,
width: Dimens.pt12,
),
Text('Buy me a coffee'),
],
@ -492,7 +495,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
height: 48,
height: Dimens.pt48,
),
],
),
@ -507,7 +510,7 @@ class _ProfileScreenState extends State<ProfileScreen>
child: Row(
children: <Widget>[
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Submit',
@ -526,7 +529,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Inbox : '
@ -542,7 +545,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Favorite',
@ -556,7 +559,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Submitted',
@ -570,7 +573,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Search',
@ -584,7 +587,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
CustomChip(
label: 'Settings',
@ -598,7 +601,7 @@ class _ProfileScreenState extends State<ProfileScreen>
},
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
],
),
@ -666,7 +669,7 @@ class _ProfileScreenState extends State<ProfileScreen>
child: const Text(
'Cancel',
style: TextStyle(
color: Colors.orange,
color: Palette.orange,
),
),
),
@ -743,64 +746,64 @@ class _ProfileScreenState extends State<ProfileScreen>
children: <Widget>[
if (state.status == AuthStatus.loading)
const SizedBox(
height: 36,
width: 36,
height: Dimens.pt36,
width: Dimens.pt36,
child: Center(
child: CircularProgressIndicator(
color: Colors.orange,
color: Palette.orange,
),
),
)
else if (!state.isLoggedIn) ...<Widget>[
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 18,
horizontal: Dimens.pt18,
),
child: TextField(
controller: usernameController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Username',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
),
),
const SizedBox(
height: 16,
height: Dimens.pt16,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 18,
horizontal: Dimens.pt18,
),
child: TextField(
controller: passwordController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
obscureText: true,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Password',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
),
),
const SizedBox(
height: 16,
height: Dimens.pt16,
),
if (state.status == AuthStatus.failure)
const Padding(
padding: EdgeInsets.only(
left: 18,
left: Dimens.pt18,
),
child: Text(
'Something went wrong...',
style: TextStyle(
color: Colors.grey,
fontSize: 12,
color: Palette.grey,
fontSize: TextDimens.pt12,
),
),
),
@ -814,8 +817,8 @@ class _ProfileScreenState extends State<ProfileScreen>
? Icons.check_box
: Icons.check_box_outline_blank,
color: state.agreedToEULA
? Colors.deepOrange
: Colors.grey,
? Palette.deepOrange
: Palette.grey,
),
onPressed: () => context
.read<AuthBloc>()
@ -840,7 +843,7 @@ class _ProfileScreenState extends State<ProfileScreen>
child: const Text(
'End User Agreement',
style: TextStyle(
color: Colors.deepOrange,
color: Palette.deepOrange,
decoration: TextDecoration.underline,
fontWeight: FontWeight.w600,
),
@ -855,7 +858,7 @@ class _ProfileScreenState extends State<ProfileScreen>
),
Padding(
padding: const EdgeInsets.only(
right: 12,
right: Dimens.pt12,
),
child: ButtonBar(
children: <Widget>[
@ -886,15 +889,15 @@ class _ProfileScreenState extends State<ProfileScreen>
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
state.agreedToEULA
? Colors.deepOrange
: Colors.grey,
? Palette.deepOrange
: Palette.grey,
),
),
child: const Text(
'Log in',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
color: Palette.white,
),
),
),
@ -921,7 +924,7 @@ class _ProfileScreenState extends State<ProfileScreen>
content: Text(
'Log out as ${authBloc.state.username}?',
style: const TextStyle(
fontSize: 16,
fontSize: TextDimens.pt16,
),
),
actions: <Widget>[

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:hacki/styles/styles.dart';
class CenteredMessageView extends StatelessWidget {
const CenteredMessageView({
@ -12,14 +13,14 @@ class CenteredMessageView extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
top: 120,
left: 40,
right: 40,
top: Dimens.pt120,
left: Dimens.pt40,
right: Dimens.pt40,
),
child: Text(
content,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.grey),
style: const TextStyle(color: Palette.grey),
),
);
}

View File

@ -3,6 +3,7 @@ import 'package:flutter_fadein/flutter_fadein.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/link_util.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -29,8 +30,8 @@ class InboxView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Color textColor = Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black;
? Palette.white
: Palette.black;
return Column(
children: <Widget>[
if (unreadCommentsIds.isNotEmpty)
@ -42,12 +43,14 @@ class InboxView extends StatelessWidget {
child: SmartRefresher(
enablePullUp: true,
header: const WaterDropMaterialHeader(
backgroundColor: Colors.orange,
backgroundColor: Palette.orange,
),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
const double height = 55;
late final Widget body;
if (mode == LoadStatus.loading) {
body = const CustomCircularProgressIndicator();
} else if (mode == LoadStatus.failed) {
@ -58,7 +61,7 @@ class InboxView extends StatelessWidget {
body = const SizedBox.shrink();
}
return SizedBox(
height: 55,
height: height,
child: Center(child: body),
);
},
@ -72,7 +75,9 @@ class InboxView extends StatelessWidget {
return <Widget>[
FadeIn(
child: Padding(
padding: const EdgeInsets.only(left: 6),
padding: const EdgeInsets.only(
left: Dimens.pt6,
),
child: InkWell(
onTap: () => onCommentTapped(e),
child: Padding(
@ -87,8 +92,8 @@ class InboxView extends StatelessWidget {
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 6,
vertical: Dimens.pt8,
horizontal: Dimens.pt6,
),
child: Linkify(
text: '${e.by} : ${e.text}',
@ -96,13 +101,13 @@ class InboxView extends StatelessWidget {
color:
unreadCommentsIds.contains(e.id)
? textColor
: Colors.grey,
: Palette.grey,
),
linkStyle: TextStyle(
color:
unreadCommentsIds.contains(e.id)
? Colors.orange
: Colors.orange
? Palette.orange
: Palette.orange
.withOpacity(0.6),
),
maxLines: 4,
@ -116,18 +121,18 @@ class InboxView extends StatelessWidget {
Text(
e.postedDate,
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
],
),
],
),
const Divider(
height: 0,
height: Dimens.zero,
),
],
),
@ -136,12 +141,12 @@ class InboxView extends StatelessWidget {
),
),
const Divider(
height: 0,
height: Dimens.zero,
),
];
}).expand((List<Widget> element) => element),
const SizedBox(
height: 40,
height: Dimens.pt40,
),
],
),

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:wakelock/wakelock.dart';
class OfflineListTile extends StatelessWidget {
@ -32,8 +33,8 @@ class OfflineListTile extends StatelessWidget {
final Widget trailingWidget = () {
if (downloading) {
return const SizedBox(
height: 24,
width: 24,
height: Dimens.pt24,
width: Dimens.pt24,
child: CustomCircularProgressIndicator(),
);
} else if (downloaded) {

View File

@ -7,6 +7,7 @@ import 'package:hacki/models/models.dart';
import 'package:hacki/screens/screens.dart';
import 'package:hacki/screens/search/widgets/widgets.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -38,14 +39,16 @@ class _SearchScreenState extends State<SearchScreen> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.symmetric(
horizontal: Dimens.pt12,
),
child: TextField(
cursorColor: Colors.orange,
cursorColor: Palette.orange,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Search Hacker News',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
onChanged: (String val) {
@ -58,7 +61,7 @@ class _SearchScreenState extends State<SearchScreen> {
),
),
const SizedBox(
height: 6,
height: Dimens.pt6,
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
@ -83,7 +86,7 @@ class _SearchScreenState extends State<SearchScreen> {
.removeFilter<DateTimeRangeFilter>,
),
const SizedBox(
width: 8,
width: Dimens.pt8,
),
CustomChip(
onSelected: (_) =>
@ -92,7 +95,7 @@ class _SearchScreenState extends State<SearchScreen> {
label: '''newest first''',
),
const SizedBox(
width: 8,
width: Dimens.pt8,
),
for (final CustomDateTimeRange range
in CustomDateTimeRange.values) ...<Widget>[
@ -107,7 +110,7 @@ class _SearchScreenState extends State<SearchScreen> {
),
),
const SizedBox(
width: 8,
width: Dimens.pt8,
),
],
],
@ -116,7 +119,7 @@ class _SearchScreenState extends State<SearchScreen> {
if (state.status == SearchStatus.loading &&
state.results.isEmpty) ...<Widget>[
const SizedBox(
height: 100,
height: Dimens.pt100,
),
const CustomCircularProgressIndicator(),
],
@ -125,12 +128,14 @@ class _SearchScreenState extends State<SearchScreen> {
enablePullDown: false,
enablePullUp: true,
header: const WaterDropMaterialHeader(
backgroundColor: Colors.orange,
backgroundColor: Palette.orange,
),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
const double height = 55;
late final Widget body;
if (mode == LoadStatus.loading) {
body = const CustomCircularProgressIndicator();
} else if (mode == LoadStatus.failed) {
@ -140,8 +145,9 @@ class _SearchScreenState extends State<SearchScreen> {
} else {
body = const SizedBox.shrink();
}
return SizedBox(
height: 55,
height: height,
child: Center(child: body),
);
},
@ -169,14 +175,14 @@ class _SearchScreenState extends State<SearchScreen> {
),
if (!prefState.showComplexStoryTile)
const Divider(
height: 0,
height: Dimens.zero,
),
],
)
.expand((List<Widget> e) => e)
.toList(),
const SizedBox(
height: 40,
height: Dimens.pt40,
),
],
),

View File

@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/extensions/extensions.dart';
import 'package:hacki/styles/styles.dart';
class SubmitScreen extends StatefulWidget {
const SubmitScreen({super.key});
@ -58,7 +59,7 @@ class _SubmitScreenState extends State<SubmitScreen> {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).canvasColor,
elevation: 0,
elevation: Dimens.zero,
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
@ -78,7 +79,7 @@ class _SubmitScreenState extends State<SubmitScreen> {
child: const Text(
'Yes',
style: TextStyle(
color: Colors.red,
color: Palette.red,
),
),
),
@ -99,14 +100,14 @@ class _SubmitScreenState extends State<SubmitScreen> {
if (state.status == SubmitStatus.submitting)
const Padding(
padding: EdgeInsets.symmetric(
vertical: 18,
horizontal: 16,
vertical: Dimens.pt18,
horizontal: Dimens.pt16,
),
child: SizedBox(
height: 20,
width: 20,
height: Dimens.pt20,
width: Dimens.pt20,
child: CircularProgressIndicator(
color: Colors.orange,
color: Palette.orange,
strokeWidth: 2,
),
),
@ -115,7 +116,7 @@ class _SubmitScreenState extends State<SubmitScreen> {
IconButton(
icon: const Icon(
Icons.send,
color: Colors.orange,
color: Palette.orange,
),
onPressed: context.read<SubmitCubit>().onSubmitTapped,
)
@ -123,7 +124,7 @@ class _SubmitScreenState extends State<SubmitScreen> {
IconButton(
icon: const Icon(
Icons.send,
color: Colors.grey,
color: Palette.grey,
),
onPressed: () {},
),
@ -132,50 +133,58 @@ class _SubmitScreenState extends State<SubmitScreen> {
body: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.symmetric(
horizontal: Dimens.pt12,
),
child: TextField(
controller: titleEditingController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
autocorrect: false,
maxLength: 80,
decoration: const InputDecoration(
hintText: 'Title',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
onChanged: context.read<SubmitCubit>().onTitleChanged,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.symmetric(
horizontal: Dimens.pt12,
),
child: TextField(
enabled: textEditingController.text.isEmpty,
controller: urlEditingController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
autocorrect: false,
decoration: const InputDecoration(
hintText: 'Url',
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
borderSide: BorderSide(color: Palette.orange),
),
),
onChanged: context.read<SubmitCubit>().onUrlChanged,
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
padding: EdgeInsets.symmetric(
vertical: Dimens.pt12,
),
child: Center(
child: Text('or'),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.symmetric(
horizontal: Dimens.pt12,
),
child: TextField(
enabled: urlEditingController.text.isEmpty,
controller: textEditingController,
cursorColor: Colors.orange,
cursorColor: Palette.orange,
maxLines: 200,
decoration: const InputDecoration(
hintText: 'Text',

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hacki/config/locator.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/styles/styles.dart';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewScreen extends StatefulWidget {
@ -24,7 +25,7 @@ class _WebViewScreenState extends State<WebViewScreen> {
title: Text(
humanize(widget.url),
style: const TextStyle(
fontSize: 12,
fontSize: TextDimens.pt12,
),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,

View File

@ -7,6 +7,8 @@ import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/extensions/extensions.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/services/services.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
class CommentTile extends StatelessWidget {
@ -42,6 +44,7 @@ class CommentTile extends StatelessWidget {
lazy: false,
create: (_) => CollapseCubit(
commentId: comment.id,
cacheService: context.read<CacheService>(),
)..init(),
child: BlocBuilder<CollapseCubit, CollapseState>(
builder: (BuildContext context, CollapseState state) {
@ -67,8 +70,8 @@ class CommentTile extends StatelessWidget {
SlidableAction(
onPressed: (_) =>
onReplyTapped?.call(comment),
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.message,
),
if (context
@ -80,15 +83,15 @@ class CommentTile extends StatelessWidget {
SlidableAction(
onPressed: (_) =>
onEditTapped?.call(comment),
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.edit,
),
SlidableAction(
onPressed: (_) =>
onMoreTapped?.call(comment),
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.more_horiz,
),
],
@ -101,8 +104,8 @@ class CommentTile extends StatelessWidget {
SlidableAction(
onPressed: (_) =>
onRightMoreTapped?.call(comment),
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: Icons.av_timer,
),
],
@ -111,7 +114,7 @@ class CommentTile extends StatelessWidget {
child: InkWell(
onTap: () {
if (actionable) {
HapticFeedback.lightImpact();
HapticFeedback.selectionClick();
context.read<CollapseCubit>().collapse();
}
},
@ -120,9 +123,9 @@ class CommentTile extends StatelessWidget {
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 6,
right: 6,
top: 6,
left: Dimens.pt6,
right: Dimens.pt6,
top: Dimens.pt6,
),
child: Row(
children: <Widget>[
@ -145,7 +148,7 @@ class CommentTile extends StatelessWidget {
Text(
comment.postedDate,
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
],
@ -154,13 +157,14 @@ class CommentTile extends StatelessWidget {
if (actionable && state.collapsed)
Center(
child: Padding(
padding:
const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.only(
bottom: Dimens.pt12,
),
child: Text(
'collapsed '
'(${state.collapsedCount + 1})',
style: const TextStyle(
color: Colors.orangeAccent,
color: Palette.orangeAccent,
),
),
),
@ -168,11 +172,13 @@ class CommentTile extends StatelessWidget {
else if (comment.deleted)
const Center(
child: Padding(
padding: EdgeInsets.only(bottom: 12),
padding: EdgeInsets.only(
bottom: Dimens.pt12,
),
child: Text(
'deleted',
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
),
@ -180,11 +186,13 @@ class CommentTile extends StatelessWidget {
else if (comment.dead)
const Center(
child: Padding(
padding: EdgeInsets.only(bottom: 12),
padding: EdgeInsets.only(
bottom: Dimens.pt12,
),
child: Text(
'dead',
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
),
@ -193,11 +201,13 @@ class CommentTile extends StatelessWidget {
.contains(comment.by))
const Center(
child: Padding(
padding: EdgeInsets.only(bottom: 12),
padding: EdgeInsets.only(
bottom: Dimens.pt12,
),
child: Text(
'blocked',
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
),
@ -205,10 +215,10 @@ class CommentTile extends StatelessWidget {
else
Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
top: 6,
bottom: 12,
left: Dimens.pt8,
right: Dimens.pt8,
top: Dimens.pt6,
bottom: Dimens.pt12,
),
child: comment is BuildableComment
? SelectableText.rich(
@ -219,15 +229,15 @@ class CommentTile extends StatelessWidget {
style: TextStyle(
fontSize: MediaQuery.of(context)
.textScaleFactor *
15,
TextDimens.pt15,
),
linkStyle: TextStyle(
fontSize: MediaQuery.of(context)
.textScaleFactor *
15,
TextDimens.pt15,
decoration:
TextDecoration.underline,
color: Colors.orange,
color: Palette.orange,
),
onOpen: (LinkableElement link) {
if (link.url.contains(
@ -247,13 +257,13 @@ class CommentTile extends StatelessWidget {
style: TextStyle(
fontSize: MediaQuery.of(context)
.textScaleFactor *
15,
TextDimens.pt15,
),
linkStyle: TextStyle(
fontSize: MediaQuery.of(context)
.textScaleFactor *
15,
color: Colors.orange,
TextDimens.pt15,
color: Palette.orange,
),
onOpen: (LinkableElement link) {
if (link.url.contains(
@ -268,7 +278,7 @@ class CommentTile extends StatelessWidget {
),
),
const Divider(
height: 0,
height: Dimens.zero,
),
],
),
@ -285,14 +295,14 @@ class CommentTile extends StatelessWidget {
final Color commentColor = prefState.showEyeCandy
? color.withOpacity(commentBackgroundColorOpacity)
: Colors.transparent;
: Palette.transparent;
final bool isMyComment = myUsername == comment.by;
Widget? wrapper = child;
if (isMyComment && level == 0) {
return Container(
color: Colors.orange.withOpacity(0.2),
color: Palette.orange.withOpacity(0.2),
child: wrapper,
);
}
@ -301,7 +311,9 @@ class CommentTile extends StatelessWidget {
final Color wrapperBorderColor = _getColor(i);
final bool shouldHighlight = isMyComment && i == level;
wrapper = Container(
margin: const EdgeInsets.only(left: 12),
margin: const EdgeInsets.only(
left: Dimens.pt12,
),
decoration: BoxDecoration(
border: i != 0
? Border(
@ -311,7 +323,7 @@ class CommentTile extends StatelessWidget {
)
: null,
color: shouldHighlight
? Colors.orange.withOpacity(0.2)
? Palette.orange.withOpacity(0.2)
: commentColor,
),
child: wrapper,

View File

@ -7,6 +7,7 @@ import 'package:hacki/extensions/extensions.dart';
import 'package:hacki/models/story.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/screens/screens.dart';
import 'package:hacki/styles/styles.dart';
class CountdownReminder extends StatefulWidget {
const CountdownReminder({super.key});
@ -95,9 +96,13 @@ class _CountDownReminderState extends State<CountdownReminder>
animation: animationController,
child: FadeIn(
child: Material(
color: Colors.deepOrange,
color: Palette.deepOrange,
clipBehavior: Clip.hardEdge,
borderRadius: const BorderRadius.all(Radius.circular(4)),
borderRadius: const BorderRadius.all(
Radius.circular(
Dimens.pt4,
),
),
child: InkWell(
onTap: () {
if (state.storyId != null) {
@ -122,24 +127,24 @@ class _CountDownReminderState extends State<CountdownReminder>
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 12,
top: 10,
right: 10,
left: Dimens.pt12,
top: Dimens.pt10,
right: Dimens.pt10,
),
child: Row(
children: const <Widget>[
Text(
'Pick up where you left off',
style: TextStyle(
color: Colors.white,
fontSize: 12,
color: Palette.white,
fontSize: TextDimens.pt12,
),
),
Spacer(),
Icon(
Icons.arrow_forward_ios,
size: 12,
color: Colors.white,
size: TextDimens.pt12,
color: Palette.white,
),
],
),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:hacki/styles/styles.dart';
class CustomChip extends StatelessWidget {
CustomChip({
@ -15,16 +16,16 @@ class CustomChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FilterChip(
shadowColor: Colors.transparent,
selectedShadowColor: Colors.transparent,
backgroundColor: Colors.transparent,
shadowColor: Palette.transparent,
selectedShadowColor: Palette.transparent,
backgroundColor: Palette.transparent,
shape: const StadiumBorder(
side: BorderSide(color: Colors.orange),
side: BorderSide(color: Palette.orange),
),
label: Text(label),
selected: selected,
onSelected: onSelected,
selectedColor: Colors.orange,
selectedColor: Palette.orange,
);
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:hacki/styles/styles.dart';
/// Circular progress indicator with color.
/// Changing `colorScheme`'s `primary` color doesn't work because it changes
@ -17,7 +18,7 @@ class CustomCircularProgressIndicator extends StatelessWidget {
Widget build(BuildContext context) {
return CircularProgressIndicator(
strokeWidth: strokeWidth,
valueColor: const AlwaysStoppedAnimation<Color>(Colors.orange),
valueColor: const AlwaysStoppedAnimation<Color>(Palette.orange),
);
}
}

View File

@ -7,6 +7,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -80,8 +81,8 @@ class ItemsListView<T extends Item> extends StatelessWidget {
HapticFeedback.lightImpact();
onPinned?.call(e);
},
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
backgroundColor: Palette.orange,
foregroundColor: Palette.white,
icon: showWebPreview
? Icons.push_pin_outlined
: null,
@ -97,13 +98,15 @@ class ItemsListView<T extends Item> extends StatelessWidget {
showWebPreview: showWebPreview,
showMetadata: showMetadata,
hasRead: markReadStories && hasRead,
simpleTileFontSize: useConsistentFontSize ? 14 : 16,
simpleTileFontSize: useConsistentFontSize
? TextDimens.pt14
: TextDimens.pt16,
),
),
),
if (!showWebPreview)
const Divider(
height: 0,
height: Dimens.zero,
),
];
} else if (e is Comment) {
@ -111,22 +114,22 @@ class ItemsListView<T extends Item> extends StatelessWidget {
return <Widget>[
if (showWebPreview)
const Divider(
height: 0,
height: Dimens.zero,
),
_CommentTile(
comment: e,
onTap: () => onTap(e),
fontSize: showWebPreview ? 14 : 16,
fontSize: showWebPreview ? TextDimens.pt14 : TextDimens.pt16,
),
const Divider(
height: 0,
height: Dimens.zero,
),
];
}
return <Widget>[
FadeIn(
child: Padding(
padding: const EdgeInsets.only(left: 6),
padding: const EdgeInsets.only(left: Dimens.pt6),
child: InkWell(
onTap: () => onTap(e),
child: Padding(
@ -137,10 +140,12 @@ class ItemsListView<T extends Item> extends StatelessWidget {
if (e.deleted)
const Center(
child: Padding(
padding: EdgeInsets.only(top: 6),
padding: EdgeInsets.only(
top: Dimens.pt6,
),
child: Text(
'deleted',
style: TextStyle(color: Colors.grey),
style: TextStyle(color: Palette.grey),
),
),
),
@ -151,15 +156,15 @@ class ItemsListView<T extends Item> extends StatelessWidget {
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 6,
vertical: Dimens.pt8,
horizontal: Dimens.pt6,
),
child: Linkify(
text:
'''${showCommentBy ? '${e.by}: ' : ''}${e.text}''',
maxLines: 4,
linkStyle: const TextStyle(
color: Colors.orange,
color: Palette.orange,
),
onOpen: (LinkableElement link) =>
LinkUtil.launch(link.url),
@ -171,18 +176,18 @@ class ItemsListView<T extends Item> extends StatelessWidget {
Text(
e.postedDate,
style: const TextStyle(
color: Colors.grey,
color: Palette.grey,
),
),
const SizedBox(
width: 12,
width: Dimens.pt12,
),
],
),
],
),
const Divider(
height: 0,
height: Dimens.zero,
),
],
),
@ -191,7 +196,7 @@ class ItemsListView<T extends Item> extends StatelessWidget {
),
),
const Divider(
height: 0,
height: Dimens.zero,
),
];
}
@ -199,7 +204,7 @@ class ItemsListView<T extends Item> extends StatelessWidget {
return <Widget>[Container()];
}).expand((List<Widget> element) => element),
const SizedBox(
height: 40,
height: Dimens.pt40,
),
],
);
@ -208,12 +213,14 @@ class ItemsListView<T extends Item> extends StatelessWidget {
enablePullUp: true,
enablePullDown: enablePullDown,
header: const WaterDropMaterialHeader(
backgroundColor: Colors.orange,
backgroundColor: Palette.orange,
),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
const double height = 55;
late final Widget body;
if (mode == LoadStatus.loading) {
body = const CustomCircularProgressIndicator();
} else if (mode == LoadStatus.failed) {
@ -224,7 +231,7 @@ class ItemsListView<T extends Item> extends StatelessWidget {
body = const SizedBox.shrink();
}
return SizedBox(
height: 55,
height: height,
child: Center(child: body),
);
},
@ -254,12 +261,14 @@ class _CommentTile extends StatelessWidget {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.only(left: 12),
padding: const EdgeInsets.only(
left: Dimens.pt12,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(
height: 8,
height: Dimens.pt8,
),
Row(
children: <Widget>[
@ -281,7 +290,7 @@ class _CommentTile extends StatelessWidget {
child: Text(
comment.metadata,
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
fontSize: fontSize - 2,
),
maxLines: 1,
@ -290,7 +299,7 @@ class _CommentTile extends StatelessWidget {
],
),
const SizedBox(
height: 8,
height: Dimens.pt8,
),
],
),

View File

@ -5,6 +5,7 @@ import 'package:hacki/config/constants.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/widgets/link_preview/link_view.dart';
import 'package:hacki/screens/widgets/link_preview/web_analyzer.dart';
import 'package:hacki/styles/styles.dart';
import 'package:url_launcher/url_launcher.dart';
class LinkPreview extends StatefulWidget {
@ -97,7 +98,7 @@ class LinkPreview extends StatefulWidget {
final bool removeElevation;
/// Box shadow for the card. Defaults to
/// `[BoxShadow(blurRadius: 3, color: Colors.grey)]`
/// `[BoxShadow(blurRadius: 3, color: Palette.grey)]`
final List<BoxShadow>? boxShadow;
final bool showMetadata;
@ -163,11 +164,15 @@ class _LinkPreviewState extends State<LinkPreview> {
return Container(
decoration: BoxDecoration(
color: widget.backgroundColor,
borderRadius: BorderRadius.circular(widget.borderRadius ?? 12),
borderRadius: BorderRadius.circular(
widget.borderRadius ?? Dimens.pt12,
),
boxShadow: widget.removeElevation
? <BoxShadow>[]
: widget.boxShadow ??
<BoxShadow>[const BoxShadow(blurRadius: 3, color: Colors.grey)],
<BoxShadow>[
const BoxShadow(blurRadius: 3, color: Palette.grey),
],
),
height: _height,
child: LinkView(
@ -194,19 +199,29 @@ class _LinkPreviewState extends State<LinkPreview> {
@override
Widget build(BuildContext context) {
const double screenWidthLowerBound = 428,
screenWidthUpperBound = 850,
picHeightLowerBound = 118,
picHeightUpperBound = 140,
smallPicHeight = 100,
picHeightFactor = 0.14;
final double screenWidth = MediaQuery.of(context).size.width;
final bool showSmallerPreviewPic = screenWidth > 428.0 && screenWidth < 850;
final double _height = showSmallerPreviewPic
? 100.0
: (MediaQuery.of(context).size.height * 0.14).clamp(118.0, 140.0);
final bool showSmallerPreviewPic = screenWidth > screenWidthLowerBound &&
screenWidth < screenWidthUpperBound;
final double height = showSmallerPreviewPic
? smallPicHeight
: (MediaQuery.of(context).size.height * picHeightFactor)
.clamp(picHeightLowerBound, picHeightUpperBound);
final Widget loadingWidget = widget.placeholderWidget ??
Container(
height: _height,
height: height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(widget.borderRadius ?? 12),
color: Colors.grey[200],
borderRadius: BorderRadius.circular(
widget.borderRadius ?? Dimens.pt12,
),
color: Palette.grey[200],
),
alignment: Alignment.center,
child: const Text('Fetching data...'),
@ -217,13 +232,13 @@ class _LinkPreviewState extends State<LinkPreview> {
final WebInfo? info = _info as WebInfo?;
loadedWidget = _info == null
? _buildLinkContainer(
_height,
height,
title: _errorTitle,
desc: _errorBody,
imageUri: null,
)
: _buildLinkContainer(
_height,
height,
title: _errorTitle,
desc: WebAnalyzer.isNotEmpty(info!.description)
? info.description

View File

@ -1,6 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/styles/styles.dart';
class LinkView extends StatelessWidget {
const LinkView({
@ -74,13 +75,13 @@ class LinkView extends StatelessWidget {
final TextStyle _titleFontSize = titleTextStyle ??
TextStyle(
fontSize: computeTitleFontSize(layoutWidth),
color: Colors.black,
color: Palette.black,
fontWeight: FontWeight.bold,
);
final TextStyle _bodyFontSize = bodyTextStyle ??
TextStyle(
fontSize: computeTitleFontSize(layoutWidth) - 1,
color: Colors.grey,
color: Palette.grey,
fontWeight: FontWeight.w400,
);

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/screens/widgets/link_preview/web_analyzer.dart';
import 'package:hacki/styles/styles.dart';
class OfflineBanner extends StatelessWidget {
const OfflineBanner({
@ -25,7 +26,7 @@ class OfflineBanner extends StatelessWidget {
'${showExitButton ? 'Exit to fetch latest stories.' : ''}',
textAlign: showExitButton ? TextAlign.left : TextAlign.center,
),
backgroundColor: Colors.orangeAccent.withOpacity(0.3),
backgroundColor: Palette.orangeAccent.withOpacity(0.3),
actions: <Widget>[
if (showExitButton)
TextButton(
@ -46,7 +47,7 @@ class OfflineBanner extends StatelessWidget {
child: const Text(
'Yes',
style: TextStyle(
color: Colors.red,
color: Palette.red,
),
),
),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';
class OnboardingView extends StatefulWidget {
@ -16,34 +17,35 @@ class _OnboardingViewState extends State<OnboardingView> {
final Throttle throttle = Throttle(delay: _throttleDelay);
static const Duration _throttleDelay = Duration(milliseconds: 100);
static const double _screenshotHeight = 550;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).brightness == Brightness.light
? Colors.orange
? Palette.orange
: Theme.of(context).canvasColor,
elevation: 0,
elevation: Dimens.zero,
leading: IconButton(
icon: const Icon(
Icons.close,
color: Colors.white,
color: Palette.white,
),
onPressed: () => Navigator.pop(context),
),
),
backgroundColor: Theme.of(context).brightness == Brightness.light
? Colors.orange
? Palette.orange
: null,
body: Stack(
children: <Widget>[
Positioned(
top: 40,
left: 0,
right: 0,
top: Dimens.pt40,
left: Dimens.zero,
right: Dimens.zero,
child: SizedBox(
height: 550,
height: _screenshotHeight,
child: PageView(
controller: pageController,
scrollDirection: Axis.vertical,
@ -65,9 +67,9 @@ class _OnboardingViewState extends State<OnboardingView> {
),
),
Positioned(
bottom: 40,
left: 0,
right: 0,
bottom: Dimens.pt40,
left: Dimens.zero,
right: Dimens.zero,
child: ElevatedButton(
onPressed: () {
HapticFeedback.lightImpact();
@ -84,13 +86,15 @@ class _OnboardingViewState extends State<OnboardingView> {
},
style: ElevatedButton.styleFrom(
shape: const CircleBorder(),
primary: Colors.orange,
padding: const EdgeInsets.all(18),
primary: Palette.orange,
padding: const EdgeInsets.all(
Dimens.pt18,
),
),
child: const Icon(
Icons.arrow_drop_down_circle_outlined,
size: 24,
color: Colors.white,
size: TextDimens.pt24,
color: Palette.white,
),
),
),
@ -110,25 +114,27 @@ class _PageViewChild extends StatelessWidget {
final String path;
final String description;
static const double _height = 400;
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
SizedBox(
height: 400,
height: _height,
child: Image.asset(path),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 24,
horizontal: Dimens.pt24,
vertical: Dimens.pt24,
),
child: Text(
description,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
color: Colors.white,
fontSize: TextDimens.pt16,
color: Palette.white,
),
),
),

View File

@ -5,6 +5,7 @@ import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:shimmer/shimmer.dart';
class StoryTile extends StatelessWidget {
@ -28,18 +29,25 @@ class StoryTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (showWebPreview) {
const double screenWidthLowerBound = 428,
screenWidthUpperBound = 850,
picHeightLowerBound = 118,
picHeightUpperBound = 140,
smallPicHeight = 100,
picHeightFactor = 0.14;
final double screenWidth = MediaQuery.of(context).size.width;
final bool showSmallerPreviewPic =
screenWidth > 428.0 && screenWidth < 850;
final bool showSmallerPreviewPic = screenWidth > screenWidthLowerBound &&
screenWidth < screenWidthUpperBound;
final double height = showSmallerPreviewPic
? 100.0
: (MediaQuery.of(context).size.height * 0.14).clamp(118.0, 140.0);
? smallPicHeight
: (MediaQuery.of(context).size.height * picHeightFactor)
.clamp(picHeightLowerBound, picHeightUpperBound);
return TapDownWrapper(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
horizontal: Dimens.pt12,
),
child: AbsorbPointer(
child: LinkPreview(
@ -50,66 +58,77 @@ class StoryTile extends StatelessWidget {
child: SizedBox(
height: height,
child: Shimmer.fromColors(
baseColor: Colors.orange,
highlightColor: Colors.orangeAccent,
baseColor: Palette.orange,
highlightColor: Palette.orangeAccent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
right: 5,
bottom: 5,
top: 5,
right: Dimens.pt5,
bottom: Dimens.pt5,
top: Dimens.pt5,
),
child: Container(
height: height,
width: height,
color: Colors.white,
color: Palette.white,
),
),
Expanded(
flex: 4,
child: Padding(
padding: const EdgeInsets.only(left: 4, top: 6),
padding: const EdgeInsets.only(
left: Dimens.pt4,
top: Dimens.pt6,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: double.infinity,
height: 14,
color: Colors.white,
height: Dimens.pt14,
color: Palette.white,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 4),
padding: EdgeInsets.symmetric(
vertical: Dimens.pt4,
),
),
Container(
width: double.infinity,
height: 10,
color: Colors.white,
height: Dimens.pt10,
color: Palette.white,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 3),
padding: EdgeInsets.symmetric(
vertical: Dimens.pt3,
),
),
Container(
width: double.infinity,
height: 10,
color: Colors.white,
height: Dimens.pt10,
color: Palette.white,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 3),
padding: EdgeInsets.symmetric(
vertical: Dimens.pt3,
),
),
Container(
width: double.infinity,
height: 10,
color: Colors.white,
height: Dimens.pt10,
color: Palette.white,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 3),
padding: EdgeInsets.symmetric(
vertical: Dimens.pt3,
),
),
Container(
width: 40,
height: 10,
color: Colors.white,
width: Dimens.pt40,
height: Dimens.pt10,
color: Palette.white,
),
],
),
@ -121,14 +140,14 @@ class StoryTile extends StatelessWidget {
),
),
errorImage: Constants.hackerNewsLogoLink,
backgroundColor: Colors.transparent,
borderRadius: 0,
backgroundColor: Palette.transparent,
borderRadius: Dimens.zero,
removeElevation: true,
bodyMaxLines: height == 100 ? 3 : 4,
bodyMaxLines: height == smallPicHeight ? 3 : 4,
errorTitle: story.title,
titleStyle: TextStyle(
color: hasRead
? Colors.grey[500]
? Palette.grey[500]
: Theme.of(context).textTheme.subtitle1!.color,
fontWeight: FontWeight.bold,
),
@ -141,12 +160,12 @@ class StoryTile extends StatelessWidget {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.only(left: 12),
padding: const EdgeInsets.only(left: Dimens.pt12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(
height: 8,
height: Dimens.pt8,
),
Row(
children: <Widget>[
@ -154,7 +173,7 @@ class StoryTile extends StatelessWidget {
child: Text(
story.title,
style: TextStyle(
color: hasRead ? Colors.grey[500] : null,
color: hasRead ? Palette.grey[500] : null,
fontSize: simpleTileFontSize,
),
),
@ -168,7 +187,7 @@ class StoryTile extends StatelessWidget {
child: Text(
story.metadata,
style: TextStyle(
color: Colors.grey,
color: Palette.grey,
fontSize: simpleTileFontSize - 2,
),
maxLines: 1,
@ -177,7 +196,7 @@ class StoryTile extends StatelessWidget {
],
),
const SizedBox(
height: 8,
height: Dimens.pt8,
),
],
),

View File

@ -18,7 +18,6 @@ class _TapDownWrapperState extends State<TapDownWrapper>
with SingleTickerProviderStateMixin {
late AnimationController controller;
Tween<double> tween = Tween<double>(begin: 1, end: 0.95);
double scale = 1;
@override
void initState() {

View File

@ -2,11 +2,11 @@ import 'package:hacki/models/models.dart' show Comment;
import 'package:rxdart/rxdart.dart';
class CacheService {
static final Map<int, Comment> _comments = <int, Comment>{};
static final Map<int, String> _drafts = <int, String>{};
static final Map<int, Set<int>> _kids = <int, Set<int>>{};
static final Set<int> _collapsed = <int>{};
static final Map<int, Set<int>> _hidden = <int, Set<int>>{};
final Map<int, Comment> _comments = <int, Comment>{};
final Map<int, String> _drafts = <int, String>{};
final Map<int, Set<int>> _kids = <int, Set<int>>{};
final Set<int> _collapsed = <int>{};
final Map<int, Set<int>> _hidden = <int, Set<int>>{};
final PublishSubject<Map<int, Set<int>>> _hiddenCommentsSubject =
PublishSubject<Map<int, Set<int>>>();

38
lib/styles/dimens.dart Normal file
View File

@ -0,0 +1,38 @@
abstract class Dimens {
static const double zero = 0;
static const double pt2 = 2;
static const double pt3 = 3;
static const double pt4 = 4;
static const double pt5 = 5;
static const double pt6 = 6;
static const double pt8 = 8;
static const double pt10 = 10;
static const double pt12 = 12;
static const double pt14 = 14;
static const double pt16 = 16;
static const double pt18 = 18;
static const double pt20 = 20;
static const double pt24 = 24;
static const double pt36 = 36;
static const double pt40 = 40;
static const double pt48 = 48;
static const double pt50 = 50;
static const double pt64 = 64;
static const double pt100 = 100;
static const double pt120 = 120;
}
abstract class TextDimens {
static const double pt6 = 6;
static const double pt8 = 8;
static const double pt10 = 10;
static const double pt12 = 12;
static const double pt14 = 14;
static const double pt15 = 15;
static const double pt16 = 16;
static const double pt18 = 18;
static const double pt20 = 20;
static const double pt24 = 24;
static const double pt26 = 26;
static const double pt36 = 36;
}

21
lib/styles/palette.dart Normal file
View File

@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
abstract class Palette {
static const Color black = Colors.black;
static const Color black26 = Colors.black26;
static const Color white = Colors.white;
static const MaterialColor grey = Colors.grey;
static const MaterialColor orange = Colors.orange;
static const Color orangeAccent = Colors.orangeAccent;
static const MaterialColor deepOrange = Colors.deepOrange;
static const MaterialColor red = Colors.red;
static const Color transparent = Colors.transparent;
}

2
lib/styles/styles.dart Normal file
View File

@ -0,0 +1,2 @@
export 'dimens.dart';
export 'palette.dart';

View File

@ -6,6 +6,7 @@ import 'package:hacki/config/locator.dart';
import 'package:hacki/main.dart';
import 'package:hacki/repositories/repositories.dart';
import 'package:hacki/screens/screens.dart' show WebViewScreen;
import 'package:hacki/styles/styles.dart';
import 'package:url_launcher/url_launcher.dart';
abstract class LinkUtil {
@ -56,7 +57,7 @@ abstract class LinkUtil {
options: ChromeSafariBrowserClassOptions(
ios: IOSSafariOptions(
entersReaderIfAvailable: useReader,
preferredControlTintColor: Colors.orange,
preferredControlTintColor: Palette.orange,
),
),
)

View File

@ -7,7 +7,7 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "39.0.0"
version: "40.0.0"
adaptive_theme:
dependency: "direct main"
description:
@ -21,14 +21,14 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
version: "4.1.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.1"
async:
dependency: transitive
description:
@ -42,7 +42,7 @@ packages:
name: badges
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
bloc:
dependency: "direct main"
description:
@ -126,56 +126,56 @@ packages:
name: connectivity_plus
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.5"
connectivity_plus_linux:
dependency: transitive
description:
name: connectivity_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
connectivity_plus_macos:
dependency: transitive
description:
name: connectivity_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.2"
version: "1.2.4"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
connectivity_plus_web:
dependency: transitive
description:
name: connectivity_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.2"
connectivity_plus_windows:
dependency: transitive
description:
name: connectivity_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.2"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
coverage:
dependency: transitive
description:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.2"
crypto:
dependency: transitive
description:
@ -189,14 +189,14 @@ packages:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.1"
version: "0.17.2"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.3"
version: "0.7.5"
diff_match_patch:
dependency: transitive
description:
@ -247,7 +247,7 @@ packages:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "2.0.1"
file:
dependency: transitive
description:
@ -273,7 +273,7 @@ packages:
name: flutter_blurhash
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.8"
version: "0.7.0"
flutter_cache_manager:
dependency: "direct main"
description:
@ -315,14 +315,14 @@ packages:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "9.5.2"
version: "9.6.1"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
version: "0.5.0+1"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
@ -385,7 +385,7 @@ packages:
name: flutter_slidable
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
version: "1.3.0"
flutter_test:
dependency: "direct dev"
description: flutter
@ -409,7 +409,7 @@ packages:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.3"
gbk_codec:
dependency: "direct main"
description:
@ -430,14 +430,14 @@ packages:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.1.0"
hive:
dependency: "direct main"
description:
name: hive
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.2"
html:
dependency: "direct main"
description:
@ -465,14 +465,14 @@ packages:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
version: "4.0.1"
intl:
dependency: "direct main"
description:
@ -577,14 +577,14 @@ packages:
name: octo_image
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.1.0"
path:
dependency: "direct main"
description:
@ -598,28 +598,28 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
version: "2.0.11"
path_provider_android:
dependency: "direct main"
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.14"
version: "2.0.15"
path_provider_ios:
dependency: "direct main"
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.6"
version: "2.1.7"
path_provider_macos:
dependency: transitive
description:
@ -640,7 +640,7 @@ packages:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
version: "2.1.0"
pedantic:
dependency: transitive
description:
@ -675,7 +675,7 @@ packages:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.5.1"
process:
dependency: transitive
description:
@ -689,7 +689,7 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.2"
version: "6.0.3"
pub_semver:
dependency: transitive
description:
@ -733,21 +733,21 @@ packages:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.3"
version: "0.27.4"
sembast:
dependency: "direct main"
description:
name: sembast
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
version: "3.2.0+1"
share_plus:
dependency: "direct main"
description:
name: share_plus
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.8"
version: "4.0.9"
share_plus_linux:
dependency: transitive
description:
@ -845,28 +845,28 @@ packages:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
shelf_static:
dependency: transitive
description:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
shimmer:
dependency: "direct main"
description:
@ -997,7 +997,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
universal_platform:
dependency: "direct main"
description:
@ -1011,7 +1011,7 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.3"
version: "6.1.4"
url_launcher_android:
dependency: transitive
description:
@ -1025,7 +1025,7 @@ packages:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.16"
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
@ -1046,14 +1046,14 @@ packages:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.0"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.12"
url_launcher_windows:
dependency: transitive
description:
@ -1144,7 +1144,7 @@ packages:
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0"
webview_flutter:
dependency: "direct main"
description:
@ -1158,28 +1158,28 @@ packages:
name: webview_flutter_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.8"
version: "2.8.14"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.1"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.5"
version: "2.8.1"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.2"
version: "2.7.0"
workmanager:
dependency: "direct main"
description:
@ -1200,14 +1200,14 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.1"
version: "6.1.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
version: "3.1.1"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"

View File

@ -1,6 +1,6 @@
name: hacki
description: A Hacker News reader.
version: 0.2.21+63
version: 0.2.24+66
publish_to: none
environment: