Compare commits
5 Commits
3eda464e03
...
82fe9e287a
Author | SHA1 | Date | |
---|---|---|---|
82fe9e287a | |||
dc1c285de1 | |||
5a3313e94f | |||
61032c84f1 | |||
36a5b8fb39 |
@ -378,9 +378,26 @@
|
||||
"dailyCheckNegativeHint5Description": "Lost connection at a crucial moment",
|
||||
"dailyCheckNegativeHint6": "Going out",
|
||||
"dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain",
|
||||
"happyBirthday": "Happy birthday, {}!",
|
||||
"celebrateBirthday": "Happy birthday, {}!",
|
||||
"celebrateMerryXmas": "Merry christmas, {}!",
|
||||
"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",
|
||||
"friendRequests": "Friend Requests",
|
||||
"friendRequestsDescription": {
|
||||
@ -488,5 +505,6 @@
|
||||
"postCategoryNews": "News",
|
||||
"postCategoryKnowledge": "Knowledge",
|
||||
"postCategoryLiterature": "Literature",
|
||||
"postCategoryFunny": "Funny",
|
||||
"postCategoryUncategorized": "Uncategorized"
|
||||
}
|
||||
|
@ -376,9 +376,26 @@
|
||||
"dailyCheckNegativeHint5Description": "关键时刻断网",
|
||||
"dailyCheckNegativeHint6": "出门",
|
||||
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨",
|
||||
"happyBirthday": "生日快乐,{}!",
|
||||
"celebrateBirthday": "生日快乐,{}!",
|
||||
"celebrateMerryXmas": "圣诞快乐,{}!",
|
||||
"celebrateNewYear": "新年快乐,{}!",
|
||||
"celebrateValentineDay": "今天是情人节,{}!",
|
||||
"celebrateLaborDay": "今天是劳动节,{}。",
|
||||
"celebrateMotherDay": "今天是母亲节,{}。",
|
||||
"celebrateChildrenDay": "今天是儿童节,{}!",
|
||||
"celebrateFatherDay": "今天是父亲节,{}。",
|
||||
"celebrateHalloween": "快乐在圣诞节,{}!",
|
||||
"celebrateThanksgiving": "今天是感恩节,{}!",
|
||||
"pendingBirthday": "{} 过生日",
|
||||
"pendingMerryXmas": "{} 过圣诞节",
|
||||
"pendingNewYear": "{} 跨年",
|
||||
"pendingValentineDay": "{} 过情人节",
|
||||
"pendingLaborDay": "{} 过劳动节",
|
||||
"pendingMotherDay": "{} 过母亲节",
|
||||
"pendingChildrenDay": "{} 过儿童节",
|
||||
"pendingFatherDay": "{} 过父亲节",
|
||||
"pendingHalloween": "{} 过圣诞节",
|
||||
"pendingThanksgiving": "{} 过感恩节",
|
||||
"friendNew": "添加好友",
|
||||
"friendRequests": "好友请求",
|
||||
"friendRequestsDescription": {
|
||||
@ -486,5 +503,6 @@
|
||||
"postCategoryNews": "新闻",
|
||||
"postCategoryKnowledge": "知识",
|
||||
"postCategoryLiterature": "文学",
|
||||
"postCategoryFunny": "搞笑",
|
||||
"postCategoryUncategorized": "未分类"
|
||||
}
|
||||
|
@ -376,9 +376,26 @@
|
||||
"dailyCheckNegativeHint5Description": "關鍵時刻斷網",
|
||||
"dailyCheckNegativeHint6": "出門",
|
||||
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
||||
"happyBirthday": "生日快樂,{}!",
|
||||
"celebrateBirthday": "生日快樂,{}!",
|
||||
"celebrateMerryXmas": "聖誕快樂,{}!",
|
||||
"celebrateNewYear": "新年快樂,{}!",
|
||||
"celebrateValentineDay": "今天是情人節,{}!",
|
||||
"celebrateLaborDay": "今天是勞動節,{}。",
|
||||
"celebrateMotherDay": "今天是母親節,{}。",
|
||||
"celebrateChildrenDay": "今天是兒童節,{}!",
|
||||
"celebrateFatherDay": "今天是父親節,{}。",
|
||||
"celebrateHalloween": "快樂在聖誕節,{}!",
|
||||
"celebrateThanksgiving": "今天是感恩節,{}!",
|
||||
"pendingBirthday": "{} 過生日",
|
||||
"pendingMerryXmas": "{} 過聖誕節",
|
||||
"pendingNewYear": "{} 跨年",
|
||||
"pendingValentineDay": "{} 過情人節",
|
||||
"pendingLaborDay": "{} 過勞動節",
|
||||
"pendingMotherDay": "{} 過母親節",
|
||||
"pendingChildrenDay": "{} 過兒童節",
|
||||
"pendingFatherDay": "{} 過父親節",
|
||||
"pendingHalloween": "{} 過聖誕節",
|
||||
"pendingThanksgiving": "{} 過感恩節",
|
||||
"friendNew": "添加好友",
|
||||
"friendRequests": "好友請求",
|
||||
"friendRequestsDescription": {
|
||||
@ -486,5 +503,6 @@
|
||||
"postCategoryNews": "新聞",
|
||||
"postCategoryKnowledge": "知識",
|
||||
"postCategoryLiterature": "文學",
|
||||
"postCategoryFunny": "搞笑",
|
||||
"postCategoryUncategorized": "未分類"
|
||||
}
|
||||
|
@ -376,9 +376,26 @@
|
||||
"dailyCheckNegativeHint5Description": "關鍵時刻斷網",
|
||||
"dailyCheckNegativeHint6": "出門",
|
||||
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
||||
"happyBirthday": "生日快樂,{}!",
|
||||
"celebrateBirthday": "生日快樂,{}!",
|
||||
"celebrateMerryXmas": "聖誕快樂,{}!",
|
||||
"celebrateNewYear": "新年快樂,{}!",
|
||||
"celebrateValentineDay": "今天是情人節,{}!",
|
||||
"celebrateLaborDay": "今天是勞動節,{}。",
|
||||
"celebrateMotherDay": "今天是母親節,{}。",
|
||||
"celebrateChildrenDay": "今天是兒童節,{}!",
|
||||
"celebrateFatherDay": "今天是父親節,{}。",
|
||||
"celebrateHalloween": "快樂在聖誕節,{}!",
|
||||
"celebrateThanksgiving": "今天是感恩節,{}!",
|
||||
"pendingBirthday": "{} 過生日",
|
||||
"pendingMerryXmas": "{} 過聖誕節",
|
||||
"pendingNewYear": "{} 跨年",
|
||||
"pendingValentineDay": "{} 過情人節",
|
||||
"pendingLaborDay": "{} 過勞動節",
|
||||
"pendingMotherDay": "{} 過母親節",
|
||||
"pendingChildrenDay": "{} 過兒童節",
|
||||
"pendingFatherDay": "{} 過父親節",
|
||||
"pendingHalloween": "{} 過聖誕節",
|
||||
"pendingThanksgiving": "{} 過感恩節",
|
||||
"friendNew": "新增好友",
|
||||
"friendRequests": "好友請求",
|
||||
"friendRequestsDescription": {
|
||||
@ -486,5 +503,6 @@
|
||||
"postCategoryNews": "新聞",
|
||||
"postCategoryKnowledge": "知識",
|
||||
"postCategoryLiterature": "文學",
|
||||
"postCategoryFunny": "搞笑",
|
||||
"postCategoryUncategorized": "未分類"
|
||||
}
|
||||
|
@ -80,7 +80,11 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
|
||||
let metadataCopy = metadata as? [String: String] ?? [:]
|
||||
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?
|
||||
switch result {
|
||||
case .success(let value):
|
||||
|
@ -30,6 +30,7 @@ import 'package:surface/providers/post.dart';
|
||||
import 'package:surface/providers/relationship.dart';
|
||||
import 'package:surface/providers/sn_attachment.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/user_directory.dart';
|
||||
import 'package:surface/providers/userinfo.dart';
|
||||
@ -148,6 +149,9 @@ class SolianApp extends StatelessWidget {
|
||||
ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)),
|
||||
ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)),
|
||||
ChangeNotifierProvider(create: (ctx) => ChatCallProvider(ctx)),
|
||||
|
||||
// Additional helper layer
|
||||
Provider(create: (ctx) => SpecialDayProvider(ctx)),
|
||||
],
|
||||
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
|
||||
final sn = context.read<SnNetworkProvider>();
|
||||
await sn.initializeUserAgent();
|
||||
await sn.setConfigWithNative();
|
||||
if (!mounted) return;
|
||||
final ua = context.read<UserProvider>();
|
||||
await ua.initialize();
|
||||
|
@ -68,9 +68,8 @@ class SnNetworkProvider {
|
||||
_config.initialize().then((_) {
|
||||
_prefs = _config.prefs;
|
||||
client.options.baseUrl = _config.serverUrl;
|
||||
if (!context.mounted) return;
|
||||
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static Future<Dio> createOffContextClient() async {
|
||||
@ -109,6 +108,10 @@ class SnNetworkProvider {
|
||||
return client;
|
||||
}
|
||||
|
||||
Future<void> setConfigWithNative() async {
|
||||
_home.saveWidgetData("nex_server_url", client.options.baseUrl);
|
||||
}
|
||||
|
||||
static Future<String> _getUserAgent() async {
|
||||
final String platformInfo;
|
||||
if (kIsWeb) {
|
||||
|
136
lib/providers/special_day.dart
Normal file
136
lib/providers/special_day.dart
Normal 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);
|
||||
}
|
||||
}
|
@ -34,7 +34,6 @@ class UserProvider extends ChangeNotifier {
|
||||
refreshUser().then((value) {
|
||||
if (value != null) {
|
||||
log('Logged in as @${value.name}');
|
||||
_home.saveWidgetData('user', value.toJson());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class HomeWidgetProvider {
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) return;
|
||||
if (!kIsWeb && Platform.isIOS) {
|
||||
if (Platform.isIOS) {
|
||||
await HomeWidget.setAppGroupId("group.solsynth.solian");
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ const Map<String, IconData> kCategoryIcons = {
|
||||
'sports': Symbols.sports_soccer,
|
||||
'music': Symbols.music_note,
|
||||
'news': Symbols.newspaper,
|
||||
'knowledge': Symbols.book,
|
||||
'knowledge': Symbols.library_books,
|
||||
'literature': Symbols.book,
|
||||
'funny': Symbols.attractions,
|
||||
};
|
||||
|
||||
class ExploreScreen extends StatefulWidget {
|
||||
@ -184,26 +185,27 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
||||
preferredSize: const Size.fromHeight(50),
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _categories.length,
|
||||
itemBuilder: (context, idx) {
|
||||
final ele = _categories[idx];
|
||||
return StyledWidget(ChoiceChip(
|
||||
avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark),
|
||||
label: Text(
|
||||
'postCategory${ele.alias.capitalize()}'.trExists()
|
||||
? 'postCategory${ele.alias.capitalize()}'.tr()
|
||||
: ele.name,
|
||||
),
|
||||
selected: _selectedCategory == ele.alias,
|
||||
onSelected: (value) {
|
||||
_selectedCategory = value ? ele.alias : null;
|
||||
_refreshPosts();
|
||||
},
|
||||
)).padding(horizontal: 4);
|
||||
},
|
||||
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: _categories.map((ele) {
|
||||
return StyledWidget(ChoiceChip(
|
||||
avatar: Icon(kCategoryIcons[ele.alias] ?? Symbols.question_mark),
|
||||
label: Text(
|
||||
'postCategory${ele.alias.capitalize()}'.trExists()
|
||||
? 'postCategory${ele.alias.capitalize()}'.tr()
|
||||
: ele.name,
|
||||
),
|
||||
selected: _selectedCategory == ele.alias,
|
||||
onSelected: (value) {
|
||||
_selectedCategory = value ? ele.alias : null;
|
||||
_refreshPosts();
|
||||
},
|
||||
)).padding(horizontal: 4);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -11,11 +11,13 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:relative_time/relative_time.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:surface/providers/config.dart';
|
||||
import 'package:surface/providers/post.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/widget.dart';
|
||||
import 'package:surface/types/check_in.dart';
|
||||
@ -79,8 +81,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: constraints.maxWidth > 640 ? MainAxisAlignment.center : MainAxisAlignment.start,
|
||||
children: [
|
||||
_HomeDashSpecialDayWidget().padding(bottom: 8, horizontal: 8),
|
||||
_HomeDashUpdateWidget(padding: const EdgeInsets.only(bottom: 8, left: 8, right: 8)),
|
||||
_HomeDashSpecialDayWidget().padding(horizontal: 8),
|
||||
StaggeredGrid.extent(
|
||||
maxCrossAxisExtent: 280,
|
||||
mainAxisSpacing: 8,
|
||||
@ -156,36 +158,59 @@ class _HomeDashSpecialDayWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ua = context.watch<UserProvider>();
|
||||
final today = DateTime.now();
|
||||
final birthday = ua.user?.profile?.birthday?.toLocal();
|
||||
final isBirthday = birthday != null && birthday.day == today.day && birthday.month == today.month;
|
||||
final dayz = context.watch<SpecialDayProvider>();
|
||||
|
||||
return Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (isBirthday)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('🎂').fontSize(24),
|
||||
title: Text('happyBirthday').tr(args: [ua.user?.nick ?? 'user']),
|
||||
),
|
||||
).padding(bottom: 8),
|
||||
if (today.month == 12 && today.day == 25)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('🎄').fontSize(24),
|
||||
title: Text('celebrateMerryXmas').tr(args: [ua.user?.nick ?? 'user']),
|
||||
),
|
||||
final days = dayz.getSpecialDays();
|
||||
|
||||
if (days.isNotEmpty) {
|
||||
return Column(
|
||||
spacing: 8,
|
||||
children: days.map((ele) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: Text(kSpecialDaysSymbol[ele] ?? '🎉').fontSize(24),
|
||||
title: Text('celebrate$ele').tr(args: [ua.user?.nick ?? 'user']),
|
||||
subtitle: Text(
|
||||
DateFormat('y/M/d').format(DateTime.now().copyWith(
|
||||
month: kSpecialDays[ele]!.$1,
|
||||
day: kSpecialDays[ele]!.$2,
|
||||
)),
|
||||
),
|
||||
),
|
||||
).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(
|
||||
child: ListTile(
|
||||
leading: Text('🎉').fontSize(24),
|
||||
title: Text('celebrateNewYear').tr(args: [ua.user?.nick ?? 'user']),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
).padding(bottom: 8);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,9 +518,7 @@ class _HomeDashRecommendationPostWidgetState extends State<_HomeDashRecommendati
|
||||
setState(() => _isBusy = true);
|
||||
try {
|
||||
final pt = context.read<SnPostContentProvider>();
|
||||
final home = context.read<HomeWidgetProvider>();
|
||||
_posts = await pt.listRecommendations();
|
||||
home.saveWidgetData('post_featured', _posts!.first.toJson());
|
||||
} catch (err) {
|
||||
if (!mounted) return;
|
||||
context.showErrorDialog(err);
|
||||
|
@ -282,20 +282,6 @@ class _PostCategoriesFieldState extends State<PostCategoriesField> {
|
||||
: null,
|
||||
),
|
||||
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();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user