Skip to content

Commit

Permalink
Merge pull request #337 from mirea-ninja/release/v1.3.5
Browse files Browse the repository at this point in the history
Release/v1.3.5
  • Loading branch information
0niel authored Sep 14, 2023
2 parents cf66635 + 680dc3c commit d45ae9f
Show file tree
Hide file tree
Showing 30 changed files with 300 additions and 266 deletions.
27 changes: 22 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Custom
.fvm/
# Do not remove or rename entries in this file, only add new ones
# See https://github.com/flutter/flutter/issues/128635 for more context.

# Miscellaneous
*.class
Expand All @@ -23,7 +23,7 @@
.classpath
.project
.settings/
.vscode/
.vscode/*

# Flutter repo-specific
/bin/cache/
Expand All @@ -35,6 +35,7 @@
/dev/bots/android_tools/
/dev/devicelab/ABresults*.json
/dev/docs/doc/
/dev/docs/api_docs.zip
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
Expand All @@ -54,6 +55,7 @@ analysis_benchmark.json
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-preload-cache/
.pub-cache/
.pub/
build/
Expand All @@ -64,7 +66,7 @@ unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
.gradle/
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
Expand Down Expand Up @@ -104,7 +106,21 @@ unlinked_spec.ds
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/xcuserdata/

# Windows
**/windows/flutter/generated_plugin_registrant.cc
**/windows/flutter/generated_plugin_registrant.h
**/windows/flutter/generated_plugins.cmake

# Linux
**/linux/flutter/generated_plugin_registrant.cc
**/linux/flutter/generated_plugin_registrant.h
**/linux/flutter/generated_plugins.cmake

# Coverage
coverage/
Expand All @@ -118,4 +134,5 @@ app.*.symbols
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!/dev/ci/**/Gemfile.lock
!.vscode/settings.json
30 changes: 28 additions & 2 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: adc687823a831bbebe28bdccfac1a628ca621513
revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: linux
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: macos
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: windows
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
Expand All @@ -28,6 +28,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
6 changes: 3 additions & 3 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Sat Feb 18 16:22:23 MSK 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
42 changes: 26 additions & 16 deletions lib/data/datasources/news_remote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,60 @@ import 'package:rtu_mirea_app/common/errors/exceptions.dart';
import 'package:rtu_mirea_app/data/models/news_item_model.dart';

