Skip to content

Commit

Permalink
대회 탭 수정 및 기능 개선 (리팩터링 휴게소) (#46)
Browse files Browse the repository at this point in the history
* fix: flutter_svg 버전 올리고 기도

* feat: 예정된 대회만 알람 설정

* feat: color_extension 티어 색상 추가

* feat: Grass 스킴 변경
`topic` 추가

* feat: 서포터 전용 티어 스트릭 지원

* v1.1.5+57

* fix: 진행중인 대회 리스트 수정

* v1.1.5+58

* fix: CI flutter 버전 업그레이드

* v1.1.6+59
대회탭 null 에러 수정
  • Loading branch information
w8385 authored Sep 19, 2023
1 parent 169afca commit dc8f77a
Show file tree
Hide file tree
Showing 21 changed files with 351 additions and 192 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flutter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- main
env:
JAVA_VERSION: "12.x"
FLUTTER_VERSION: "3.7"
FLUTTER_VERSION: "3.13.3"
jobs:
analyze:
name: Analyze Flutter 🔍
Expand All @@ -32,7 +32,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: "3.7"
flutter-version: "3.13.3"
- name: Analyze
run: |
cd my_solved
Expand Down
5 changes: 3 additions & 2 deletions my_solved/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:label="my_solved"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down Expand Up @@ -49,5 +51,4 @@
android:exported="true"
android:stopWithTask="false" />
</application>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
</manifest>
2 changes: 1 addition & 1 deletion my_solved/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
18 changes: 9 additions & 9 deletions my_solved/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ DEPENDENCIES:
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_timezone (from `.symlinks/plugins/flutter_native_timezone/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
Expand All @@ -45,9 +45,9 @@ EXTERNAL SOURCES:
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios"
:path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/ios"
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

Expand All @@ -56,12 +56,12 @@ SPEC CHECKSUMS:
flutter_app_badger: b87fc231847b03b92ce1412aa351842e7e97932f
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_timezone: 5f05b2de06c9776b4cc70e1839f03de178394d22
fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
7 changes: 5 additions & 2 deletions my_solved/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -157,7 +157,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -201,10 +201,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -237,6 +239,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Binary file removed my_solved/lib/assets/venues/Codeforces_logo.svg.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
34 changes: 34 additions & 0 deletions my_solved/lib/extensions/color_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,38 @@ extension CupertinoThemeDataExtension on CupertinoThemeData {
Color(0xff0479C7),
],
};

Map<int, Color> get tier => {
0: Color(0xff2d2d2d),
1: Color(0xff9d4900),
2: Color(0xffa54f00),
3: Color(0xffad5600),
4: Color(0xffb55d0a),
5: Color(0xffc67739),
6: Color(0xff38546e),
7: Color(0xff3d5a74),
8: Color(0xff435f7a),
9: Color(0xff496580),
10: Color(0xff4e6a86),
11: Color(0xffd28500),
12: Color(0xffdf8f00),
13: Color(0xffec9a00),
14: Color(0xfff9a518),
15: Color(0xffffb028),
16: Color(0xff00c78b),
17: Color(0xff00d497),
18: Color(0xff27e2a4),
19: Color(0xff3ef0b1),
20: Color(0xff51fdbd),
21: Color(0xff009ee5),
22: Color(0xff00a9f0),
23: Color(0xff00b4fc),
24: Color(0xff2bbfff),
25: Color(0xff41caff),
26: Color(0xffe0004c),
27: Color(0xffea0053),
28: Color(0xfff5005a),
29: Color(0xffff0062),
30: Color(0xffff3071),
};
}
2 changes: 1 addition & 1 deletion my_solved/lib/models/contest.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:html/dom.dart';

class Contest {
final String venue;
final String? venue;
final String name;
final String? url;
final DateTime startTime;
Expand Down
2 changes: 2 additions & 0 deletions my_solved/lib/models/streak_date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class StreakDate {
final int year;
final int weekDay;
final int solvedCount;
final bool isSolved;
final bool isFuture;
final bool isFrozen;
final bool isRepaired;
Expand All @@ -14,6 +15,7 @@ class StreakDate {
required this.year,
required this.weekDay,
required this.solvedCount,
required this.isSolved,
required this.isFuture,
required this.isFrozen,
required this.isRepaired});
Expand Down
3 changes: 3 additions & 0 deletions my_solved/lib/models/user/grass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ class Grass {
final dynamic theme;
final int currentStreak;
final int longestStreak;
final String topic;

const Grass({
required this.grass,
required this.theme,
required this.currentStreak,
required this.longestStreak,
required this.topic,
});

factory Grass.fromJson(Map<String, dynamic> json) {
Expand All @@ -17,6 +19,7 @@ class Grass {
theme: json['theme'],
currentStreak: json['currentStreak'],
longestStreak: json['longestStreak'],
topic: json['topic'],
);
}
}
45 changes: 30 additions & 15 deletions my_solved/lib/services/network_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class NetworkService {

Future<Grass> requestStreak(String handle) async {
final response = await http.get(Uri.parse(
"https://solved.ac/api/v3/user/grass?handle=$handle&topic=today-solved"));
"https://solved.ac/api/v3/user/grass?handle=$handle&topic=default"));
final statusCode = response.statusCode;

if (statusCode == 200) {
Expand Down Expand Up @@ -127,7 +127,7 @@ class NetworkService {

if (statusCode == 200) {
List<TagRatings> tagRatings =
json.decode(response.body).map<TagRatings>((json) {
json.decode(response.body).map<TagRatings>((json) {
return TagRatings.fromJson(json);
}).toList();
return tagRatings;
Expand All @@ -144,16 +144,16 @@ class NetworkService {

if (statusCode == 200) {
SearchSuggestion search =
SearchSuggestion.fromJson(jsonDecode(response.body));
SearchSuggestion.fromJson(jsonDecode(response.body));
return search;
} else {
throw Exception('Fail to load');
}
}

// 문제 검색
Future<SearchObject> requestSearchProblem(
String query, int? page, String? sort, String? direction) async {
Future<SearchObject> requestSearchProblem(String query, int? page,
String? sort, String? direction) async {
String url = "https://solved.ac/api/v3/search/problem?query=$query";
if (page != null) {
url += "&page=$page";
Expand Down Expand Up @@ -214,7 +214,9 @@ class NetworkService {

Future<List<List<Contest>>> requestContests() async {
List<Contest> upcomingContests(dom.Element element) {
if (element.getElementsByClassName('col-md-12').length < 5) {
if (element
.getElementsByClassName('col-md-12')
.length < 5) {
return element
.getElementsByClassName('col-md-12')[2]
.getElementsByTagName('tbody')
Expand All @@ -238,7 +240,11 @@ class NetworkService {
}

List<Contest> ongoingContests(dom.Element element) {
if (element.getElementsByClassName('col-md-12').length < 5) {
if (element
.getElementsByClassName('col-md-12')
.length < 5) {
return [];
} else {
return element
.getElementsByClassName('col-md-12')[2]
.getElementsByTagName('tbody')
Expand All @@ -248,8 +254,6 @@ class NetworkService {
.map((e) {
return Contest.fromElement(e);
}).toList();
} else {
return [];
}
}

Expand All @@ -273,7 +277,9 @@ class NetworkService {
.replaceAll('일', '')
.split(' ');
DateTime startTime = DateTime.parse(
"${startTimeList[0].padLeft(4, "0")}-${startTimeList[1].padLeft(2, "0")}-${startTimeList[2].padLeft(2, "0")}T${startTimeList[3].padLeft(2, "0")}:00+09:00")
"${startTimeList[0].padLeft(4, "0")}-${startTimeList[1].padLeft(
2, "0")}-${startTimeList[2].padLeft(2, "0")}T${startTimeList[3]
.padLeft(2, "0")}:00+09:00")
.toLocal();
List<String> endTimeList = element
.getElementsByTagName('td')[4]
Expand All @@ -284,27 +290,36 @@ class NetworkService {
.replaceAll('일', '')
.split(' ');
DateTime endTime = DateTime.parse(
"${endTimeList[0].padLeft(4, "0")}-${endTimeList[1].padLeft(2, "0")}-${endTimeList[2].padLeft(2, "0")}T${endTimeList[3].padLeft(2, "0")}:00+09:00")
"${endTimeList[0].padLeft(4, "0")}-${endTimeList[1].padLeft(
2, "0")}-${endTimeList[2].padLeft(2, "0")}T${endTimeList[3]
.padLeft(2, "0")}:00+09:00")
.toLocal();

return Contest(
venue: 'BOJ Open',
name: e.getElementsByTagName('td')[0].text.trim(),
url:
'https://www.acmicpc.net${e.getElementsByTagName('td')[0].getElementsByTagName('a')[0].attributes['href']}',
'https://www.acmicpc.net${e.getElementsByTagName('td')[0]
.getElementsByTagName('a')[0].attributes['href']}',
startTime: startTime,
endTime: endTime,
);
}).toList();
}

final others =
await http.get(Uri.parse("https://www.acmicpc.net/contest/other/list"));
await http.get(Uri.parse("https://www.acmicpc.net/contest/other/list"));
dom.Document docOthers = parser.parse(others.body);
final othersStatus = others.statusCode;

final ended = await http
.get(Uri.parse("https://www.acmicpc.net/contest/official/list"));
dom.Document docEnded = parser.parse(ended.body);
final endedStatus = ended.statusCode;

if (othersStatus != 200 || endedStatus != 200) {
throw Exception('Failed to load');
}

return [
ongoingContests(docOthers.body!),
Expand All @@ -315,7 +330,7 @@ class NetworkService {

Future<Set<int>> requestArenaContests() async {
final response =
await http.get(Uri.parse("https://solved.ac/api/v3/arena/contests"));
await http.get(Uri.parse("https://solved.ac/api/v3/arena/contests"));
final statusCode = response.statusCode;

if (statusCode == 200) {
Expand All @@ -337,7 +352,7 @@ class NetworkService {

Future<SiteStats> requestSiteStats() async {
final response =
await http.get(Uri.parse("https://solved.ac/api/v3/site/stats"));
await http.get(Uri.parse("https://solved.ac/api/v3/site/stats"));
final statusCode = response.statusCode;
debugPrint(response.body);

Expand Down
Loading

0 comments on commit dc8f77a

Please sign in to comment.