Skip to content

Commit 24bc49b

Browse files
NamxobickKriseevM
andauthored
Отображение постов в живой ленте без комментариев (#620)
Co-authored-by: Mikhail Kriseev <mish.kryseev@gmail.com>
1 parent 815ad61 commit 24bc49b

File tree

45 files changed

+1351
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1351
-179
lines changed

lib/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class UnnMobile extends StatelessWidget {
3131
scheduleDayHighlight: Color(0xFFEEEEEE),
3232
scheduleSubjectHighlight: Color(0xFFFFF6E8),
3333
defaultPostHighlight: Color(0xFFFFFFFF),
34-
importantPostHighlight: Color(0xFFFAD289),
34+
importantPostHighlight: Color(0xFFFFE3AF),
3535
newPostHighlight: Color(0xFFFFF6E8),
3636
subjectTypeHighlight: {
3737
SubjectType.lecture: Color(0xFF1CA49C),

lib/core/constants/api/ajax_action.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class AjaxActionStrings {
55
/// QueryParams для указания action
66
static const String actionKey = 'action';
77

8+
/// QueryParams для указания action
9+
static const String c = 'c';
10+
811
/// Для получения следующей страниц живой ленты в формате html
912
static const String getNextPage = 'socialnetwork.api.livefeed.getNextPage';
1013

@@ -64,4 +67,10 @@ class AjaxActionStrings {
6467

6568
/// Для сохранения диолога в истории поиска
6669
static const String saveDialog = 'ui.entityselector.saveRecentItems';
70+
71+
/// Для обновления живой ленты
72+
static const String refreshBlogPosts = 'socialnetwork.api.livefeed.refresh';
73+
74+
/// Для получения постов из живой ленты
75+
static const String logBlogPosts = 'bitrix:socialnetwork.log.ex';
6776
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright 2026 BitCodersNN
3+
4+
import 'package:unn_mobile/core/constants/string_keys/session_identifier_keys.dart';
5+
6+
class FeedDataKeys {
7+
static const String logajax = 'logajax';
8+
static const String reload = 'RELOAD';
9+
static const String noblog = 'noblog';
10+
static const String useBXMainFilter = 'params[useBXMainFilter]';
11+
static const String siteTemplateId = 'params[siteTemplateId]';
12+
static const String pageNumber = 'params[PAGE_NUMBER]';
13+
static const String lastLogTimestamp = 'params[LAST_LOG_TIMESTAMP]';
14+
static const String prevPageLogId = 'params[PREV_PAGE_LOG_ID]';
15+
static const String presentFilterTopId = 'params[present_filter_top_id]';
16+
static const String presentFilterId = 'params[present_filter_id]';
17+
static const String assetsCheckSum =
18+
'params[${SessionIdentifierKeys.assetsCheckSum}]';
19+
static const String context = 'params[context]';
20+
static const String commentFormUID =
21+
'params[${SessionIdentifierKeys.commentFormUID}]';
22+
static const String blogCommentFormUID =
23+
'params[${SessionIdentifierKeys.blogCommentFormUID}]';
24+
static const String signedParameters = SessionIdentifierKeys.signedParameters;
25+
}
26+
27+
class FeedDataVelues {
28+
static const String y = 'Y';
29+
static const String n = 'N';
30+
static const String bitrix24 = 'bitrix24';
31+
}

lib/core/constants/api/path.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@ class ApiPath {
111111

112112
/// Для отправки файла в чате
113113
static const String fileCommit = 'rest/im.disk.file.commit.json';
114+
115+
/// Для получения аутентификационных параметров
116+
static const String stream = 'stream/';
114117
}

lib/core/constants/date_pattern.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ class DatePattern {
1212
static const hhmm = 'HH:mm';
1313
static const dMMMM = 'd MMMM';
1414
static const e = 'E';
15+
static const dmmmmyyyyhhmm = 'd MMMM yyyy HH:mm';
16+
static const dmmmmhhmmyyyy = 'd MMMM HH:mm yyyy';
1517
}

lib/core/constants/regular_expressions.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class _RegularExpressionSource {
1616
static const distanceCourseSemester =
1717
r'selectedYear == (\d{4}) && selectedSemester == (\d)';
1818
static const upperCaseLetters = r'[A-Z]';
19+
20+
static const sonetLAssetsCheckSum = r"sonetLAssetsCheckSum:\s*'([^']+)'";
21+
static const signedParameters = r"signedParameters:\s*'([^']+)'";
22+
static const commentFormUID = r"commentFormUID:\s*'([^']+)'";
23+
static const blogCommentFormUID = r"blogCommentFormUID:\s*'([^']+)'";
1924
}
2025

2126
class RegularExpressions {
@@ -58,4 +63,28 @@ class RegularExpressions {
5863
static final uppercaseLettersRegExp = RegExp(
5964
_RegularExpressionSource.upperCaseLetters,
6065
);
66+
67+
static final sonetLAssetsCheckSumRegExp = RegExp(
68+
_RegularExpressionSource.sonetLAssetsCheckSum,
69+
multiLine: true,
70+
caseSensitive: false,
71+
);
72+
73+
static final signedParametersRegExp = RegExp(
74+
_RegularExpressionSource.signedParameters,
75+
multiLine: true,
76+
caseSensitive: false,
77+
);
78+
79+
static final commentFormUIDRegExp = RegExp(
80+
_RegularExpressionSource.commentFormUID,
81+
multiLine: true,
82+
caseSensitive: false,
83+
);
84+
85+
static final blogCommentFormUIDRegExp = RegExp(
86+
_RegularExpressionSource.blogCommentFormUID,
87+
multiLine: true,
88+
caseSensitive: false,
89+
);
6190
}

lib/core/constants/string_keys/session_identifier_keys.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ class SessionIdentifierKeys {
77
static const String csrf = 'csrf';
88
static const String newCsrf = 'X-Bitrix-New-Csrf';
99
static const String csrfToken = 'X-Bitrix-Csrf-Token';
10+
11+
static const String assetsCheckSum = 'assetsCheckSum';
12+
static const String signedParameters = 'signedParameters';
13+
static const String commentFormUID = 'commentFormUID';
14+
static const String blogCommentFormUID = 'blogCommentFormUID';
1015
}

lib/core/misc/date_time_utilities/date_time_parser.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import 'package:intl/intl.dart';
55

66
class DateTimeParser {
7-
static DateTime parse(String input, String pattern) {
8-
final formatter = DateFormat(pattern);
7+
static DateTime parse(
8+
String input,
9+
String pattern, {
10+
String local = 'ru_RU',
11+
}) {
12+
final formatter = DateFormat(pattern, local);
913
return formatter.parse(input);
1014
}
1115
}

lib/core/misc/file_helpers/size_converter.dart

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum SizeUnit {
1111
}
1212

1313
extension UnitNames on SizeUnit {
14-
String getUnitString() {
14+
String getUnitStringRu() {
1515
switch (this) {
1616
case SizeUnit.byte:
1717
return 'Б';
@@ -23,11 +23,28 @@ extension UnitNames on SizeUnit {
2323
return 'ГБ';
2424
}
2525
}
26+
27+
String getUnitStringEn() {
28+
switch (this) {
29+
case SizeUnit.byte:
30+
return 'B';
31+
case SizeUnit.kilobyte:
32+
return 'KB';
33+
case SizeUnit.megabyte:
34+
return 'MB';
35+
case SizeUnit.gigabyte:
36+
return 'GB';
37+
}
38+
}
39+
40+
List<String> getAllUnitVariants() => [getUnitStringRu(), getUnitStringEn()];
2641
}
2742

2843
class SizeConverter {
2944
static const int _base = 10;
30-
final Map<SizeUnit?, num> _coefficients = {
45+
static final String _allUnits =
46+
SizeUnit.values.expand((unit) => unit.getAllUnitVariants()).join('|');
47+
static final Map<SizeUnit?, num> _coefficients = {
3148
SizeUnit.byte: pow(_base, 0),
3249
SizeUnit.kilobyte: pow(_base, 3),
3350
SizeUnit.megabyte: pow(_base, 6),
@@ -39,6 +56,40 @@ class SizeConverter {
3956
/// Возвращает единицы измерения, используемые в последней операции
4057
SizeUnit? get lastUsedUnit => _lastUsedUnit;
4158

59+
/// Парсит строку с размером файла (например, "1.5 ГБ", "100 КБ", "2.3 TB")
60+
/// и возвращает размер в байтах.
61+
///
62+
/// Поддерживает русские (Б, КБ, МБ, ГБ) и латинские (B, KB, MB, GB) обозначения,
63+
/// а также запятую или точку в качестве десятичного разделителя.
64+
static int parseFileSize(String sizeText) {
65+
final pattern = '([\\d.,]+)\\s*($_allUnits)';
66+
67+
final regex = RegExp(
68+
pattern,
69+
caseSensitive: false,
70+
);
71+
72+
final match = regex.firstMatch(sizeText);
73+
if (match == null) {
74+
return 0;
75+
}
76+
77+
final value =
78+
double.tryParse(match.group(1)?.replaceAll(',', '.') ?? '0') ?? 0;
79+
80+
final unit = match.group(2)?.toUpperCase() ?? 'Б';
81+
82+
for (final sizeUnit in SizeUnit.values) {
83+
if (sizeUnit.getAllUnitVariants().any(
84+
(u) => u.toUpperCase() == unit,
85+
)) {
86+
return (value * _coefficients[sizeUnit]!).toInt();
87+
}
88+
}
89+
90+
return value.toInt();
91+
}
92+
4293
/// Преобразует байты в указанные единицы измерения или в наибольшие единицы, в которых целая часть числа не равна 0.
4394
///
4495
/// [bytes] - кол-во байтов

0 commit comments

Comments
 (0)