Compare commits

...

5 Commits

Author SHA1 Message Date
82fe9e287a 🐛 Bug fixes on special days 2024-12-23 23:02:47 +08:00
dc1c285de1 🍱 Add more special days 2024-12-23 22:55:03 +08:00
5a3313e94f Days countdown 2024-12-23 22:42:10 +08:00
61032c84f1 🐛 Scale down user image on ios notification extensions 2024-12-23 22:02:29 +08:00
36a5b8fb39 🐛 Bug fixes on something 2024-12-23 21:55:07 +08:00
13 changed files with 304 additions and 74 deletions

View File

@ -378,9 +378,26 @@
"dailyCheckNegativeHint5Description": "Lost connection at a crucial moment", "dailyCheckNegativeHint5Description": "Lost connection at a crucial moment",
"dailyCheckNegativeHint6": "Going out", "dailyCheckNegativeHint6": "Going out",
"dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain", "dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain",
"happyBirthday": "Happy birthday, {}!", "celebrateBirthday": "Happy birthday, {}!",
"celebrateMerryXmas": "Merry christmas, {}", "celebrateMerryXmas": "Merry christmas, {}",
"celebrateNewYear": "Happy new year, {}", "celebrateNewYear": "Happy new year, {}",
"celebrateValentineDay": "Today is valentine's day, {}!",
"celebrateLaborDay": "Today is labor day, {}.",
"celebrateMotherDay": "Today is mother's day, {}.",
"celebrateChildrenDay": "Today is children's day, {}!",
"celebrateFatherDay": "Today is father's day, {}.",
"celebrateHalloween": "Happy halloween, {}!",
"celebrateThanksgiving": "Today is thanksgiving day, {}!",
"pendingBirthday": "Birthday in {}",
"pendingMerryXmas": "Christmas in {}",
"pendingNewYear": "New year in {}",
"pendingValentineDay": "Valentine's day in {}",
"pendingLaborDay": "Labor day in {}",
"pendingMotherDay": "Mother's day in {}",
"pendingChildrenDay": "Children's day in {}",
"pendingFatherDay": "Father's day in {}",
"pendingHalloween": "Halloween in {}",
"pendingThanksgiving": "Thanksgiving day in {}",
"friendNew": "Add Friend", "friendNew": "Add Friend",
"friendRequests": "Friend Requests", "friendRequests": "Friend Requests",
"friendRequestsDescription": { "friendRequestsDescription": {
@ -488,5 +505,6 @@
"postCategoryNews": "News", "postCategoryNews": "News",
"postCategoryKnowledge": "Knowledge", "postCategoryKnowledge": "Knowledge",
"postCategoryLiterature": "Literature", "postCategoryLiterature": "Literature",
"postCategoryFunny": "Funny",
"postCategoryUncategorized": "Uncategorized" "postCategoryUncategorized": "Uncategorized"
} }

View File

@ -376,9 +376,26 @@
"dailyCheckNegativeHint5Description": "关键时刻断网", "dailyCheckNegativeHint5Description": "关键时刻断网",
"dailyCheckNegativeHint6": "出门", "dailyCheckNegativeHint6": "出门",
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨", "dailyCheckNegativeHint6Description": "忘带伞遇上大雨",
"happyBirthday": "生日快乐,{}", "celebrateBirthday": "生日快乐,{}",
"celebrateMerryXmas": "圣诞快乐,{}", "celebrateMerryXmas": "圣诞快乐,{}",
"celebrateNewYear": "新年快乐,{}", "celebrateNewYear": "新年快乐,{}",
"celebrateValentineDay": "今天是情人节,{}",
"celebrateLaborDay": "今天是劳动节,{}。",
"celebrateMotherDay": "今天是母亲节,{}。",
"celebrateChildrenDay": "今天是儿童节,{}",
"celebrateFatherDay": "今天是父亲节,{}。",
"celebrateHalloween": "快乐在圣诞节,{}",
"celebrateThanksgiving": "今天是感恩节,{}",
"pendingBirthday": "{} 过生日",
"pendingMerryXmas": "{} 过圣诞节",
"pendingNewYear": "{} 跨年",
"pendingValentineDay": "{} 过情人节",
"pendingLaborDay": "{} 过劳动节",
"pendingMotherDay": "{} 过母亲节",
"pendingChildrenDay": "{} 过儿童节",
"pendingFatherDay": "{} 过父亲节",
"pendingHalloween": "{} 过圣诞节",
"pendingThanksgiving": "{} 过感恩节",
"friendNew": "添加好友", "friendNew": "添加好友",
"friendRequests": "好友请求", "friendRequests": "好友请求",
"friendRequestsDescription": { "friendRequestsDescription": {
@ -486,5 +503,6 @@
"postCategoryNews": "新闻", "postCategoryNews": "新闻",
"postCategoryKnowledge": "知识", "postCategoryKnowledge": "知识",
"postCategoryLiterature": "文学", "postCategoryLiterature": "文学",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分类" "postCategoryUncategorized": "未分类"
} }

