Skip to content

Commit

Permalink
Add pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ksw2000 committed Dec 2, 2021
1 parent 71bbb81 commit 3edb35e
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 72 deletions.
33 changes: 33 additions & 0 deletions lib/components/card.dart
Original file line number Diff line number Diff line change
@@ -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);
},
),
),
)),
);
}
}
88 changes: 88 additions & 0 deletions lib/components/drawer.dart
Original file line number Diff line number Diff line change
@@ -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: <Widget>[
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('聯絡我們'),
),
*/
],
),
);
}
}
90 changes: 22 additions & 68 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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());
Expand All @@ -11,105 +18,52 @@ 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(),
},
);
}
}

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
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
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: <Widget>[
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.
);
}
}
24 changes: 24 additions & 0 deletions lib/pages/about.dart
Original file line number Diff line number Diff line change
@@ -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<AboutPage> createState() => _AboutPageState();
}

class _AboutPageState extends State<AboutPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('關於學生會')),
drawer: MyDrawer(),
body: Center(
child: Text(
'關於學生會',
style: Theme.of(context).textTheme.headline4,
),
),
);
}
}
24 changes: 24 additions & 0 deletions lib/pages/activity.dart
Original file line number Diff line number Diff line change
@@ -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<ActivityPage> createState() => _ActivityPageState();
}

class _ActivityPageState extends State<ActivityPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('社團/系學會活動補助申請')),
drawer: MyDrawer(),
body: Center(
child: Text(
'社團/系學會活動補助申請',
style: Theme.of(context).textTheme.headline4,
),
),
);
}
}
24 changes: 24 additions & 0 deletions lib/pages/equipment.dart
Original file line number Diff line number Diff line change
@@ -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<EquipmentPage> createState() => _EquipmentPageState();
}

class _EquipmentPageState extends State<EquipmentPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('器材借用')),
drawer: MyDrawer(),
body: Center(
child: Text(
'器材借用',
style: Theme.of(context).textTheme.headline4,
),
),
);
}
}
40 changes: 40 additions & 0 deletions lib/pages/links.dart
Original file line number Diff line number Diff line change
@@ -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<LinksPage> createState() => _LinksPageState();
}

class _LinksPageState extends State<LinksPage> {
@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 '),
])))));
}
}
24 changes: 24 additions & 0 deletions lib/pages/poster.dart
Original file line number Diff line number Diff line change
@@ -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<PosterPage> createState() => _PosterPageState();
}

class _PosterPageState extends State<PosterPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('海報張貼系統')),
drawer: MyDrawer(),
body: Center(
child: Text(
'海報張貼系統',
style: Theme.of(context).textTheme.headline4,
),
),
);
}
}
Loading

0 comments on commit 3edb35e

Please sign in to comment.