Skip to content

Commit

Permalink
feat: hive db
Browse files Browse the repository at this point in the history
  • Loading branch information
sukinosuki committed Sep 5, 2024
1 parent ac1622f commit 0119b27
Show file tree
Hide file tree
Showing 56 changed files with 1,488 additions and 1,772 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
with:
allowUpdates: true
artifacts: "releases/*-release.apk"
tag: 1.0
tag: ${{ github.event.inputs.TAG }}
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# duel_links_meta
# Duel links meta app

A new Flutter project.
## Futures

## Getting Started
- Tier List Page
- Deck Type Detail Page
- Top Deck page
- Deck detail page
- Ban list change page
- Ban list cards page
- Article list page
- Pack set list page
- Pack set detail page
- Data local cache for fast viewing and reduce the api fetching

This project is a starting point for a Flutter application.
## Download 下载

A few resources to get you started if this is your first Flutter project:
[从github下载](https://github.com/sukinosuki/duel-links-meta-flutter-app/releases)

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
## Stars

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
If this project is helpful to you, please consider giving a star for support.

如果本项目对你有帮助的话, 可以`star`支持一下.

## Data source

The app utilizes the following resources from [Duel Links Meta](https://www.duellinksmeta.com):

- **APIs**: The app integrates with Duel Links Meta's APIs to fetch deck lists, card details, and other game-related data.
- **Images**: Card images and other graphics used in the app are sourced directly from Duel Links Meta.

4 changes: 2 additions & 2 deletions lib/components/MdCardItemView2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class _MdCardItemViewState extends State<MdCardItemView2> {
Future<void> init() async {
if (widget.mdCard != null && widget.mdCard?.type != '') return;

var card = await CardHiveDb.get(cardId);
var card = await CardHiveDb().get(cardId);

if (card == null) {
final (err, res) = await CardApi().getById(cardId).toCatch;
if (err != null || res == null) return;

card = res;
await CardHiveDb.setCard(card);
await CardHiveDb().set(card);
}

setState(() {
Expand Down
186 changes: 186 additions & 0 deletions lib/components/SettingModalView.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import 'package:duel_links_meta/hive/MyHive.dart';
import 'package:duel_links_meta/hive/db/DarkModeHiveDb.dart';
import 'package:duel_links_meta/pages/open_source_licenses/index.dart';
import 'package:duel_links_meta/store/AppStore.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';

class SettingModalView extends StatefulWidget {
const SettingModalView({super.key});

@override
State<SettingModalView> createState() => _SettingModalViewState();
}

class _SettingModalViewState extends State<SettingModalView> {
AppStore appStore = Get.put(AppStore());

PackageInfo? get packageInfo => appStore.packageInfo;

String repos = 'https://github.com/sukinosuki/duel-links-meta-flutter-app';
String duelLinksMetaUrl = 'https://www.duellinksmeta.com';

String githubHash = '';

void init() {
githubHash = const String.fromEnvironment('GITHUB_HASH');
}

@override
void initState() {
super.initState();

init();
}

@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
child: Container(
padding: const EdgeInsets.only(top: 30),
color: Theme.of(context).colorScheme.onPrimary,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: Text(
'Setting',
style: TextStyle(fontSize: 24),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Padding(
padding: EdgeInsets.only(left: 6),
child: Text('Theme mode'),
),
Row(
children: [
IconButton(
isSelected: !Get.isDarkMode,
onPressed: () {
Get.changeThemeMode(ThemeMode.light);
DarkModeHiveDb().set(ThemeMode.light);
},

icon: const Icon(Icons.sunny),
),
IconButton(
isSelected: Get.isDarkMode,
onPressed: () {
Get.changeThemeMode(ThemeMode.dark);
DarkModeHiveDb().set(ThemeMode.dark);
},
icon: const Icon(Icons.nightlight_rounded),
),
],
),
],
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
child: Text(
'About',
style: TextStyle(fontSize: 24),
),
),
Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('App version'),
Text(packageInfo?.version ?? ''),
],
),
),
Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Commit ID'),
Text(githubHash),
],
),
),
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
final uri = Uri.parse(repos);
launchUrl(uri).ignore();
},
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Github'),
Icon(Icons.arrow_forward, color: Theme.of(context).iconTheme.color?.withOpacity(0.6)),
],
),
),
),
),
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute<void>(builder: (context) => const OpenSourceLicensePage()));
},
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Open source licenses'),
Icon(Icons.arrow_forward, color: Theme.of(context).iconTheme.color?.withOpacity(0.6),),
],
),
),
),
),
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
final uri = Uri.parse(duelLinksMetaUrl);
launchUrl(uri).ignore();
},
child: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Duel Link Meta'),
Icon(Icons.arrow_forward, color: Theme.of(context).iconTheme.color?.withOpacity(0.6),),
],
),
),
),
),
],
),
),
),
);
}
}
Loading

0 comments on commit 0119b27

Please sign in to comment.