Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #97 from CCXXXI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
CCXXXI authored Oct 1, 2021
2 parents 58f342c + ed5f0cb commit a1e7182
Show file tree
Hide file tree
Showing 27 changed files with 308 additions and 61 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ on:
- cron: '10 16 * * FRI'

jobs:
check-duplication:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content_newer'

analyze:
needs: check-duplication
if: ${{ needs.check-duplication.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -20,6 +32,8 @@ jobs:
- run: flutter analyze

coverage:
needs: check-duplication
if: ${{ needs.check-duplication.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -33,6 +47,8 @@ jobs:
- uses: codecov/codecov-action@v2

dependency_validator:
needs: check-duplication
if: ${{ needs.check-duplication.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
9 changes: 0 additions & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowFullscreen">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowFullscreen">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
Binary file added assets/images/ecnu_a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ecnu_b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ecnu_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dart_dependency_validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
ignore:
- flutter_web_plugins
- package_info_plus_web
- shared_preferences_web
4 changes: 2 additions & 2 deletions flutter_native_splash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ flutter_native_splash:
# of your splash screen to a solid color. Use background_image to set the background of your
# splash screen to a png image. This is useful for gradients. The image will be stretch to the
# size of the app. Only one parameter can be used, color and background_image cannot both be set.
color: "#A32135"
color: "#a41f35"
#background_image: "assets/background.png"

# Optional parameters are listed below. To enable a parameter, uncomment the line by removing
Expand Down Expand Up @@ -59,7 +59,7 @@ flutter_native_splash:
# To show the notification bar, add the following code to your Flutter app:
# WidgetsFlutterBinding.ensureInitialized();
# SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]);
fullscreen: true
#fullscreen: true

# If you have changed the name(s) of your info.plist file(s), you can specify the filename(s)
# with the info_plist_files parameter. Remove only the # characters in the three lines below,
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<true/>
<false/>
</dict>
</plist>
12 changes: 9 additions & 3 deletions lib/home/home_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ import '../utils/logger.dart';

class HomeLogic extends GetxController {
final idx = 1.obs;
final pageController = PageController(initialPage: 1);
final isAnimating = false.obs;

late PageController _pageController;

PageController get pageController {
_pageController = PageController(initialPage: idx.value);
return _pageController;
}

Future<void> _toPage(int idx_, bool animate) async {
idx.value = idx_;

if (animate) {
logger.d('animateToPage $idx_ begin.');
isAnimating.value = true;

await pageController.animateToPage(
await _pageController.animateToPage(
idx_,
duration: const Duration(milliseconds: 500),
curve: Curves.ease,
Expand All @@ -24,7 +30,7 @@ class HomeLogic extends GetxController {
isAnimating.value = false;
logger.d('animateToPage $idx_ end.');
} else {
pageController.jumpToPage(idx_);
_pageController.jumpToPage(idx_);
}
}

Expand Down
33 changes: 17 additions & 16 deletions lib/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';

import '../settings/settings_view.dart';
import '../timetable/timetable_view.dart';
import '../toolbox/toolbox_view.dart';
import '../utils/messages.dart';
import 'home_logic.dart';

Expand All @@ -14,7 +17,11 @@ class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: context.isPortrait ? AppBar() : null,
appBar: context.isPortrait
? AppBar(
title: Text('求实创造 为人师表'.s),
)
: null,
body: Row(
children: [
if (context.isLandscape)
Expand All @@ -25,8 +32,8 @@ class HomePage extends StatelessWidget {
destinations: [
for (final i in idxMap)
NavigationRailDestination(
label: _labelIconList[i].label,
icon: _labelIconList[i].icon,
label: _labelIcons[i].label,
icon: _labelIcons[i].icon,
),
],
);
Expand All @@ -40,21 +47,13 @@ class HomePage extends StatelessWidget {
physics: logic.isAnimating.isTrue
? const NeverScrollableScrollPhysics()
: null,
children: const [
Placeholder(color: Colors.red),
Placeholder(color: Colors.green),
Placeholder(color: Colors.blue),
],
children: _pages,
);
})
: PageView(
controller: logic.pageController,
physics: const NeverScrollableScrollPhysics(),
children: const [
Placeholder(color: Colors.red),
Placeholder(color: Colors.green),
Placeholder(color: Colors.blue),
],
children: _pages,
),
),
],
Expand All @@ -66,7 +65,7 @@ class HomePage extends StatelessWidget {
selectedIndex: logic.idx.value,
onItemSelected: logic.onItemSelected,
items: [
for (final labelIcon in _labelIconList)
for (final labelIcon in _labelIcons)
BottomNavyBarItem(
title: labelIcon.label,
icon: labelIcon.icon,
Expand All @@ -83,11 +82,13 @@ class _LabelIcon {
final Widget label;
final Widget icon;

_LabelIcon(String label, this.icon) : label = Text(label.t);
_LabelIcon(String label, this.icon) : label = Text(label.s);
}

final _labelIconList = [
final _labelIcons = [
_LabelIcon('Toolbox', const FaIcon(FontAwesomeIcons.toolbox)),
_LabelIcon('Timetable', const Icon(Icons.calendar_view_month)),
_LabelIcon('Settings', const Icon(Icons.settings)),
];

final _pages = [ToolboxPage(), TimetablePage(), SettingsPage()];
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_settings_screens/flutter_settings_screens.dart';
import 'package:get/get.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Expand All @@ -10,6 +11,7 @@ import 'utils/sentry.dart';

Future<void> main() async {
initLogger();
await Settings.init();
if (GetPlatform.isDesktop) initDesktop();
await initSentry(const MyApp());
}
Expand Down
14 changes: 14 additions & 0 deletions lib/settings/settings_logic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter_settings_screens/flutter_settings_screens.dart';
import 'package:get/get.dart';

import '../utils/gu.dart';

class SettingsLogic extends GetxController {
bool get loggedIn => id != null;

String? get id => Settings.getValue('id', null);

String? get username => Settings.getValue('username', null);

void login() => gu(); // todo
}
38 changes: 38 additions & 0 deletions lib/settings/settings_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';

import '../utils/messages.dart';
import 'settings_logic.dart';

class SettingsPage extends StatelessWidget {
SettingsPage({Key? key}) : super(key: key);

final logic = Get.put(SettingsLogic());

@override
Widget build(BuildContext context) {
return ListView(
children: [
user(),
const Divider(),
const Placeholder(),
],
);
}

Widget user() => logic.loggedIn
? ListTile(
leading: const Icon(Icons.person),
trailing: const Icon(Icons.logout),
title: Text(logic.username!),
subtitle: Text(logic.id!),
)
: ListTile(
leading: const FaIcon(FontAwesomeIcons.userSecret),
trailing: const Icon(Icons.login),
title: Text('Anonymous'.s),
subtitle: Text('Tap to login.'.s),
onTap: logic.login,
);
}
3 changes: 3 additions & 0 deletions lib/timetable/timetable_logic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:get/get.dart';

class TimetableLogic extends GetxController {}
15 changes: 15 additions & 0 deletions lib/timetable/timetable_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'timetable_logic.dart';

class TimetablePage extends StatelessWidget {
TimetablePage({Key? key}) : super(key: key);

final logic = Get.put(TimetableLogic());

@override
Widget build(BuildContext context) {
return const Placeholder(color: Colors.green);
}
}
3 changes: 3 additions & 0 deletions lib/toolbox/toolbox_logic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:get/get.dart';

class ToolboxLogic extends GetxController {}
15 changes: 15 additions & 0 deletions lib/toolbox/toolbox_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'toolbox_logic.dart';

class ToolboxPage extends StatelessWidget {
ToolboxPage({Key? key}) : super(key: key);

final logic = Get.put(ToolboxLogic());

@override
Widget build(BuildContext context) {
return const Placeholder(color: Colors.red);
}
}
10 changes: 5 additions & 5 deletions lib/utils/desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import 'logger.dart';
import 'messages.dart';

void initDesktop() {
logger.i('initDesktop...');
logger.d('initDesktop begin.');

logger.i('ensureInitialized');
logger.d('ensureInitialized');
WidgetsFlutterBinding.ensureInitialized();

logger.i('setWindowTitle');
logger.d('setWindowTitle');
setWindowTitle(appName);

logger.i('setWindowMinSize');
logger.d('setWindowMinSize');
setWindowMinSize(const Size(300, 300));

logger.i('Done.');
logger.i('initDesktop end.');
}
11 changes: 11 additions & 0 deletions lib/utils/gu.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'dart:math';

import 'package:get/get.dart';

final _random = Random();

String _r(int i) => '🕊' * _random.nextInt((Get.width / i - 1).floor());

void gu() {
Get.snackbar(_r(24), _r(20));
}
10 changes: 4 additions & 6 deletions lib/utils/messages.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'package:get/get.dart';

import 'pangu.dart';

// package_info_plus 1.0.6 cannot get real info on windows
// record them manually
const appName = 'ECNU Timetable';
const packageName = 'io.github.ccxxxi.ecnu_timetable';
const version = '0.2.0';
const buildNumber = '3';
const version = '0.3.0';
const buildNumber = '4';

extension Messages on String {
String get t {
return spacingText(tr);
String get s {
return spacingText(this);
}
}
Loading

0 comments on commit a1e7182

Please sign in to comment.