View File

@ -376,9 +376,26 @@
"dailyCheckNegativeHint5Description": "關鍵時刻斷網", "dailyCheckNegativeHint5Description": "關鍵時刻斷網",
"dailyCheckNegativeHint6": "出門", "dailyCheckNegativeHint6": "出門",
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨", "dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
"happyBirthday": "生日快樂,{}", "celebrateBirthday": "生日快樂,{}",
"celebrateMerryXmas": "聖誕快樂,{}", "celebrateMerryXmas": "聖誕快樂,{}",
"celebrateNewYear": "新年快樂,{}", "celebrateNewYear": "新年快樂,{}",
"celebrateValentineDay": "今天是情人節,{}",
"celebrateLaborDay": "今天是勞動節,{}。",
"celebrateMotherDay": "今天是母親節,{}。",
"celebrateChildrenDay": "今天是兒童節,{}",
"celebrateFatherDay": "今天是父親節,{}。",
"celebrateHalloween": "快樂在聖誕節,{}",
"celebrateThanksgiving": "今天是感恩節,{}",
"pendingBirthday": "{} 過生日",
"pendingMerryXmas": "{} 過聖誕節",
"pendingNewYear": "{} 跨年",
"pendingValentineDay": "{} 過情人節",
"pendingLaborDay": "{} 過勞動節",
"pendingMotherDay": "{} 過母親節",
"pendingChildrenDay": "{} 過兒童節",
"pendingFatherDay": "{} 過父親節",
"pendingHalloween": "{} 過聖誕節",
"pendingThanksgiving": "{} 過感恩節",
"friendNew": "添加好友", "friendNew": "添加好友",
"friendRequests": "好友請求", "friendRequests": "好友請求",
"friendRequestsDescription": { "friendRequestsDescription": {
@ -486,5 +503,6 @@
"postCategoryNews": "新聞", "postCategoryNews": "新聞",
"postCategoryKnowledge": "知識", "postCategoryKnowledge": "知識",
"postCategoryLiterature": "文學", "postCategoryLiterature": "文學",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分類" "postCategoryUncategorized": "未分類"
} }

View File

