Compare commits

...

2 Commits

Author SHA1 Message Date
1b41c847a6 Custom fonts 2025-02-27 22:35:12 +08:00
b1af6c2c97 🐛 Optimize and fix profile page loading issue 2025-02-27 22:11:53 +08:00
10 changed files with 128 additions and 19 deletions

View File

@ -0,0 +1,18 @@
meta {
name: Deal Abuse Report
type: http
seq: 3
}
put {
url: {{endpoint}}/cgi/id/reports/abuse/3/status
body: json
auth: inherit
}
body:json {
{
"status": "processed",
"message": "相关附件已经进行评级处理,未来会将该项权限下放到帖主以及社区成员。"
}
}

View File

@ -203,6 +203,11 @@
"other": "{} comments"
},
"settingsAppearance": "Appearance",
"settingsCustomFonts": "Custom Fonts",
"settingsCustomFontsDescription": "Set custom fonts for the application.",
"settingsCustomFontFamily": "Custom Font Family",
"settingsCustomFontFamilyHint": "Use comma to separate fonts, higher priority comes first",
"settingsCustomFontApplied": "Custom font has been applied.",
"settingsDisplayLanguage": "Display Language",
"settingsDisplayLanguageDescription": "Set the application language.",
"settingsDisplayLanguageSystem": "Follow System",

View File

@ -201,6 +201,11 @@
"other": "{} 条评论"
},
"settingsAppearance": "外观",
"settingsCustomFonts": "自定义字体",
"settingsCustomFontsDescription": "设置应用程序使用的字体。",
"settingsCustomFontFamily": "应用字体",
"settingsCustomFontFamilyHint": "使用英文逗号分割每一种字体,越前优先级越高",
"settingsCustomFontApplied": "自定义字体已经应用。",
"settingsDisplayLanguage": "显示语言",
"settingsDisplayLanguageDescription": "设置应用程序使用的语言",
"settingsDisplayLanguageSystem": "跟随系统",

View File

@ -201,6 +201,11 @@
"other": "{} 條評論"
},
"settingsAppearance": "外觀",
"settingsCustomFonts": "自定義字體",
"settingsCustomFontsDescription": "設置應用程序使用的字體。",
"settingsCustomFontFamily": "應用字體",
"settingsCustomFontFamilyHint": "使用英文逗號分割每一種字體,越前優先級越高",
"settingsCustomFontApplied": "自定義字體已經應用。",
"settingsDisplayLanguage": "顯示語言",
"settingsDisplayLanguageDescription": "設置應用程序使用的語言",
"settingsDisplayLanguageSystem": "跟隨系統",

View File

@ -201,6 +201,11 @@
"other": "{} 條評論"
},
"settingsAppearance": "外觀",
"settingsCustomFonts": "自定義字體",
"settingsCustomFontsDescription": "設置應用程序使用的字體。",
"settingsCustomFontFamily": "應用字體",
"settingsCustomFontFamilyHint": "使用英文逗號分割每一種字體,越前優先級越高",
"settingsCustomFontApplied": "自定義字體已經應用。",
"settingsDisplayLanguage": "顯示語言",
"settingsDisplayLanguageDescription": "設置應用程序使用的語言",
"settingsDisplayLanguageSystem": "跟隨系統",

View File

