Add clear image cache button & name tweaks (#33)

Closes #33
This commit is contained in:
Tommy Chow 2022-01-06 23:06:25 -05:00
parent 9caad1f6c9
commit 488162a035
7 changed files with 98 additions and 65 deletions

View file

@ -82,8 +82,8 @@ class IRCMessage {
Map<String, List<BadgeInfo7TV>>? sevenTVUserToBadges,
Map<String, BadgeInfoBTTV>? bttvUserToBadge,
RoomFFZ? ffzRoomInfo,
bool hideMessage = false,
bool zeroWidthEnabled = false,
bool showMessage = true,
bool useZeroWidth = false,
bool useReadableColors = false,
Timestamp timestamp = Timestamp.none,
}) {
@ -258,7 +258,7 @@ class IRCMessage {
// Italicize the text it was called with an IRC Action i.e., "/me".
final textStyle = action == true ? const TextStyle(fontStyle: FontStyle.italic) : style;
if (hideMessage) {
if (!showMessage) {
span.add(const TextSpan(text: ' <message deleted>'));
} else {
// Add the message and any emotes to the span.
@ -267,7 +267,7 @@ class IRCMessage {
final words = chatMessage.split(' ');
words.removeWhere((element) => element == '');
if (zeroWidthEnabled) {
if (useZeroWidth) {
final localSpan = <InlineSpan>[];
var index = words.length - 1;

View file

@ -42,7 +42,7 @@ class ChatMessage extends StatelessWidget {
sevenTVUserToBadges: assetsStore.userTo7TVBadges,
bttvUserToBadge: assetsStore.userToBTTVBadges,
ffzRoomInfo: assetsStore.ffzRoomInfo,
zeroWidthEnabled: settingsStore.showZeroWidth,
useZeroWidth: settingsStore.showZeroWidth,
useReadableColors: settingsStore.useReadableColors,
timestamp: timeStamps,
),
@ -81,8 +81,8 @@ class ChatMessage extends StatelessWidget {
sevenTVUserToBadges: assetsStore.userTo7TVBadges,
bttvUserToBadge: assetsStore.userToBTTVBadges,
ffzRoomInfo: assetsStore.ffzRoomInfo,
hideMessage: settingsStore.hideBannedMessages,
zeroWidthEnabled: settingsStore.showZeroWidth,
showMessage: settingsStore.showDeletedMessages,
useZeroWidth: settingsStore.showZeroWidth,
useReadableColors: settingsStore.useReadableColors,
timestamp: timeStamps,
),
@ -135,7 +135,7 @@ class ChatMessage extends StatelessWidget {
sevenTVUserToBadges: assetsStore.userTo7TVBadges,
bttvUserToBadge: assetsStore.userToBTTVBadges,
ffzRoomInfo: assetsStore.ffzRoomInfo,
zeroWidthEnabled: settingsStore.showZeroWidth,
useZeroWidth: settingsStore.showZeroWidth,
useReadableColors: settingsStore.useReadableColors,
timestamp: timeStamps,
),

View file

@ -17,18 +17,16 @@ class ChatSettings extends StatelessWidget {
children: [
const SectionHeader('Chat'),
SwitchListTile.adaptive(
isThreeLine: true,
title: const Text('Use more readable colors for chat names'),
subtitle: const Text('Attempts to make names more readable by boosting the lightness of darker colors.'),
value: settingsStore.useReadableColors,
onChanged: (newValue) => settingsStore.useReadableColors = newValue,
title: const Text('Show deleted messages'),
value: settingsStore.showDeletedMessages,
onChanged: (newValue) => settingsStore.showDeletedMessages = newValue,
),
SwitchListTile.adaptive(
isThreeLine: true,
title: const Text('Hide banned and deleted messages'),
subtitle: const Text('Replaces deleted, timed-out, and banned user messages with "<message deleted>".'),
value: settingsStore.hideBannedMessages,
onChanged: (newValue) => settingsStore.hideBannedMessages = newValue,
title: const Text('Use readable colors for chat names'),
subtitle: const Text('Make chat names more readable by boosting the lightness of darker colors.'),
value: settingsStore.useReadableColors,
onChanged: (newValue) => settingsStore.useReadableColors = newValue,
),
SwitchListTile.adaptive(
isThreeLine: true,
@ -39,8 +37,8 @@ class ChatSettings extends StatelessWidget {
),
SwitchListTile.adaptive(
isThreeLine: true,
title: const Text('Show timestamps'),
subtitle: const Text('Displays 24-hour timestamps for when a chat message was sent.'),
title: const Text('Show message timestamps'),
subtitle: const Text('Displays timestamps for when a chat message was sent.'),
value: settingsStore.showTimestamps,
onChanged: (newValue) => settingsStore.showTimestamps = newValue,
),

View file

@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:frosty/screens/settings/stores/settings_store.dart';
import 'package:frosty/widgets/section_header.dart';
class OtherSettings extends StatelessWidget {
final SettingsStore settingsStore;
const OtherSettings({
Key? key,
required this.settingsStore,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SectionHeader('Other'),
ListTile(
leading: const Icon(Icons.info),
title: const Text('About'),
onTap: () => showAboutDialog(
context: context,
applicationName: 'Frosty for Twitch',
applicationVersion: '1.0.0',
applicationLegalese: '\u{a9} 2021 Tommy Chow',
),
),
Container(
padding: const EdgeInsets.all(10.0),
width: double.infinity,
child: OutlinedButton(
style: OutlinedButton.styleFrom(),
child: const Text('Clear Image Cache'),
onPressed: () async {
await DefaultCacheManager().emptyCache();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Image cache cleared!'),
behavior: SnackBarBehavior.floating,
),
);
},
),
),
],
);
}
}

View file

@ -3,9 +3,9 @@ import 'package:frosty/core/auth/auth_store.dart';
import 'package:frosty/screens/settings/account/account_settings.dart';
import 'package:frosty/screens/settings/chat_settings.dart';
import 'package:frosty/screens/settings/general_settings.dart';
import 'package:frosty/screens/settings/other_settings.dart';
import 'package:frosty/screens/settings/stores/settings_store.dart';
import 'package:frosty/screens/settings/video_settings.dart';
import 'package:frosty/widgets/section_header.dart';
import 'package:provider/provider.dart';
class Settings extends StatelessWidget {
@ -22,21 +22,14 @@ class Settings extends StatelessWidget {
body: SafeArea(
child: ListView(
children: [
AccountSettings(settingsStore: settingsStore, authStore: context.read<AuthStore>()),
AccountSettings(
settingsStore: settingsStore,
authStore: context.read<AuthStore>(),
),
GeneralSettings(settingsStore: settingsStore),
VideoSettings(settingsStore: settingsStore),
ChatSettings(settingsStore: settingsStore),
const SectionHeader('Other'),
ListTile(
leading: const Icon(Icons.info),
title: const Text('About'),
onTap: () => showAboutDialog(
context: context,
applicationName: 'Frosty for Twitch',
applicationVersion: '1.0.0',
applicationLegalese: '\u{a9} 2021 Tommy Chow',
),
)
OtherSettings(settingsStore: settingsStore),
],
),
),

View file

@ -32,7 +32,7 @@ abstract class _SettingsStoreBase with Store {
var useReadableColors = false;
@observable
var hideBannedMessages = false;
var showDeletedMessages = false;
@observable
var showZeroWidth = false;

View file

@ -6,28 +6,26 @@ part of 'settings_store.dart';
// JsonSerializableGenerator
// **************************************************************************
SettingsStore _$SettingsStoreFromJson(Map<String, dynamic> json) =>
SettingsStore()
..useOledTheme = json['useOledTheme'] as bool
..showVideo = json['showVideo'] as bool
..showOverlay = json['showOverlay'] as bool
..showThumbnailUptime = json['showThumbnailUptime'] as bool
..useReadableColors = json['useReadableColors'] as bool
..hideBannedMessages = json['hideBannedMessages'] as bool
..showZeroWidth = json['showZeroWidth'] as bool
..showTimestamps = json['showTimestamps'] as bool
..useTwelveHourTimestamps = json['useTwelveHourTimestamps'] as bool
..fullScreen = json['fullScreen'] as bool
..expandInfo = json['expandInfo'] as bool;
SettingsStore _$SettingsStoreFromJson(Map<String, dynamic> json) => SettingsStore()
..useOledTheme = json['useOledTheme'] as bool
..showVideo = json['showVideo'] as bool
..showOverlay = json['showOverlay'] as bool
..showThumbnailUptime = json['showThumbnailUptime'] as bool
..useReadableColors = json['useReadableColors'] as bool
..showDeletedMessages = json['hideBannedMessages'] as bool
..showZeroWidth = json['showZeroWidth'] as bool
..showTimestamps = json['showTimestamps'] as bool
..useTwelveHourTimestamps = json['useTwelveHourTimestamps'] as bool
..fullScreen = json['fullScreen'] as bool
..expandInfo = json['expandInfo'] as bool;
Map<String, dynamic> _$SettingsStoreToJson(SettingsStore instance) =>
<String, dynamic>{
Map<String, dynamic> _$SettingsStoreToJson(SettingsStore instance) => <String, dynamic>{
'useOledTheme': instance.useOledTheme,
'showVideo': instance.showVideo,
'showOverlay': instance.showOverlay,
'showThumbnailUptime': instance.showThumbnailUptime,
'useReadableColors': instance.useReadableColors,
'hideBannedMessages': instance.hideBannedMessages,
'hideBannedMessages': instance.showDeletedMessages,
'showZeroWidth': instance.showZeroWidth,
'showTimestamps': instance.showTimestamps,
'useTwelveHourTimestamps': instance.useTwelveHourTimestamps,
@ -87,8 +85,7 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
});
}
final _$showThumbnailUptimeAtom =
Atom(name: '_SettingsStoreBase.showThumbnailUptime');
final _$showThumbnailUptimeAtom = Atom(name: '_SettingsStoreBase.showThumbnailUptime');
@override
bool get showThumbnailUptime {
@ -103,8 +100,7 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
});
}
final _$useReadableColorsAtom =
Atom(name: '_SettingsStoreBase.useReadableColors');
final _$useReadableColorsAtom = Atom(name: '_SettingsStoreBase.useReadableColors');
@override
bool get useReadableColors {
@ -119,19 +115,18 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
});
}
final _$hideBannedMessagesAtom =
Atom(name: '_SettingsStoreBase.hideBannedMessages');
final _$hideBannedMessagesAtom = Atom(name: '_SettingsStoreBase.hideBannedMessages');
@override
bool get hideBannedMessages {
bool get showDeletedMessages {
_$hideBannedMessagesAtom.reportRead();
return super.hideBannedMessages;
return super.showDeletedMessages;
}
@override
set hideBannedMessages(bool value) {
_$hideBannedMessagesAtom.reportWrite(value, super.hideBannedMessages, () {
super.hideBannedMessages = value;
set showDeletedMessages(bool value) {
_$hideBannedMessagesAtom.reportWrite(value, super.showDeletedMessages, () {
super.showDeletedMessages = value;
});
}
@ -165,8 +160,7 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
});
}
final _$useTwelveHourTimestampsAtom =
Atom(name: '_SettingsStoreBase.useTwelveHourTimestamps');
final _$useTwelveHourTimestampsAtom = Atom(name: '_SettingsStoreBase.useTwelveHourTimestamps');
@override
bool get useTwelveHourTimestamps {
@ -176,8 +170,7 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
@override
set useTwelveHourTimestamps(bool value) {
_$useTwelveHourTimestampsAtom
.reportWrite(value, super.useTwelveHourTimestamps, () {
_$useTwelveHourTimestampsAtom.reportWrite(value, super.useTwelveHourTimestamps, () {
super.useTwelveHourTimestamps = value;
});
}
@ -220,7 +213,7 @@ showVideo: ${showVideo},
showOverlay: ${showOverlay},
showThumbnailUptime: ${showThumbnailUptime},
useReadableColors: ${useReadableColors},
hideBannedMessages: ${hideBannedMessages},
hideBannedMessages: ${showDeletedMessages},
showZeroWidth: ${showZeroWidth},
showTimestamps: ${showTimestamps},
useTwelveHourTimestamps: ${useTwelveHourTimestamps},