Skip to content

Commit

Permalink
fix: theming. (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
Livinglist authored Jan 25, 2025
1 parent 341e04d commit 4f7a515
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 60 deletions.
6 changes: 3 additions & 3 deletions lib/config/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class Constants {
'٩(˘◡˘)۶',
'(─‿‿─)',
'(¬‿¬)',
].pickRandomly()!;
].randomlyPicked!;

static final String sadFace = <String>[
'ಥ_ಥ',
Expand All @@ -55,13 +55,13 @@ abstract class Constants {
'(ㆆ_ㆆ)',
'ʕ•́ᴥ•̀ʔっ',
'(ㆆ_ㆆ)',
].pickRandomly()!;
].randomlyPicked!;

static final String magicWord = <String>[
'to be over the rainbow!',
'to infinity and beyond!',
'to see the future.',
].pickRandomly()!;
].randomlyPicked!;

static final String errorMessage = 'Something went wrong...$sadFace';
static final String loginErrorMessage =
Expand Down
2 changes: 0 additions & 2 deletions lib/cubits/preference/preference_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class PreferenceState extends Equatable {

bool get isFaviconEnabled => _isOn<FaviconModePreference>();

bool get isEyeCandyEnabled => _isOn<EyeCandyModePreference>();

bool get isReaderEnabled => _isOn<ReaderModePreference>();

bool get isMarkReadStoriesEnabled => _isOn<MarkReadStoriesModePreference>();
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/list_extension.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:math';

extension ListExtension<T> on List<T> {
T? pickRandomly() {
T? get randomlyPicked {
if (isEmpty) return null;
final Random random = Random(DateTime.now().millisecondsSinceEpoch);
final int luckyNumber = random.nextInt(length);
Expand Down
22 changes: 0 additions & 22 deletions lib/models/preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ abstract final class Preference<T> extends Equatable with SettingsDisplayable {
const ManualPaginationPreference(),
const SwipeGesturePreference(),
const HapticFeedbackPreference(),
const EyeCandyModePreference(),
const TrueDarkModePreference(),
const DevMode(),
],
Expand Down Expand Up @@ -316,27 +315,6 @@ final class MarkReadStoriesModePreference extends BooleanPreference {
String get subtitle => 'grey out stories you have read.';
}

final class EyeCandyModePreference extends BooleanPreference {
const EyeCandyModePreference({bool? val})
: super(val: val ?? _eyeCandyModeDefaultValue);

static const bool _eyeCandyModeDefaultValue = false;

@override
EyeCandyModePreference copyWith({required bool? val}) {
return EyeCandyModePreference(val: val);
}

@override
String get key => 'eyeCandyMode';

@override
String get title => 'Eye Candy';

@override
String get subtitle => 'some sort of magic.';
}

final class ManualPaginationPreference extends BooleanPreference {
const ManualPaginationPreference({bool? val})
: super(val: val ?? _paginationModeDefaultValue);
Expand Down
8 changes: 4 additions & 4 deletions lib/screens/item/widgets/custom_floating_action_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class CustomFloatingActionButton extends StatelessWidget {
CustomDescribedFeatureOverlay(
feature: DiscoverableFeature.jumpUpButton,
contentLocation: ContentLocation.above,
tapTarget: const Icon(
tapTarget: Icon(
Icons.keyboard_arrow_up,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
child: InkWell(
onLongPress: () =>
Expand All @@ -59,9 +59,9 @@ class CustomFloatingActionButton extends StatelessWidget {
),
CustomDescribedFeatureOverlay(
feature: DiscoverableFeature.jumpDownButton,
tapTarget: const Icon(
tapTarget: Icon(
Icons.keyboard_arrow_down,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
child: InkWell(
onLongPress: () {
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/item/widgets/fav_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/discoverable_feature.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';

class FavIconButton extends StatelessWidget {
Expand All @@ -24,7 +23,7 @@ class FavIconButton extends StatelessWidget {
icon: CustomDescribedFeatureOverlay(
tapTarget: Icon(
isFav ? Icons.favorite : Icons.favorite_border,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
feature: DiscoverableFeature.addStoryToFavList,
child: Icon(
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/item/widgets/in_thread_search_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class InThreadSearchIconButton extends StatelessWidget {
transitionType: ContainerTransitionType.fadeThrough,
closedBuilder: (BuildContext context, void Function() action) {
return CustomDescribedFeatureOverlay(
tapTarget: const Icon(
tapTarget: Icon(
Icons.search,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
feature: DiscoverableFeature.searchInThread,
child: IconButton(
Expand Down
7 changes: 3 additions & 4 deletions lib/screens/item/widgets/link_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/models/discoverable_feature.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';

class LinkIconButton extends StatelessWidget {
Expand All @@ -17,13 +16,13 @@ class LinkIconButton extends StatelessWidget {
Widget build(BuildContext context) {
return IconButton(
tooltip: 'Open this story in browser',
icon: const CustomDescribedFeatureOverlay(
icon: CustomDescribedFeatureOverlay(
tapTarget: Icon(
Icons.stream,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
feature: DiscoverableFeature.openStoryInWebView,
child: Icon(
child: const Icon(
Icons.stream,
),
),
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/item/widgets/pin_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/extensions/context_extension.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';

class PinIconButton extends StatelessWidget {
Expand All @@ -31,7 +30,7 @@ class PinIconButton extends StatelessWidget {
icon: CustomDescribedFeatureOverlay(
tapTarget: Icon(
pinned ? Icons.push_pin : Icons.push_pin_outlined,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
feature: DiscoverableFeature.pinToTop,
child: Icon(
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/item/widgets/reply_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class _ReplyBoxState extends State<ReplyBox> with ItemActionMixin {
hintStyle: TextStyle(
color: Palette.grey,
),
enabledBorder: InputBorder.none,
disabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
border: InputBorder.none,
),
Expand Down
10 changes: 6 additions & 4 deletions lib/screens/log/log_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ class LogScreen extends StatelessWidget {
),
],
),
body: ListView(
children: <Widget>[
...?snapshot.data?.map(Text.new),
],
body: Scrollbar(
child: ListView(
children: <Widget>[
...?snapshot.data?.map(Text.new),
],
),
),
);
},
Expand Down
23 changes: 22 additions & 1 deletion lib/screens/profile/widgets/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';

import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -62,6 +63,12 @@ class _SettingsState extends State<Settings> with ItemActionMixin, Loggable {
child: Column(
children: <Widget>[
ListTile(
leading: Icon(
Icons.person,
color: widget.authState.isLoggedIn
? Theme.of(context).primaryColor
: null,
),
title: Text(
widget.authState.isLoggedIn ? 'Log Out' : 'Log In',
),
Expand Down Expand Up @@ -392,7 +399,7 @@ class _SettingsState extends State<Settings> with ItemActionMixin, Loggable {
),
onTap: showClearCacheDialog,
),
if (preferenceState.isDevModeEnabled)
if (preferenceState.isDevModeEnabled) ...<Widget>[
ListTile(
title: const Text(
'Logs',
Expand All @@ -401,6 +408,20 @@ class _SettingsState extends State<Settings> with ItemActionMixin, Loggable {
context.go(Paths.log.landing);
},
),
ListTile(
title: const Text(
'Reset Feature Discovery',
),
onTap: () {
HapticFeedbackUtil.light();
FeatureDiscovery.clearPreferences(
context,
DiscoverableFeature.values
.map((DiscoverableFeature f) => f.featureId),
);
},
),
],
ListTile(
title: const Text('About'),
subtitle: const Text('nothing interesting here.'),
Expand Down
12 changes: 1 addition & 11 deletions lib/screens/widgets/comment_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ class CommentTile extends StatelessWidget {

final Color primaryColor = Theme.of(context).colorScheme.primary;
final Brightness brightness = Theme.of(context).brightness;
final Color color = _getColor(
level,
primaryColor: primaryColor,
brightness: brightness,
);

final Widget child = DeviceGestureWrapper(
child: Column(
Expand Down Expand Up @@ -307,12 +302,7 @@ class CommentTile extends StatelessWidget {
),
);

final double commentBackgroundColorOpacity =
Theme.of(context).canvasColor != Palette.white ? 0.03 : 0.15;

final Color commentColor = prefState.isEyeCandyEnabled
? color.withValues(alpha: commentBackgroundColorOpacity)
: Palette.transparent;
const Color commentColor = Palette.transparent;
final bool isMyComment = comment.deleted == false &&
context.read<AuthBloc>().state.username == comment.by;

Expand Down
4 changes: 2 additions & 2 deletions lib/screens/widgets/custom_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ class _CustomTabBarState extends State<CustomTabBar> {
Tab(
child: CustomDescribedFeatureOverlay(
onComplete: showOnboarding,
tapTarget: const Icon(
tapTarget: Icon(
Icons.person,
size: TextDimens.pt16,
color: Palette.white,
color: Theme.of(context).colorScheme.onPrimary,
),
feature: DiscoverableFeature.login,
child: BlocBuilder<NotificationCubit, NotificationState>(
Expand Down

0 comments on commit 4f7a515

Please sign in to comment.