From 3edb35e370eeed2a4667678527a9a7d20c7bba32 Mon Sep 17 00:00:00 2001 From: liao2000 Date: Thu, 2 Dec 2021 11:22:02 +0800 Subject: [PATCH] Add pages --- lib/components/card.dart | 33 ++++++++++++++ lib/components/drawer.dart | 88 +++++++++++++++++++++++++++++++++++++ lib/main.dart | 90 ++++++++++---------------------------- lib/pages/about.dart | 24 ++++++++++ lib/pages/activity.dart | 24 ++++++++++ lib/pages/equipment.dart | 24 ++++++++++ lib/pages/links.dart | 40 +++++++++++++++++ lib/pages/poster.dart | 24 ++++++++++ lib/pages/right.dart | 24 ++++++++++ pubspec.lock | 78 ++++++++++++++++++++++++++++++++- pubspec.yaml | 1 + web/index.html | 6 +-- 12 files changed, 384 insertions(+), 72 deletions(-) create mode 100644 lib/components/card.dart create mode 100644 lib/components/drawer.dart create mode 100644 lib/pages/about.dart create mode 100644 lib/pages/activity.dart create mode 100644 lib/pages/equipment.dart create mode 100644 lib/pages/links.dart create mode 100644 lib/pages/poster.dart create mode 100644 lib/pages/right.dart diff --git a/lib/components/card.dart b/lib/components/card.dart new file mode 100644 index 0000000..075d54f --- /dev/null +++ b/lib/components/card.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class LinkedCard extends StatelessWidget { + final double width; + final String text; + final String url; + const LinkedCard( + {Key? key, required this.text, required this.url, this.width = 500}) + : super(key: key); + @override + Widget build(BuildContext context) { + return SizedBox( + width: (MediaQuery.of(context).size.width > width * 1.5) + ? width + : double.infinity, + child: Card( + child: LimitedBox( + maxWidth: 200, + child: ListTile( + title: Text(text), + subtitle: Text(url), + trailing: TextButton( + child: const Text('前往'), + onPressed: () { + launch(url); + }, + ), + ), + )), + ); + } +} diff --git a/lib/components/drawer.dart b/lib/components/drawer.dart new file mode 100644 index 0000000..42549ce --- /dev/null +++ b/lib/components/drawer.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; + +class MyDrawer extends StatelessWidget { + const MyDrawer({Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + DrawerHeader( + decoration: BoxDecoration( + color: Colors.blue[300], + ), + child: const Text( + '很高興為您服務', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + ListTile( + leading: const Icon(Icons.home), + title: const Text('首頁'), + onTap: () { + Navigator.pushReplacementNamed(context, '/'); + }), + ListTile( + leading: const Icon(Icons.description), + title: const Text('海報張貼系統'), + onTap: () { + Navigator.pushReplacementNamed(context, '/poster'); + }, + ), + ListTile( + leading: const Icon(Icons.build), + title: const Text('器材借用'), + onTap: () { + Navigator.pushReplacementNamed(context, '/equipment'); + }, + ), + ListTile( + leading: const Icon(Icons.paid), + title: const Text('活動補助申請'), + onTap: () { + Navigator.pushReplacementNamed(context, '/activity'); + }, + ), + ListTile( + leading: const Icon(Icons.groups), + title: const Text('學生權益'), + onTap: () { + Navigator.pushReplacementNamed(context, '/right'); + }, + ), + ListTile( + leading: const Icon(Icons.public), + title: const Text('相關連結'), + onTap: () { + Navigator.pushReplacementNamed(context, '/links'); + }, + ), + ListTile( + leading: const Icon(Icons.info), + title: const Text('關於學生會'), + onTap: () { + Navigator.pushReplacementNamed(context, '/about'); + }, + ), + /* + ListTile( + leading: const Icon(Icons.account_circle), + title: const Text('學生會活動'), + onTap: () { + Navigator.pushReplacementNamed(context, '/about'); + }, + ), + ListTile( + leading: const Icon(Icons.contact_mail), + title: const Text('聯絡我們'), + ), + */ + ], + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 202509b..fd8ce70 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; +import 'package:io_github_nchusg/pages/about.dart'; +import 'package:io_github_nchusg/pages/activity.dart'; +import 'package:io_github_nchusg/pages/equipment.dart'; +import 'package:io_github_nchusg/pages/links.dart'; +import 'package:io_github_nchusg/pages/poster.dart'; +import 'package:io_github_nchusg/pages/right.dart'; void main() { runApp(const MyApp()); @@ -11,20 +18,20 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', + title: '中興大學學生會', theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, + primarySwatch: Colors.blueGrey, ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), + initialRoute: '/', + routes: { + '/': (context) => const MyHomePage(title: '中興大學第27屆學生會'), + '/about': (context) => const AboutPage(), + '/activity': (context) => const ActivityPage(), + '/equipment': (context) => const EquipmentPage(), + '/poster': (context) => const PosterPage(), + '/right': (context) => const RightPage(), + '/links': (context) => const LinksPage(), + }, ); } } @@ -32,15 +39,6 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - final String title; @override @@ -48,68 +46,24 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), + drawer: MyDrawer(), body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'You have pushed the button this many times:', - ), Text( - '$_counter', + 'The website is building...', style: Theme.of(context).textTheme.headline4, - ), + ) ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/lib/pages/about.dart b/lib/pages/about.dart new file mode 100644 index 0000000..4bab8fb --- /dev/null +++ b/lib/pages/about.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; + +class AboutPage extends StatefulWidget { + const AboutPage({Key? key}) : super(key: key); + @override + State createState() => _AboutPageState(); +} + +class _AboutPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('關於學生會')), + drawer: MyDrawer(), + body: Center( + child: Text( + '關於學生會', + style: Theme.of(context).textTheme.headline4, + ), + ), + ); + } +} diff --git a/lib/pages/activity.dart b/lib/pages/activity.dart new file mode 100644 index 0000000..289b2e8 --- /dev/null +++ b/lib/pages/activity.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; + +class ActivityPage extends StatefulWidget { + const ActivityPage({Key? key}) : super(key: key); + @override + State createState() => _ActivityPageState(); +} + +class _ActivityPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('社團/系學會活動補助申請')), + drawer: MyDrawer(), + body: Center( + child: Text( + '社團/系學會活動補助申請', + style: Theme.of(context).textTheme.headline4, + ), + ), + ); + } +} diff --git a/lib/pages/equipment.dart b/lib/pages/equipment.dart new file mode 100644 index 0000000..fb6f098 --- /dev/null +++ b/lib/pages/equipment.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; + +class EquipmentPage extends StatefulWidget { + const EquipmentPage({Key? key}) : super(key: key); + @override + State createState() => _EquipmentPageState(); +} + +class _EquipmentPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('器材借用')), + drawer: MyDrawer(), + body: Center( + child: Text( + '器材借用', + style: Theme.of(context).textTheme.headline4, + ), + ), + ); + } +} diff --git a/lib/pages/links.dart b/lib/pages/links.dart new file mode 100644 index 0000000..383b501 --- /dev/null +++ b/lib/pages/links.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; +import 'package:io_github_nchusg/components/card.dart'; + +class LinksPage extends StatefulWidget { + const LinksPage({Key? key}) : super(key: key); + @override + State createState() => _LinksPageState(); +} + +class _LinksPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('相關連結')), + drawer: const MyDrawer(), + body: Scrollbar( + isAlwaysShown: true, + child: SingleChildScrollView( + child: Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + '相關連結', + style: Theme.of(context).textTheme.headline4, + ), + const LinkedCard( + text: '會長令、各部門公告', url: 'https://reurl.cc/W3zM5y'), + const LinkedCard( + text: '第27屆總預算案', url: 'https://reurl.cc/8n7KbR'), + const LinkedCard( + text: '第27屆總決算案', url: 'https://reurl.cc/R0gXnx'), + const LinkedCard( + text: '學權申訴系統', url: 'https://reurl.cc/gzaRbL'), + const LinkedCard( + text: '社團海報張貼申請', url: 'https://reurl.cc/kLapEG '), + ]))))); + } +} diff --git a/lib/pages/poster.dart b/lib/pages/poster.dart new file mode 100644 index 0000000..69ed8b5 --- /dev/null +++ b/lib/pages/poster.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; + +class PosterPage extends StatefulWidget { + const PosterPage({Key? key}) : super(key: key); + @override + State createState() => _PosterPageState(); +} + +class _PosterPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('海報張貼系統')), + drawer: MyDrawer(), + body: Center( + child: Text( + '海報張貼系統', + style: Theme.of(context).textTheme.headline4, + ), + ), + ); + } +} diff --git a/lib/pages/right.dart b/lib/pages/right.dart new file mode 100644 index 0000000..b178321 --- /dev/null +++ b/lib/pages/right.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:io_github_nchusg/components/drawer.dart'; + +class RightPage extends StatefulWidget { + const RightPage({Key? key}) : super(key: key); + @override + State createState() => _RightPageState(); +} + +class _RightPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('學生權益')), + drawer: MyDrawer(), + body: Center( + child: Text( + '學生權益', + style: Theme.of(context).textTheme.headline4, + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 18fcc0f..46271eb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -74,6 +74,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" lints: dependency: transitive description: @@ -102,6 +114,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -156,6 +175,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" vector_math: dependency: transitive description: @@ -164,4 +239,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6287652..468b8ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + url_launcher: ^6.0.17 dev_dependencies: flutter_test: diff --git a/web/index.html b/web/index.html index c0c36dd..a43a470 100644 --- a/web/index.html +++ b/web/index.html @@ -13,8 +13,8 @@ This is a placeholder for base href that will be replaced by the value of the `--base-href` argument provided to `flutter build`. + --> - @@ -23,10 +23,10 @@ - + - io_github_nchusg + 國立中興大學第27屆學生會