@ -18,6 +18,7 @@ const kAppNotifyWithHaptic = 'app_notify_with_haptic';
const kAppExpandPostLink = 'app_expand_post_link';
const kAppExpandChatLink = 'app_expand_chat_link';
const kAppRealmCompactView = 'app_realm_compact_view';
const kAppCustomFonts = 'app_custom_fonts';
const Map<String, FilterQuality> kImageQualityLevel = {
'settingsImageQualityLowest': FilterQuality.none,

View File

@ -13,8 +13,16 @@ class ThemeProvider extends ChangeNotifier {
});
}
void reloadTheme({Color? seedColorOverride, bool? useMaterial3}) {
createAppThemeSet(seedColorOverride: seedColorOverride, useMaterial3: useMaterial3).then((value) {
void reloadTheme({
Color? seedColorOverride,
bool? useMaterial3,
String? customFonts,
}) {
createAppThemeSet(
seedColorOverride: seedColorOverride,
useMaterial3: useMaterial3,
customFonts: customFonts,
).then((value) {
theme = value;
notifyListeners();
});

View File

@ -65,14 +65,18 @@ class _UserScreenState extends State<UserScreen>
}
}
Future<List<SnCheckInRecord>> _getCheckInRecords() async {
List<SnCheckInRecord>? _records;
Future<void> _getCheckInRecords() async {
try {
final sn = context.read<SnNetworkProvider>();
final resp =
await sn.client.get('/cgi/id/users/${widget.name}/check-in?take=14');
return List.from(
setState(() {
_records = List.from(
resp.data['data']?.map((x) => SnCheckInRecord.fromJson(x)) ?? [],
);
});
} catch (err) {
if (mounted) context.showErrorDialog(err);
rethrow;
@ -213,6 +217,7 @@ class _UserScreenState extends State<UserScreen>
_fetchStatus();
_fetchPublishers();
_getCheckInRecords();
try {
final rel = context.read<SnRelationshipProvider>();
@ -542,12 +547,10 @@ class _UserScreenState extends State<UserScreen>
SliverToBoxAdapter(child: const Divider()),
const SliverGap(12),
SliverToBoxAdapter(
child: FutureBuilder<List<SnCheckInRecord>>(
key: GlobalKey(),
future: _getCheckInRecords(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const SizedBox.shrink();
if (snapshot.data!.length <= 1) {
child: Builder(
builder: (context) {
if (_records == null) return const SizedBox.shrink();
if (_records!.length <= 1) {
return Text(
'accountCheckInNoRecords',
textAlign: TextAlign.center,
@ -557,11 +560,10 @@ class _UserScreenState extends State<UserScreen>
.center()
.padding(horizontal: 20, vertical: 8);
}
final records = snapshot.data!;
return SizedBox(
width: double.infinity,
height: 240,
child: CheckInRecordChart(records: records),
child: CheckInRecordChart(records: _records!),
).padding(
right: 24,
left: 16,

View File

@ -48,6 +48,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
late final SharedPreferences _prefs;
String _docBasepath = '/';
final TextEditingController _customFontController = TextEditingController();
final TextEditingController _serverUrlController = TextEditingController();
@override
@ -62,11 +63,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
final config = context.read<ConfigProvider>();
_prefs = config.prefs;
_serverUrlController.text = config.serverUrl;
if (_prefs.getString(kAppCustomFonts) != null) {
_customFontController.text = _prefs.getString(kAppCustomFonts) ?? '';
}
}
@override
void dispose() {
_serverUrlController.dispose();
_customFontController.dispose();
super.dispose();
}
@ -330,6 +335,47 @@ class _SettingsScreenState extends State<SettingsScreen> {
setState(() {});
},
),
ListTile(
leading: const Icon(Symbols.font_download),
title: Text('settingsCustomFonts').tr(),
subtitle: Text('settingsCustomFontsDescription').tr(),
contentPadding: const EdgeInsets.only(left: 24, right: 14),
trailing: IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.clear),
onPressed: () {
_prefs.remove(kAppCustomFonts);
context.showSnackbar('settingsCustomFontApplied'.tr());
final theme = context.read<ThemeProvider>();
_customFontController.clear();
theme.reloadTheme();
},
),
),
TextField(
controller: _customFontController,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'settingsCustomFontFamily'.tr(),
helperText: 'settingsCustomFontFamilyHint'.tr(),
prefixIcon: const Icon(Symbols.format_paint),
suffixIcon: IconButton(
icon: const Icon(Symbols.save),
onPressed: () {
_prefs.setString(
kAppCustomFonts,
_customFontController.text,
);
context.showSnackbar('settingsCustomFontApplied'.tr());
final theme = context.read<ThemeProvider>();
theme.reloadTheme();
},
),
),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
).padding(horizontal: 16, top: 8, bottom: 4),
],
),
Column(

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:surface/providers/config.dart';
@ -13,10 +12,18 @@ class ThemeSet {
}
Future<ThemeSet> createAppThemeSet(
{Color? seedColorOverride, bool? useMaterial3}) async {
{Color? seedColorOverride, bool? useMaterial3, String? customFonts}) async {
return ThemeSet(
light: await createAppTheme(Brightness.light, useMaterial3: useMaterial3),
dark: await createAppTheme(Brightness.dark, useMaterial3: useMaterial3),
light: await createAppTheme(
Brightness.light,
useMaterial3: useMaterial3,
customFonts: customFonts,
),
dark: await createAppTheme(
Brightness.dark,
useMaterial3: useMaterial3,
customFonts: customFonts,
),
);
}
@ -24,6 +31,7 @@ Future<ThemeData> createAppTheme(
Brightness brightness, {
Color? seedColorOverride,
bool? useMaterial3,
String? customFonts,
}) async {
final prefs = await SharedPreferences.getInstance();
@ -41,11 +49,17 @@ Future<ThemeData> createAppTheme(
final useM3 =
useMaterial3 ?? (prefs.getBool(kMaterialYouToggleStoreKey) ?? true);
final inUseFonts = (customFonts ?? prefs.getString(kAppCustomFonts))
?.split(',')
.map((ele) => ele.trim())
.toList();
return ThemeData(
useMaterial3: useM3,
colorScheme: colorScheme,
brightness: brightness,
textTheme: GoogleFonts.rubikTextTheme(),
fontFamily: inUseFonts?.firstOrNull,
fontFamilyFallback: inUseFonts?.sublist(1),
iconTheme: IconThemeData(
fill: 0,
weight: 400,