Skip to content

Commit

Permalink
aaa
Browse files Browse the repository at this point in the history
  • Loading branch information
顾飞 committed Jan 26, 2023
1 parent 32e3817 commit bca7d3f
Show file tree
Hide file tree
Showing 24 changed files with 321 additions and 282 deletions.
4 changes: 2 additions & 2 deletions lib/app/models/game_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:switch_game/app/data/category_data.dart';
import 'package:switch_game/app/data/game_data.dart';

class GameModel {
static const pageSize = 15;
static List<dynamic> _gameList = [];
static String categoryId2Text(int categoryID) {
List<dynamic> categorys = jsonDecode(categoryData);
Expand All @@ -19,7 +20,7 @@ class GameModel {
return '未知';
}

static int count(int categoryID, String gameName, int pageIndex) {
static int count(int categoryID, String gameName) {
List<GameSchame> list = [];
gameName = gameName.trim();
for (var item in _gameList) {
Expand Down Expand Up @@ -168,7 +169,6 @@ class GameModel {
}

static List<GameSchame> _sublist(List<GameSchame> list, int pageIndex) {
var pageSize = 15;
var startIndex = (pageIndex - 1) * pageSize;
var endIndex = startIndex + pageSize;
if (startIndex >= list.length) {
Expand Down
22 changes: 1 addition & 21 deletions lib/app/pages/archive/controllers/archive_controller.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
import 'package:get/get.dart';

class ArchiveController extends GetxController {
//TODO: Implement ArchiveController

final count = 0.obs;
@override
void onInit() {
super.onInit();
}

@override
void onReady() {
super.onReady();
}

@override
void onClose() {
super.onClose();
}

void increment() => count.value++;
}
class ArchiveController extends GetxController {}
2 changes: 2 additions & 0 deletions lib/app/pages/game/components/category.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: must_be_immutable

import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand Down
3 changes: 2 additions & 1 deletion lib/app/pages/game/components/search_bar.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:switch_game/app/models/game_model.dart';
import 'package:switch_game/app/pages/game/controllers/game_controller.dart';

class SearchBar extends GetView<GameController> {
Expand Down Expand Up @@ -115,7 +116,7 @@ class SearchBar extends GetView<GameController> {
Padding(
padding: EdgeInsets.only(right: 5),
child: Obx(() {
var pageNum = (controller.gameCount.value / 12).ceil();
var pageNum = (controller.gameCount.value / GameModel.pageSize).ceil();
return RichText(
locale: Locale('zh', 'CN'),
text: TextSpan(
Expand Down
13 changes: 8 additions & 5 deletions lib/app/pages/game/controllers/game_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GameController extends GetxController {
var category = <dynamic>[];
void loadGames() {
games.value = GameModel.findMany(currentCategoryID.value, gameNameC.text, currentPageIndex.value);
gameCount.value = GameModel.count(currentCategoryID.value, gameNameC.text, currentPageIndex.value);
gameCount.value = GameModel.count(currentCategoryID.value, gameNameC.text);
games.refresh();
sc.jumpTo(0);
}
Expand All @@ -28,12 +28,15 @@ class GameController extends GetxController {
void onInit() {
category = jsonDecode(categoryData);
games.value = GameModel.findMany(currentCategoryID.value, gameNameC.text, currentPageIndex.value);
gameCount.value = GameModel.count(currentCategoryID.value, gameNameC.text, currentPageIndex.value);
gameCount.value = GameModel.count(currentCategoryID.value, gameNameC.text);
//loadGames();
sc.addListener(() {
if (sc.position.pixels == sc.position.maxScrollExtent) {
currentPageIndex.value = currentPageIndex.value + 1;
var nextGames = GameModel.findMany(currentCategoryID.value, gameNameC.text, currentPageIndex.value);
if (sc.position.pixels >= sc.position.maxScrollExtent) {
var pageIndex = currentPageIndex.value + 1;
var nextGames = GameModel.findMany(currentCategoryID.value, gameNameC.text, pageIndex);
if (nextGames.length > 0) {
currentPageIndex.value = pageIndex;
}
games.addAll(nextGames);
games.refresh();
}
Expand Down
22 changes: 1 addition & 21 deletions lib/app/pages/mod/controllers/mod_controller.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
import 'package:get/get.dart';

class ModController extends GetxController {
//TODO: Implement ModController

final count = 0.obs;
@override
void onInit() {
super.onInit();
}

@override
void onReady() {
super.onReady();
}

@override
void onClose() {
super.onClose();
}

void increment() => count.value++;
}
class ModController extends GetxController {}
2 changes: 2 additions & 0 deletions lib/app/routes/app_pages.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names

import 'package:get/get.dart';

import '../pages/home/bindings/home_binding.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/app/routes/app_routes.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names

part of 'app_pages.dart';
// DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart

Expand Down
10 changes: 5 additions & 5 deletions lib/modules/my_icons.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/cupertino.dart';

class MyIcons {
static IconData get archive => IconData(0xe867, fontFamily: 'iconfont');
static IconData get game => IconData(0xe640, fontFamily: 'iconfont');
static IconData get lock => IconData(0xe678, fontFamily: 'iconfont');
static IconData get mod => IconData(0xe63b, fontFamily: 'iconfont');
static IconData get tool => IconData(0xe606, fontFamily: 'iconfont');
static IconData get archive => const IconData(0xe867, fontFamily: 'iconfont');
static IconData get game => const IconData(0xe640, fontFamily: 'iconfont');
static IconData get lock => const IconData(0xe678, fontFamily: 'iconfont');
static IconData get mod => const IconData(0xe63b, fontFamily: 'iconfont');
static IconData get tool => const IconData(0xe606, fontFamily: 'iconfont');
}
133 changes: 68 additions & 65 deletions lib/widgets/desktop_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';

Expand Down Expand Up @@ -66,75 +68,76 @@ class _DesktopAppBarState extends State<DesktopAppBar> {
},
)),
),
Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Click(
onClick: () {
windowManager.minimize();
},
onHover: () {
setState(() {
minBtnBgColor = Colors.black12;
});
},
onTapDown: () {
setState(() {
minBtnBgColor = Colors.black26;
});
},
onExit: () {
setState(() {
minBtnBgColor = Colors.transparent;
});
},
child: Container(
color: minBtnBgColor,
width: 30,
height: 30,
child: Icon(
Icons.remove,
color: Colors.black,
if (Platform.isWindows)
Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Click(
onClick: () {
windowManager.minimize();
},
onHover: () {
setState(() {
minBtnBgColor = Colors.black12;
});
},
onTapDown: () {
setState(() {
minBtnBgColor = Colors.black26;
});
},
onExit: () {
setState(() {
minBtnBgColor = Colors.transparent;
});
},
child: Container(
color: minBtnBgColor,
width: 30,
height: 30,
child: Icon(
Icons.remove,
color: Colors.black,
),
),
),
),
Click(
onClick: () {
windowManager.close();
},
onTapDown: () {
setState(() {
closeBtnBgColor = Color.fromARGB(255, 188, 28, 16);
});
},
onHover: () {
setState(() {
closeBtnBgColor = Colors.red;
closeBtnTextColor = Colors.white;
});
},
onExit: () {
setState(() {
closeBtnBgColor = Colors.transparent;
closeBtnTextColor = Colors.black;
});
},
child: Container(
color: closeBtnBgColor,
width: 30,
height: 30,
child: Icon(
Icons.close,
size: 20,
color: closeBtnTextColor,
Click(
onClick: () {
windowManager.close();
},
onTapDown: () {
setState(() {
closeBtnBgColor = Color.fromARGB(255, 188, 28, 16);
});
},
onHover: () {
setState(() {
closeBtnBgColor = Colors.red;
closeBtnTextColor = Colors.white;
});
},
onExit: () {
setState(() {
closeBtnBgColor = Colors.transparent;
closeBtnTextColor = Colors.black;
});
},
child: Container(
color: closeBtnBgColor,
width: 30,
height: 30,
child: Icon(
Icons.close,
size: 20,
color: closeBtnTextColor,
),
),
),
),
],
),
)
],
),
)
],
),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/widgets/desktop_scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ignore_for_file: must_be_immutable

import 'dart:io';

import 'package:flutter/material.dart';

import 'click.dart';
Expand Down Expand Up @@ -48,6 +50,7 @@ class _DesktopScaffoldState extends State<DesktopScaffold> {
Container(
decoration: BoxDecoration(border: Border(right: BorderSide(color: Color.fromARGB(255, 207, 206, 206)))),
child: Column(children: [
if (Platform.isMacOS) SizedBox(height: 18),
if (widget.leading != null) widget.leading!,
SizedBox(height: 10),
...widget.pages.asMap().entries.map((e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/my_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MyContainer extends StatelessWidget {
margin: margin,
padding: newpadding,
decoration: BoxDecoration(
boxShadow: [
boxShadow: const [
BoxShadow(
color: Colors.black38,
offset: Offset(2, 2),
Expand Down
Loading

0 comments on commit bca7d3f

Please sign in to comment.