Skip to content

Commit

Permalink
feat: setting modal
Browse files Browse the repository at this point in the history
  • Loading branch information
sukinosuki committed Sep 7, 2024
1 parent 0119b27 commit e013d40
Show file tree
Hide file tree
Showing 82 changed files with 1,258 additions and 1,569 deletions.
Binary file removed assets/images/card_placeholder.webp
Binary file not shown.
31 changes: 17 additions & 14 deletions lib/http/ArticleApi.dart → lib/api/ArticleApi.dart
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
import 'package:duel_links_meta/http/http.dart';
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/Article.dart';
import 'package:get/get.dart';

class ArticleApi extends Net {
Future<Response<List<Article>>> articleList(Map<String, String> _params) {
final params = <String, dynamic>{};
params['limit'] = _params['limit'] ?? '8';
params['page'] = _params['page'];
class ArticleApi {
factory ArticleApi() {
return _instance;
}

ArticleApi._constructor();

params['field'] = '-markdown';
params['sort'] = '-featured,-date';
params[r'hidden[$ne]'] = 'true';
params[r'category[$ne]'] = 'quick-news';
static final _instance = ArticleApi._constructor();

return httpClient.get('/api/v1/articles', query: params, decoder: (data) => (data as List<dynamic>).map(Article.fromJson).toList());
Future<Response<List<Article>>> articleList(Map<String, String> params) {
return http.get(
'/api/v1/articles',
query: params,
decoder: (data) => (data as List<dynamic>).map(Article.fromJson).toList(),
);
}

Future<Response<List<Article>>> activeEventLst(DateTime countdownDate) {
return httpClient.get(
return http.get(
'/api/v1/articles?category=event&countdownDate[\$gte]=$countdownDate&sort=-date&hidden[\$ne]=true&limit=10',
decoder: (data) => (data as List<dynamic>).map(Article.fromJson).toList(),
);
}

Future<Response<List<Article>>> pastEventLst(DateTime countdownDate, int page) {
return httpClient.get(
return http.get(
'/api/v1/articles?category=event&countdownDate[\$lt]=$countdownDate&sort=-date&hidden[\$ne]=true&limit=10&page=$page',
decoder: (data) => (data as List<dynamic>).map(Article.fromJson).toList(),
);
}

Future<Response<List<Article>>> pinnedFarmingEvent() {
return httpClient.get(
return http.get(
r'/api/v1/articles?category=farming&subCategory=pinned&sort=-date&hidden[$ne]=true',
decoder: (data) => (data as List<dynamic>).map(Article.fromJson).toList(),
);
Expand Down
14 changes: 11 additions & 3 deletions lib/http/BanListChangeApi.dart → lib/api/BanListChangeApi.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import 'package:duel_links_meta/http/http.dart';
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/ban_list_change/BanListChange.dart';
import 'package:get/get_connect/http/src/response/response.dart';

class BanListChangeApi extends Net {
Future<Response<List<BanListChange>>> list({Map<String, String>? params}) => httpClient.get(
class BanListChangeApi {
factory BanListChangeApi() {
return _instance;
}

BanListChangeApi._constructor();

static final _instance = BanListChangeApi._constructor();

Future<Response<List<BanListChange>>> list({Map<String, String>? params}) => http.get(
'/api/v1/banlist-changes',
query: params,
decoder: (data) => (data as List<dynamic>).map(BanListChange.fromJson).toList(),
Expand Down
20 changes: 14 additions & 6 deletions lib/http/CardApi.dart → lib/api/CardApi.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
import 'package:duel_links_meta/http/http.dart';
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/MdCard.dart';
import 'package:get/get.dart';

class CardApi extends Net {
Future<Response<List<MdCard>>> getByIds(String ids) => httpClient.get(
class CardApi {
factory CardApi() {
return _instance;
}

CardApi._constructor();

static final _instance = CardApi._constructor();

Future<Response<List<MdCard>>> getByIds(String ids) => http.get(
'/api/v1/cards?_id[\$in]=$ids',
decoder: (data) => (data as List<dynamic>).map(MdCard.fromJson).toList(),
);

Future<Response<MdCard>> getById(String id) => httpClient.get(
Future<Response<MdCard>> getById(String id) => http.get(
'/api/v1/cards?_id[\$in]=$id&limit=1',
decoder: MdCard.fromJson,
);

Future<Response<List<MdCard>>> getByObtainSource(String sourceId) => httpClient.get(
Future<Response<List<MdCard>>> getByObtainSource(String sourceId) => http.get(
'/api/v1/cards?obtain.source=$sourceId&sort=-rarity&limit=0',
decoder: (data) => (data as List<dynamic>).map(MdCard.fromJson).toList(),
);

Future<Response<List<MdCard>>> list(Map<String, String>? params) => httpClient.get(
Future<Response<List<MdCard>>> list(Map<String, String>? params) => http.get(
'/api/v1/cards',
query: params,
decoder: (data) => (data as List<dynamic>).map(MdCard.fromJson).toList(),
Expand Down
15 changes: 15 additions & 0 deletions lib/api/CharacterApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:get/get.dart';

import 'http.dart';

class CharacterApi {

factory CharacterApi() {
return _instance;
}
CharacterApi._constructor();

static final _instance = CharacterApi._constructor();

Future<Response<List>> list() => http.get('/api/v1/characters?npc[\$ne]=true&limit=0&sort=-linkedArticle.date');
}
17 changes: 17 additions & 0 deletions lib/api/DeckTypeApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:duel_links_meta/type/deck_type/DeckType.dart';
import 'package:get/get_connect/http/src/response/response.dart';

import 'package:duel_links_meta/api/http.dart';

class DeckTypeApi{
factory DeckTypeApi() {
return _instance;
}

DeckTypeApi._constructor();

static final _instance = DeckTypeApi._constructor();

Future<Response<DeckType>> getDetailByName(String name) =>
http.get('/api/v1/deck-types?name=$name&limit=1&aggregate=aboveThresh', decoder: DeckType.fromJson);
}
6 changes: 3 additions & 3 deletions lib/http/NavTabApi.dart → lib/api/NavTabApi.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:duel_links_meta/http/http.dart';
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/NavTab.dart';
import 'package:get/get.dart';

class NavTabApi extends Net {
class NavTabApi{
factory NavTabApi() {
return _instance;
}
Expand All @@ -11,7 +11,7 @@ class NavTabApi extends Net {

static final NavTabApi _instance = NavTabApi._privateConstructor();

Future<Response<List<NavTab>>> list() => httpClient.get(
Future<Response<List<NavTab>>> list() => http.get(
'/api/v1/nav-tabs',
decoder: (data) => (data as List<dynamic>).map(NavTab.fromJson).toList(),
);
Expand Down
13 changes: 10 additions & 3 deletions lib/http/PackSetApi.dart → lib/api/PackSetApi.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import 'package:duel_links_meta/http/http.dart';
import 'package:duel_links_meta/type/pack_set/PackSet.dart';
import 'package:get/get.dart';

class PackSetApi extends Net {
Future<Response<List<PackSet>>> list() => httpClient.get(
import 'http.dart';

class PackSetApi {
factory PackSetApi(){
return _instance;
}
PackSetApi._constructor();
static final _instance = PackSetApi._constructor();

Future<Response<List<PackSet>>> list() => http.get(
'/api/v1/sets?sort=-release&limit=0',
decoder: (data) => (data as List<dynamic>).map(PackSet.fromJson).toList(),
);
Expand Down
21 changes: 21 additions & 0 deletions lib/api/SkillApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/skill/Skill.dart';
import 'package:get/get_connect/http/src/response/response.dart';

class SkillApi {
factory SkillApi() {
return _instance;
}

SkillApi._constructor();

static final _instance = SkillApi._constructor();

Future<Response<Skill>> getByName(String name) => http.get(
'/api/v1/skills?name[\$in]=$name&limit=1',
decoder: Skill.fromJson,
);

Future<Response<List<dynamic>>> getByCharacterId(String characterId) =>
http.get('/api/v1/skills?characters.character[\$or]=$characterId&archive[\$or]=true&rush[\$ne]=true&sort=name');
}
14 changes: 14 additions & 0 deletions lib/api/SkillStatsApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:duel_links_meta/api/http.dart';
import 'package:get/get_connect/connect.dart';

class SkillStatsApi {
factory SkillStatsApi() {
return _instance;
}

SkillStatsApi._constructor();

static final _instance = SkillStatsApi._constructor();

Future<Response<List<dynamic>>> getByName(String name) => http.get('/api/v1/skills/stats?name=$name');
}
29 changes: 29 additions & 0 deletions lib/api/TierListApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/deck_type/TierList_PowerRanking.dart';
import 'package:duel_links_meta/type/tier_list_top_tier/TierList_TopTier.dart';
import 'package:get/get_connect/http/src/response/response.dart';

class TierListApi {
factory TierListApi() {
return _instance;
}

TierListApi._constructor();

static final TierListApi _instance = TierListApi._constructor();

Future<Response<List<TierList_TopTier>>> getTopTiers() => http.get(
r'/api/v1/deck-types?tier[$in]=0,1,2,3,4&limit=0&sort=name&fields=name,tier',
decoder: (data) => (data as List<dynamic>).map(TierList_TopTier.fromJson).toList(),
);

Future<Response<List<TierList_PowerRanking>>> getPowerRankings() => http.get(
r'/api/v1/deck-types?rush[$ne]=true&tournamentPower[$gte]=6&limit=0&sort=-tournamentPower&fields=name,tournamentPower,tournamentPowerTrend',
decoder: (data) => (data as List<dynamic>).map(TierList_PowerRanking.fromJson).toList(),
);

Future<Response<List<TierList_PowerRanking>>> getRushRankings() => http.get(
r'/api/v1/deck-types?rush=true&tournamentPower[$gte]=6&limit=0&sort=-tournamentPower&fields=name,tournamentPower,tournamentPowerTrend,rush',
decoder: (data) => (data as List<dynamic>).map(TierList_PowerRanking.fromJson).toList(),
);
}
24 changes: 24 additions & 0 deletions lib/api/TopDeckApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:duel_links_meta/api/http.dart';
import 'package:duel_links_meta/type/top_deck/TopDeck.dart';
import 'package:get/get_connect/http/src/response/response.dart';

class TopDeckApi {
factory TopDeckApi() {
return _instance;
}

TopDeckApi._constructor();

static final _instance = TopDeckApi._constructor();

Future<Response<TopDeck>> getBreakdownSample(Map<String, String> params) =>
http.get('/api/v1/top-decks', query: params, decoder: TopDeck.fromJson);

Future<Response<List<TopDeck>>> list(Map<String, dynamic> params) => http.get(
'/api/v1/top-decks',
query: params,
decoder: (data) {
return (data as List<dynamic>).map(TopDeck.fromJson).toList();
},
);
}
15 changes: 15 additions & 0 deletions lib/api/WorldApi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:get/get.dart';

import 'http.dart';

class WorldApi {
factory WorldApi() {
return _instance;
}

WorldApi._constructor();

static final _instance = WorldApi._constructor();

Future<Response<List<dynamic>>> list() => http.get('/api/v1/worlds');
}
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/components/MdCardItemView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class _MdCardItemViewState extends State<MdCardItemView> {
Stack(
children: [
CachedNetworkImage(
placeholder: (context, url) => Image.asset('assets/images/card_placeholder.webp'),
errorWidget: (context, url, err) => Image.asset('assets/images/card_placeholder.webp'),
// placeholder: (context, url) => Image.asset('assets/images/card_placeholder.webp'),
// errorWidget: (context, url, err) => Image.asset('assets/images/card_placeholder.webp'),
fadeInDuration: const Duration(milliseconds: 0),
fadeOutDuration: null,
imageUrl: 'https://s3.duellinksmeta.com/cards/${mdCard.oid}_w100.webp'),
Expand Down
3 changes: 1 addition & 2 deletions lib/components/MdCardItemView2.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:duel_links_meta/api/CardApi.dart';
import 'package:duel_links_meta/extension/Future.dart';
import 'package:duel_links_meta/gen/assets.gen.dart';
import 'package:duel_links_meta/hive/MyHive.dart';
import 'package:duel_links_meta/hive/db/CardHiveDb.dart';
import 'package:duel_links_meta/http/CardApi.dart';
import 'package:duel_links_meta/store/BanCardStore.dart';
import 'package:duel_links_meta/type/MdCard.dart';
import 'package:flutter/material.dart';
Expand Down
24 changes: 15 additions & 9 deletions lib/components/MdCardsBoxLayout.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';

import '../constant/colors.dart';

class MdCardsBoxLayout extends StatelessWidget {
const MdCardsBoxLayout({super.key, this.child});

Expand All @@ -10,13 +8,21 @@ class MdCardsBoxLayout extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(left: 8, right: 8, top: 8, bottom: 0),
decoration: BoxDecoration(
// color: BaColors.theme,
border: Border.all(color: const Color(0xff385979), width: 1),
borderRadius: const BorderRadius.all(Radius.circular(4)),
image: const DecorationImage(image: AssetImage('assets/images/modal_bg.webp'), fit: BoxFit.fitWidth),
padding: const EdgeInsets.only(
left: 8,
right: 8,
top: 8,
bottom: 0,
),
decoration: BoxDecoration(
border: Border.all(
color: const Color(0xff385979),
width: 1,
),
child: child);
borderRadius: const BorderRadius.all(Radius.circular(4)),
image: const DecorationImage(image: AssetImage('assets/images/modal_bg.webp'), fit: BoxFit.fitWidth),
),
child: child,
);
}
}
34 changes: 34 additions & 0 deletions lib/components/ModalBottomSheetWrap.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';

class ModalBottomSheetWrap extends StatelessWidget {
const ModalBottomSheetWrap({required this.child, super.key});

final Widget child;

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(34),
topRight: Radius.circular(34),
),
),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(24)),
child: ColoredBox(
color: Theme.of(context).colorScheme.onPrimary,
child: SingleChildScrollView(
child: Column(
children: [
child,
],
),
),
),
),
);
}
}
Loading

0 comments on commit e013d40

Please sign in to comment.