2022-07-02 22:57:23 -04:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
2021-12-28 22:52:29 -05:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2022-08-31 14:11:45 -04:00
|
|
|
import 'package:frosty/constants.dart';
|
2022-01-04 02:58:02 -05:00
|
|
|
import 'package:frosty/screens/settings/stores/settings_store.dart';
|
2023-01-18 05:34:54 -05:00
|
|
|
import 'package:frosty/screens/settings/widgets/settings_list_select.dart';
|
|
|
|
|
import 'package:frosty/screens/settings/widgets/settings_list_slider.dart';
|
|
|
|
|
import 'package:frosty/screens/settings/widgets/settings_list_switch.dart';
|
|
|
|
|
import 'package:frosty/widgets/cached_image.dart';
|
2022-03-30 19:29:51 -04:00
|
|
|
import 'package:frosty/widgets/section_header.dart';
|
2021-12-28 22:52:29 -05:00
|
|
|
|
2022-01-07 23:12:41 -05:00
|
|
|
class ChatSettings extends StatefulWidget {
|
2021-12-28 22:52:29 -05:00
|
|
|
final SettingsStore settingsStore;
|
|
|
|
|
|
|
|
|
|
const ChatSettings({Key? key, required this.settingsStore}) : super(key: key);
|
|
|
|
|
|
2022-01-07 23:12:41 -05:00
|
|
|
@override
|
2022-05-12 04:58:03 -04:00
|
|
|
State<ChatSettings> createState() => _ChatSettingsState();
|
2022-01-07 23:12:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ChatSettingsState extends State<ChatSettings> {
|
|
|
|
|
var showPreview = false;
|
|
|
|
|
|
2021-12-28 22:52:29 -05:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2022-01-07 23:12:41 -05:00
|
|
|
final settingsStore = widget.settingsStore;
|
|
|
|
|
|
2021-12-28 22:52:29 -05:00
|
|
|
return Observer(
|
2023-01-18 05:34:54 -05:00
|
|
|
builder: (context) => ListView(
|
2022-03-26 01:52:08 -04:00
|
|
|
children: [
|
2023-01-18 05:34:54 -05:00
|
|
|
const SectionHeader('Message sizing'),
|
2022-03-29 23:11:09 -04:00
|
|
|
ExpansionTile(
|
2023-10-22 18:38:32 -04:00
|
|
|
title: const Text(
|
|
|
|
|
'Preview',
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w500),
|
|
|
|
|
),
|
2022-03-29 23:11:09 -04:00
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
2023-01-18 05:34:54 -05:00
|
|
|
padding: const EdgeInsets.all(16),
|
2022-03-29 23:11:09 -04:00
|
|
|
child: DefaultTextStyle(
|
2023-04-29 11:34:28 -04:00
|
|
|
style: DefaultTextStyle.of(context)
|
|
|
|
|
.style
|
|
|
|
|
.copyWith(fontSize: settingsStore.fontSize),
|
2022-03-29 23:11:09 -04:00
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text.rich(
|
|
|
|
|
TextSpan(
|
|
|
|
|
children: [
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
alignment: PlaceholderAlignment.middle,
|
2023-01-18 05:34:54 -05:00
|
|
|
child: FrostyCachedNetworkImage(
|
|
|
|
|
imageUrl:
|
|
|
|
|
'https://static-cdn.jtvnw.net/badges/v1/bbbe0db0-a598-423e-86d0-f9fb98ca1933/3',
|
2023-04-29 11:34:28 -04:00
|
|
|
height:
|
|
|
|
|
defaultBadgeSize * settingsStore.badgeScale,
|
|
|
|
|
width:
|
|
|
|
|
defaultBadgeSize * settingsStore.badgeScale,
|
2022-03-29 23:11:09 -04:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const TextSpan(text: ' Badge and emote preview. '),
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
alignment: PlaceholderAlignment.middle,
|
2023-01-18 05:34:54 -05:00
|
|
|
child: FrostyCachedNetworkImage(
|
2023-04-29 11:34:28 -04:00
|
|
|
imageUrl:
|
|
|
|
|
'https://static-cdn.jtvnw.net/emoticons/v2/425618/default/dark/3.0',
|
|
|
|
|
height:
|
|
|
|
|
defaultEmoteSize * settingsStore.emoteScale,
|
|
|
|
|
width:
|
|
|
|
|
defaultEmoteSize * settingsStore.emoteScale,
|
2022-03-29 23:11:09 -04:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2022-03-29 23:11:09 -04:00
|
|
|
textScaleFactor: settingsStore.messageScale,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: settingsStore.messageSpacing),
|
|
|
|
|
Text(
|
|
|
|
|
'Hello! Here\'s a text preview.',
|
|
|
|
|
textScaleFactor: settingsStore.messageScale,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: settingsStore.messageSpacing),
|
|
|
|
|
Text(
|
|
|
|
|
'And another for spacing without an emote!',
|
|
|
|
|
textScaleFactor: settingsStore.messageScale,
|
|
|
|
|
),
|
|
|
|
|
],
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2022-03-29 23:11:09 -04:00
|
|
|
),
|
2022-03-26 01:52:08 -04:00
|
|
|
),
|
2022-03-29 23:11:09 -04:00
|
|
|
],
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Badge scale',
|
|
|
|
|
trailing: '${settingsStore.badgeScale.toStringAsFixed(2)}x',
|
|
|
|
|
value: settingsStore.badgeScale,
|
|
|
|
|
min: 0.25,
|
|
|
|
|
max: 3.0,
|
|
|
|
|
divisions: 11,
|
|
|
|
|
onChanged: (newValue) => settingsStore.badgeScale = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Emote scale',
|
|
|
|
|
trailing: '${settingsStore.emoteScale.toStringAsFixed(2)}x',
|
|
|
|
|
value: settingsStore.emoteScale,
|
|
|
|
|
min: 0.25,
|
|
|
|
|
max: 3.0,
|
|
|
|
|
divisions: 11,
|
|
|
|
|
onChanged: (newValue) => settingsStore.emoteScale = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Message scale',
|
|
|
|
|
trailing: '${settingsStore.messageScale.toStringAsFixed(2)}x',
|
|
|
|
|
value: settingsStore.messageScale,
|
|
|
|
|
min: 0.5,
|
|
|
|
|
max: 2.0,
|
|
|
|
|
divisions: 6,
|
|
|
|
|
onChanged: (newValue) => settingsStore.messageScale = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Message spacing',
|
|
|
|
|
trailing: '${settingsStore.messageSpacing.toStringAsFixed(0)}px',
|
|
|
|
|
value: settingsStore.messageSpacing,
|
|
|
|
|
max: 30.0,
|
2023-10-22 18:38:32 -04:00
|
|
|
divisions: 15,
|
2023-01-18 05:34:54 -05:00
|
|
|
onChanged: (newValue) => settingsStore.messageSpacing = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Font size',
|
|
|
|
|
trailing: settingsStore.fontSize.toInt().toString(),
|
|
|
|
|
value: settingsStore.fontSize,
|
|
|
|
|
min: 5,
|
|
|
|
|
max: 20,
|
|
|
|
|
divisions: 15,
|
|
|
|
|
onChanged: (newValue) => settingsStore.fontSize = newValue,
|
|
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Message appearance', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Use readable name colors',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Adjusts the lightness value of overly bright and dark names.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.useReadableColors,
|
|
|
|
|
onChanged: (newValue) => settingsStore.useReadableColors = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Show deleted messages',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Restores the original message of deleted messages.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.showDeletedMessages,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.showDeletedMessages = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Show message dividers',
|
|
|
|
|
value: settingsStore.showChatMessageDividers,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.showChatMessageDividers = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSelect(
|
|
|
|
|
title: 'Message timestamps',
|
2023-01-19 02:27:51 -05:00
|
|
|
selectedOption: timestampNames[settingsStore.timestampType.index],
|
|
|
|
|
options: timestampNames,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) => settingsStore.timestampType =
|
|
|
|
|
TimestampType.values[timestampNames.indexOf(newValue)],
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Delay', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Message delay',
|
|
|
|
|
trailing: '${settingsStore.chatDelay.toInt()}s',
|
|
|
|
|
subtitle:
|
|
|
|
|
'Adds a delay (in seconds) before each message is rendered in chat. ${Platform.isIOS ? '15 seconds is recommended for iOS.' : ''}',
|
|
|
|
|
value: settingsStore.chatDelay,
|
|
|
|
|
max: 30.0,
|
|
|
|
|
divisions: 30,
|
|
|
|
|
onChanged: (newValue) => settingsStore.chatDelay = newValue,
|
|
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Alerts', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Highlight first time chatters',
|
|
|
|
|
value: settingsStore.highlightFirstTimeChatter,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.highlightFirstTimeChatter = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Show notices',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Shows notices such as subs and re-subs, announcements, and raids.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.showUserNotices,
|
|
|
|
|
onChanged: (newValue) => settingsStore.showUserNotices = newValue,
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Layout', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Show bottom bar',
|
|
|
|
|
value: settingsStore.showBottomBar,
|
|
|
|
|
onChanged: (newValue) => settingsStore.showBottomBar = newValue,
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Move emote menu button left',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Places the emote menu button on the left side to avoid accidental presses.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.emoteMenuButtonOnLeft,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.emoteMenuButtonOnLeft = newValue,
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Move notifications to bottom',
|
|
|
|
|
value: settingsStore.chatNotificationsOnBottom,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.chatNotificationsOnBottom = newValue,
|
2022-03-28 02:48:32 -04:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Landscape mode', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Move chat left',
|
|
|
|
|
value: settingsStore.landscapeChatLeftSide,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.landscapeChatLeftSide = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Force vertical chat',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle:
|
|
|
|
|
const Text('Intended for tablets and other larger displays.'),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.landscapeForceVerticalChat,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.landscapeForceVerticalChat = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSelect(
|
|
|
|
|
title: 'Fill notch side',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle:
|
|
|
|
|
'Overrides and fills the available space in devices with a display notch.',
|
|
|
|
|
selectedOption:
|
|
|
|
|
landscapeCutoutNames[settingsStore.landscapeCutout.index],
|
2023-01-19 02:27:51 -05:00
|
|
|
options: landscapeCutoutNames,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) => settingsStore.landscapeCutout =
|
|
|
|
|
LandscapeCutoutType
|
|
|
|
|
.values[landscapeCutoutNames.indexOf(newValue)],
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Chat width',
|
|
|
|
|
trailing: '${(settingsStore.chatWidth * 100).toStringAsFixed(0)}%',
|
|
|
|
|
value: settingsStore.chatWidth,
|
|
|
|
|
min: 0.2,
|
|
|
|
|
max: 0.6,
|
|
|
|
|
divisions: 8,
|
|
|
|
|
onChanged: (newValue) => settingsStore.chatWidth = newValue,
|
|
|
|
|
),
|
|
|
|
|
SettingsListSlider(
|
|
|
|
|
title: 'Chat overlay opacity',
|
2023-04-29 11:34:28 -04:00
|
|
|
trailing:
|
|
|
|
|
'${(settingsStore.fullScreenChatOverlayOpacity * 100).toStringAsFixed(0)}%',
|
|
|
|
|
subtitle:
|
|
|
|
|
'Sets the opacity (transparency) of the overlay chat in fullscreen mode.',
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.fullScreenChatOverlayOpacity,
|
|
|
|
|
divisions: 10,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.fullScreenChatOverlayOpacity = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Sleep', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Prevent sleep in chat-only mode',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Requires restarting the chat in order to take effect.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.chatOnlyPreventSleep,
|
2023-04-29 11:34:28 -04:00
|
|
|
onChanged: (newValue) =>
|
|
|
|
|
settingsStore.chatOnlyPreventSleep = newValue,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SectionHeader('Autocomplete', showDivider: true),
|
2023-01-18 05:34:54 -05:00
|
|
|
SettingsListSwitch(
|
|
|
|
|
title: 'Show autocomplete bar',
|
2023-04-29 11:34:28 -04:00
|
|
|
subtitle: const Text(
|
2023-10-22 18:38:32 -04:00
|
|
|
'Shows a bar containing matching emotes and mentions while typing.',
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
value: settingsStore.autocomplete,
|
|
|
|
|
onChanged: (newValue) => settingsStore.autocomplete = newValue,
|
2022-03-26 01:52:08 -04:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2021-12-28 22:52:29 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|