@ -376,9 +376,26 @@
"dailyCheckNegativeHint5Description": "關鍵時刻斷網", "dailyCheckNegativeHint5Description": "關鍵時刻斷網",
"dailyCheckNegativeHint6": "出門", "dailyCheckNegativeHint6": "出門",
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨", "dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
"happyBirthday": "生日快樂,{}", "celebrateBirthday": "生日快樂,{}",
"celebrateMerryXmas": "聖誕快樂,{}", "celebrateMerryXmas": "聖誕快樂,{}",
"celebrateNewYear": "新年快樂,{}", "celebrateNewYear": "新年快樂,{}",
"celebrateValentineDay": "今天是情人節,{}",
"celebrateLaborDay": "今天是勞動節,{}。",
"celebrateMotherDay": "今天是母親節,{}。",
"celebrateChildrenDay": "今天是兒童節,{}",
"celebrateFatherDay": "今天是父親節,{}。",
"celebrateHalloween": "快樂在聖誕節,{}",
"celebrateThanksgiving": "今天是感恩節,{}",
"pendingBirthday": "{} 過生日",
"pendingMerryXmas": "{} 過聖誕節",
"pendingNewYear": "{} 跨年",
"pendingValentineDay": "{} 過情人節",
"pendingLaborDay": "{} 過勞動節",
"pendingMotherDay": "{} 過母親節",
"pendingChildrenDay": "{} 過兒童節",
"pendingFatherDay": "{} 過父親節",
"pendingHalloween": "{} 過聖誕節",
"pendingThanksgiving": "{} 過感恩節",
"friendNew": "新增好友", "friendNew": "新增好友",
"friendRequests": "好友請求", "friendRequests": "好友請求",
"friendRequestsDescription": { "friendRequestsDescription": {
@ -486,5 +503,6 @@
"postCategoryNews": "新聞", "postCategoryNews": "新聞",
"postCategoryKnowledge": "知識", "postCategoryKnowledge": "知識",
"postCategoryLiterature": "文學", "postCategoryLiterature": "文學",
"postCategoryFunny": "搞笑",
"postCategoryUncategorized": "未分類" "postCategoryUncategorized": "未分類"
} }

View File