abstract class NewsRemoteData {
Future<List<NewsItemModel>> getNews(int offset, int limit, bool isImportant,
Future<List<NewsItemModel>> getNews(int page, int pageSize, bool isImportant,
[String? tag]);
Future<List<String>> getTags();
}

class NewsRemoteDataImpl extends NewsRemoteData {
static const _apiUrl = "https://cms.mirea.ninja/api";
// Доступны методы: getNews, getEvents, getAds.
static const _apiUrl = "https://mirea.ru/api/oCoGUGuMhQzPEDJYF6Qy.php";

final Dio httpClient;

NewsRemoteDataImpl({required this.httpClient});

@override
Future<List<NewsItemModel>> getNews(int offset, int limit, bool isImportant,
Future<List<NewsItemModel>> getNews(int page, int pageSize, bool isImportant,
[String? tag]) async {
final String tagsFilter =
tag != null ? "&filters[tags][name][\$eq]=$tag" : "";
final String requestUrl =
'$_apiUrl/announcements?populate=*&pagination[limit]=$limit&pagination[start]=$offset&sort=date:DESC&filters[isImportant][\$eq]=${isImportant.toString()}$tagsFilter';
String params =
'nPageSize=$pageSize&iNumPage=$page${tag != null ? "&tag=$tag" : ""}';

final response = await httpClient.get(requestUrl);
Response response;
if (!isImportant) {
response = await httpClient.get('$_apiUrl?method=getNews&$params');
} else {
response = await httpClient.get('$_apiUrl?method=getAds&$params');
}

if (response.statusCode == 200) {
Map responseBody = response.data;
return responseBody["data"]
.map<NewsItemModel>(
(newsItem) => NewsItemModel.fromJson(newsItem["attributes"]))

List<NewsItemModel> news = responseBody["result"]
.map<NewsItemModel>((newsItem) => NewsItemModel.fromJson(newsItem))
.toList();

return news;
} else {
throw ServerException('Response status code is $response.statusCode');
}
}

@override
Future<List<String>> getTags() async {
final response = await httpClient.get('$_apiUrl/tags');
final response = await httpClient.get('$_apiUrl?method=getNewsTags');

if (response.statusCode == 200) {
Map responseBody = response.data;

List<String> tags = [];
tags = List<String>.from(
responseBody["data"].map((x) => x['attributes']['name']));
return tags;
final tagsResponse =
responseBody["result"].map((e) => e as Map<String, dynamic>);

final tags = tagsResponse
.where((element) => int.parse(element["CNT"]) > 3)
.map((e) => e["NAME"]!);

return tags.toList().cast<String>();
} else {
throw ServerException('Response status code is $response.statusCode');
}
Expand Down
20 changes: 8 additions & 12 deletions lib/data/models/news_item_model.dart
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
import 'package:intl/intl.dart';
import 'package:rtu_mirea_app/domain/entities/news_item.dart';

import 'strapi_media_model.dart';

class NewsItemModel extends NewsItem {
const NewsItemModel({
required title,
required text,
required date,
required images,
required tags,
required isImportant,
}) : super(
title: title,
text: text,
date: date,
images: images,
tags: tags,
isImportant: isImportant,
);

factory NewsItemModel.fromJson(Map<String, dynamic> json) {
return NewsItemModel(
title: json['title'],
text: json['text'],
date: DateTime.parse(json['date']),
images: List<StrapiMediaModel>.from(json["images"]["data"]
.map((x) => StrapiMediaModel.fromJson(x["attributes"]))),
title: json['NAME'],
text: json['DETAIL_TEXT'],
date: DateFormat("dd.MM.yyyy").parse(json['DATE_ACTIVE_FROM']),
images: List<String>.from(json['PROPERTY_MY_GALLERY_VALUE'] ?? [])
..add(json['DETAIL_PICTURE']),
tags: List<String>.from(
json["tags"]["data"].map((x) => x["attributes"]['name'])),
isImportant: json['isImportant'],
json['TAGS'].toString().split(',').map((x) => x.trim())),
);
}

@override
List<Object?> get props => [title, text, date, images, tags, isImportant];
List<Object?> get props => [title, text, date, images, tags];
}
4 changes: 2 additions & 2 deletions lib/data/repositories/news_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class NewsRepositoryImpl implements NewsRepository {

@override
Future<Either<Failure, List<NewsItem>>> getNews(
int offset, int limit, bool isImportant,
int page, int pageSize, bool isImportant,
[String? tag]) async {
if (await connectionChecker.hasConnection) {
try {
final newsList =
await remoteDataSource.getNews(offset, limit, isImportant, tag);
await remoteDataSource.getNews(page, pageSize, isImportant, tag);
return Right(newsList);
} on ServerException {
return const Left(ServerFailure());
Expand Down
7 changes: 2 additions & 5 deletions lib/domain/entities/news_item.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import 'package:equatable/equatable.dart';
import 'package:rtu_mirea_app/domain/entities/strapi_media.dart';

class NewsItem extends Equatable {
final String title;
final String text;
final DateTime date;
final List<StrapiMedia> images;
final List<String> images;
final List<String> tags;
final bool isImportant;

const NewsItem({
required this.title,
required this.text,
required this.date,
required this.images,
required this.tags,
required this.isImportant,
});

@override
List<Object?> get props => [title, text, date, images, tags, isImportant];
List<Object?> get props => [title, text, date, images, tags];
}
2 changes: 1 addition & 1 deletion lib/domain/repositories/news_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import 'package:rtu_mirea_app/domain/entities/news_item.dart';

abstract class NewsRepository {
Future<Either<Failure, List<NewsItem>>> getNews(
int offset, int limit, bool isImportant, String? tag);
int page, int pageSize, bool isImportant, String? tag);
Future<Either<Failure, List<String>>> getTags();
}
12 changes: 6 additions & 6 deletions lib/domain/usecases/get_news.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ class GetNews extends UseCase<List<NewsItem>, GetNewsParams> {
@override
Future<Either<Failure, List<NewsItem>>> call(GetNewsParams params) async {
return await newsRepository.getNews(
params.offset, params.limit, params.isImportant, params.tag);
params.page, params.pageSize, params.isImportant, params.tag);
}
}

class GetNewsParams extends Equatable {
final int offset;
final int limit;
final int page;
final int pageSize;
final bool isImportant;
final String? tag;

const GetNewsParams({
required this.offset,
required this.limit,
required this.page,
required this.pageSize,
required this.isImportant,
this.tag,
});

@override
List<Object?> get props => [offset, limit, isImportant, tag];
List<Object?> get props => [page, pageSize, isImportant, tag];
}
Loading

0 comments on commit d45ae9f

Please sign in to comment.