@ -80,7 +80,11 @@ class NotificationService: UNNotificationServiceExtension {
let metadataCopy = metadata as? [String: String] ?? [:] let metadataCopy = metadata as? [String: String] ?? [:]
let avatarUrl = getAttachmentUrl(for: avatarIdentifier) let avatarUrl = getAttachmentUrl(for: avatarIdentifier)
KingfisherManager.shared.retrieveImage(with: URL(string: avatarUrl)!, completionHandler: { result in
let targetSize = 640
let scaleProcessor = ResizingImageProcessor(referenceSize: CGSize(width: targetSize, height: targetSize), mode: .aspectFit)
KingfisherManager.shared.retrieveImage(with: URL(string: avatarUrl)!, options: [.processor(scaleProcessor)], completionHandler: { result in
var image: Data? var image: Data?
switch result { switch result {
case .success(let value): case .success(let value):

View File

@ -30,6 +30,7 @@ import 'package:surface/providers/post.dart';
import 'package:surface/providers/relationship.dart'; import 'package:surface/providers/relationship.dart';
import 'package:surface/providers/sn_attachment.dart'; import 'package:surface/providers/sn_attachment.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/special_day.dart';
import 'package:surface/providers/theme.dart'; import 'package:surface/providers/theme.dart';
import 'package:surface/providers/user_directory.dart'; import 'package:surface/providers/user_directory.dart';
import 'package:surface/providers/userinfo.dart'; import 'package:surface/providers/userinfo.dart';
@ -148,6 +149,9 @@ class SolianApp extends StatelessWidget {
ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)), ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)),
ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)), ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)),
ChangeNotifierProvider(create: (ctx) => ChatCallProvider(ctx)), ChangeNotifierProvider(create: (ctx) => ChatCallProvider(ctx)),
// Additional helper layer
Provider(create: (ctx) => SpecialDayProvider(ctx)),
], ],
child: _AppDelegate(), child: _AppDelegate(),
), ),
@ -265,6 +269,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> {
// The Network initialization will also save initialize the Config, so it not need to be initialized again // The Network initialization will also save initialize the Config, so it not need to be initialized again
final sn = context.read<SnNetworkProvider>(); final sn = context.read<SnNetworkProvider>();
await sn.initializeUserAgent(); await sn.initializeUserAgent();
await sn.setConfigWithNative();
if (!mounted) return; if (!mounted) return;
final ua = context.read<UserProvider>(); final ua = context.read<UserProvider>();
await ua.initialize(); await ua.initialize();

View File

@ -68,9 +68,8 @@ class SnNetworkProvider {
_config.initialize().then((_) { _config.initialize().then((_) {
_prefs = _config.prefs; _prefs = _config.prefs;
client.options.baseUrl = _config.serverUrl; client.options.baseUrl = _config.serverUrl;
if (!context.mounted) return;
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
}); });
} }
static Future<Dio> createOffContextClient() async { static Future<Dio> createOffContextClient() async {
@ -109,6 +108,10 @@ class SnNetworkProvider {
return client; return client;
} }
Future<void> setConfigWithNative() async {
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
}
static Future<String> _getUserAgent() async { static Future<String> _getUserAgent() async {
final String platformInfo; final String platformInfo;
if (kIsWeb) { if (kIsWeb) {

View File

@ -0,0 +1,136 @@
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import 'package:surface/providers/userinfo.dart';
// Stored as key: month, day
const Map<String, (int, int)> kSpecialDays = {
// Birthday is dynamically generated according to the user's profile
'NewYear': (1, 1),
'ValentineDay': (2, 14),
'LaborDay': (5, 1),
'MotherDay': (5, 11),
'ChildrenDay': (6, 1),
'FatherDay': (8, 8),
'Halloween': (10, 31),
'Thanksgiving': (11, 28),
'MerryXmas': (12, 25),
};
const Map<String, String> kSpecialDaysSymbol = {
'Birthday': '🎂',
'NewYear': '🎉',
'MerryXmas': '🎄',
'ValentineDay': '💑',
'LaborDay': '🏋️',
'MotherDay': '👩',
'ChildrenDay': '👶',
'FatherDay': '👨',
'Halloween': '🎃',
'Thanksgiving': '🎅',
};
class SpecialDayProvider {
late final UserProvider _user;
SpecialDayProvider(BuildContext context) {
_user = context.read<UserProvider>();
}
List<String> getSpecialDays() {
final now = DateTime.now().toLocal();
final birthday = _user.user?.profile?.birthday?.toLocal();
final isBirthday = birthday != null && birthday.day == now.day && birthday.month == now.month;
return [
if (isBirthday) 'Birthday',
...kSpecialDays.keys.where(
(key) => kSpecialDays[key]!.$1 == now.month && kSpecialDays[key]!.$2 == now.day,
),
];
}
(String, DateTime)? getLastSpecialDay() {
final now = DateTime.now().toLocal();
final birthday = _user.user?.profile?.birthday?.toLocal();
final Map<String, (int, int)> specialDays = {
if (birthday != null) 'Birthday': (birthday.month, birthday.day),
...kSpecialDays,
};
DateTime? lastDate;
String? lastEvent;
for (final entry in specialDays.entries) {
final eventName = entry.key;
final (month, day) = entry.value;
var specialDayThisYear = DateTime(now.year, month, day);
var specialDayLastYear = DateTime(now.year - 1, month, day);
if (specialDayThisYear.isBefore(now)) {
if (lastDate == null || specialDayThisYear.isAfter(lastDate)) {
lastDate = specialDayThisYear;
lastEvent = eventName;
}
} else if (specialDayLastYear.isBefore(now)) {
if (lastDate == null || specialDayLastYear.isAfter(lastDate)) {
lastDate = specialDayLastYear;
lastEvent = eventName;
}
}
}
if (lastEvent != null && lastDate != null) {
return (lastEvent, lastDate);
}
return null;
}
(String, DateTime)? getNextSpecialDay() {
final now = DateTime.now().toLocal();
final birthday = _user.user?.profile?.birthday?.toLocal();
// Stored as key: month, day
final Map<String, (int, int)> specialDays = {
if (birthday != null) 'Birthday': (birthday.month, birthday.day),
...kSpecialDays,
};
DateTime? closestDate;
String? closestEvent;
for (final entry in specialDays.entries) {
final eventName = entry.key;
final (month, day) = entry.value;
// Calculate the special day's DateTime in the current year
var specialDay = DateTime(now.year, month, day);
// If the special day has already passed this year, consider it for the next year
if (specialDay.isBefore(now)) {
specialDay = DateTime(now.year + 1, month, day);
}
// Check if this special day is closer than the previously found one
if (closestDate == null || specialDay.isBefore(closestDate)) {
closestDate = specialDay;
closestEvent = eventName;
}
}
if (closestEvent != null && closestDate != null) {
return (closestEvent, closestDate);
}
// No special day found
return null;
}
double getSpecialDayProgress(DateTime last, DateTime next) {
final totalDuration = next.difference(last).inSeconds.toDouble();
final elapsedDuration = DateTime.now().difference(last).inSeconds.toDouble();
return (elapsedDuration / totalDuration).clamp(0.0, 1.0);
}
}

View File

@ -34,7 +34,6 @@ class UserProvider extends ChangeNotifier {
refreshUser().then((value) { refreshUser().then((value) {
if (value != null) { if (value != null) {
log('Logged in as @${value.name}'); log('Logged in as @${value.name}');
_home.saveWidgetData('user', value.toJson());
} }
}); });
} }

View File

@ -13,7 +13,7 @@ class HomeWidgetProvider {
Future<void> initialize() async { Future<void> initialize() async {
if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return; if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return;
if (!kIsWeb && Platform.isIOS) { if (Platform.isIOS) {
await HomeWidget.setAppGroupId("group.solsynth.solian"); await HomeWidget.setAppGroupId("group.solsynth.solian");
} }
} }

View File

@ -22,8 +22,9 @@ const Map<String, IconData> kCategoryIcons = {
'sports': Symbols.sports_soccer, 'sports': Symbols.sports_soccer,
'music': Symbols.music_note, 'music': Symbols.music_note,
'news': Symbols.newspaper, 'news': Symbols.newspaper,
'knowledge': Symbols.book, 'knowledge': Symbols.library_books,
'literature': Symbols.book, 'literature': Symbols.book,
'funny': Symbols.attractions,
}; };
class ExploreScreen extends StatefulWidget { class ExploreScreen extends StatefulWidget {
@ -184,26 +185,27 @@ class _ExploreScreenState extends State<ExploreScreen> {
preferredSize: const Size.fromHeight(50), preferredSize: const Size.fromHeight(50),
child: SizedBox( child: SizedBox(
height: 50, height: 50,
child: ListView.builder( child: SingleChildScrollView(
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: _categories.length, padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
itemBuilder: (context, idx) { child: Row(
final ele = _categories[idx]; mainAxisAlignment: MainAxisAlignment.center,
return StyledWidget(ChoiceChip( children: _categories.map((ele) {
avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark), return StyledWidget(ChoiceChip(
label: Text( avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark),
'postCategory${ele.alias.capitalize()}'.trExists() label: Text(
? 'postCategory${ele.alias.capitalize()}'.tr() 'postCategory${ele.alias.capitalize()}'.trExists()
: ele.name, ? 'postCategory${ele.alias.capitalize()}'.tr()
), : ele.name,
selected: _selectedCategory == ele.alias, ),
onSelected: (value) { selected: _selectedCategory == ele.alias,
_selectedCategory = value ? ele.alias : null; onSelected: (value) {
_refreshPosts(); _selectedCategory = value ? ele.alias : null;
}, _refreshPosts();
)).padding(horizontal: 4); },
}, )).padding(horizontal: 4);
}).toList(),
),
), ),
), ),
), ),

View File

@ -11,11 +11,13 @@ import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:relative_time/relative_time.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:surface/providers/config.dart'; import 'package:surface/providers/config.dart';
import 'package:surface/providers/post.dart'; import 'package:surface/providers/post.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/special_day.dart';
import 'package:surface/providers/userinfo.dart'; import 'package:surface/providers/userinfo.dart';
import 'package:surface/providers/widget.dart'; import 'package:surface/providers/widget.dart';
import 'package:surface/types/check_in.dart'; import 'package:surface/types/check_in.dart';
@ -79,8 +81,8 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column( child: Column(
mainAxisAlignment: constraints.maxWidth > 640 ? MainAxisAlignment.center : MainAxisAlignment.start, mainAxisAlignment: constraints.maxWidth > 640 ? MainAxisAlignment.center : MainAxisAlignment.start,
children: [ children: [
_HomeDashSpecialDayWidget().padding(bottom: 8, horizontal: 8),
_HomeDashUpdateWidget(padding: const EdgeInsets.only(bottom: 8, left: 8, right: 8)), _HomeDashUpdateWidget(padding: const EdgeInsets.only(bottom: 8, left: 8, right: 8)),
_HomeDashSpecialDayWidget().padding(horizontal: 8),
StaggeredGrid.extent( StaggeredGrid.extent(
maxCrossAxisExtent: 280, maxCrossAxisExtent: 280,
mainAxisSpacing: 8, mainAxisSpacing: 8,
@ -156,36 +158,59 @@ class _HomeDashSpecialDayWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ua = context.watch<UserProvider>(); final ua = context.watch<UserProvider>();
final today = DateTime.now(); final dayz = context.watch<SpecialDayProvider>();
final birthday = ua.user?.profile?.birthday?.toLocal();
final isBirthday = birthday != null && birthday.day == today.day && birthday.month == today.month;
return Column( final days = dayz.getSpecialDays();
spacing: 8,
children: [ if (days.isNotEmpty) {
if (isBirthday) return Column(
Card( spacing: 8,
child: ListTile( children: days.map((ele) {
leading: Text('🎂').fontSize(24), return Card(
title: Text('happyBirthday').tr(args: [ua.user?.nick ?? 'user']), child: ListTile(
), leading: Text(kSpecialDaysSymbol[ele] ?? '🎉').fontSize(24),
).padding(bottom: 8), title: Text('celebrate$ele').tr(args: [ua.user?.nick ?? 'user']),
if (today.month == 12 && today.day == 25) subtitle: Text(
Card( DateFormat('y/M/d').format(DateTime.now().copyWith(
child: ListTile( month: kSpecialDays[ele]!.$1,
leading: Text('🎄').fontSize(24), day: kSpecialDays[ele]!.$2,
title: Text('celebrateMerryXmas').tr(args: [ua.user?.nick ?? 'user']), )),
), ),
),
).padding(bottom: 8);
}).toList());
}
final nextOne = dayz.getNextSpecialDay();
final lastOne = dayz.getLastSpecialDay();
if (nextOne != null && lastOne != null) {
var (name, date) = nextOne;
date = date.add(Duration(days: 1));
final progress = dayz.getSpecialDayProgress(lastOne.$2, date);
final diff = nextOne.$2.add(-const Duration(days: 1)).difference(lastOne.$2);
return Card(
child: ListTile(
leading: Text(kSpecialDaysSymbol[name] ?? '🎉').fontSize(24),
title: Text('pending$name').tr(args: [RelativeTime(context).format(date)]),
subtitle: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('${diff.inDays}d · ${(progress * 100).toStringAsFixed(2)}%'),
const Gap(8),
Expanded(
child: LinearProgressIndicator(
value: progress,
borderRadius: BorderRadius.circular(8),
),
),
],
), ),
if (today.month == 1 && today.day == 1) ),
Card( ).padding(bottom: 8);
child: ListTile( }
leading: Text('🎉').fontSize(24),
title: Text('celebrateNewYear').tr(args: [ua.user?.nick ?? 'user']), return const SizedBox.shrink();
),
),
],
);
} }
} }
@ -493,9 +518,7 @@ class _HomeDashRecommendationPostWidgetState extends State<_HomeDashRecommendati
setState(() => _isBusy = true); setState(() => _isBusy = true);
try { try {
final pt = context.read<SnPostContentProvider>(); final pt = context.read<SnPostContentProvider>();
final home = context.read<HomeWidgetProvider>();
_posts = await pt.listRecommendations(); _posts = await pt.listRecommendations();
home.saveWidgetData('post_featured', _posts!.first.toJson());
} catch (err) { } catch (err) {
if (!mounted) return; if (!mounted) return;
context.showErrorDialog(err); context.showErrorDialog(err);

View File

@ -282,20 +282,6 @@ class _PostCategoriesFieldState extends State<PostCategoriesField> {
: null, : null,
), ),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
onChanged: (value) {
for (final divider in kTagsDividers) {
if (value.endsWith(divider)) {
final tagValue = value.substring(0, value.length - 1);
if (tagValue.isEmpty) return;
if (!_currentCategories.contains(tagValue)) {
setState(() => _currentCategories.add(tagValue));
}
controller.clear();
widget.onUpdate(_currentCategories);
break;
}
}
},
onSubmitted: (_) { onSubmitted: (_) {
onSubmitted(); onSubmitted();
}, },