Skip to content

Commit

Permalink
Merge pull request #92 from NUTFes/feature/imai/84-add-time-schedule
Browse files Browse the repository at this point in the history
[Feature]タイムスケジュールの作成(#84)
  • Loading branch information
mashita1023 authored Sep 7, 2022
2 parents f5f47f4 + 6b8e71b commit 4d83429
Show file tree
Hide file tree
Showing 6 changed files with 3,513 additions and 89 deletions.
122 changes: 35 additions & 87 deletions lib/pages/schedule_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,39 @@ import 'dart:developer';
import 'package:seeft_mobile/configs/importer.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:http/http.dart' as http;
import 'package:seeft_mobile/pages/schedule_page_first_day_rainy.dart';
import 'package:seeft_mobile/pages/schedule_page_first_day_sunny.dart';
import 'package:seeft_mobile/pages/schedule_page_second_day_rainy.dart';
import 'package:seeft_mobile/pages/schedule_page_second_day_sunny.dart';

class SchedulePage extends StatefulWidget {
@override
_SchedulePageState createState() => _SchedulePageState();
}

class _SchedulePageState extends State<SchedulePage> {
// notification関連をinitStateに書き出さなきゃいけないので書いてたけどutilとかに書いてもいいかもね
class TabInfo {
String label;
Widget widget;
TabInfo(this.label, this.widget);
}

class _SchedulePageState extends State<SchedulePage> with SingleTickerProviderStateMixin {
final List<TabInfo> _tabs = [
TabInfo("9/10 晴天時", SchedulePageFirstDaySunny()),
TabInfo("9/10 雨天時", SchedulePageFirstDayRainy()),
TabInfo("9/11 晴天時", SchedulePageSecondDaySunny()),
TabInfo("9/11 雨天時", SchedulePageSecondDayRainy()),
];
late TabController _tabController;

// notification関連をinitStateに書き出さなきゃいけないので書いてたけどutilとかに書いてもいいかもね

// FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
// NotificationDetails platformChannelSpecifics;

@override
void initState() {
_tabController = TabController(length: _tabs.length, vsync: this);
super.initState();
}

Expand All @@ -27,93 +46,22 @@ class _SchedulePageState extends State<SchedulePage> {
appBar: AppBar(
title: const Text('タイムスケジュール'),
actions: <Widget>[],
bottom: PreferredSize(
child: TabBar(
isScrollable: true,
tabs: _tabs.map((TabInfo tab) {
return Tab(text: tab.label);
}).toList(),
controller: _tabController,
),
preferredSize: Size.fromHeight(30.0),
),
// debug
),
drawer: drawer.applicationDrawer(context),
body: FutureBuilder(
future: getData(),
builder: (ctx, snapshot) {
if (snapshot.connectionState == AsyncSnapshot.waiting()) {
logger.w("message");
}
if (!snapshot.hasData) {
return CircularProgressIndicator();
}
return Container(
padding: const EdgeInsets.all(40.0),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
// height: size.height - 200,
// width: size.width - 80,
// padding: const EdgeInsets.all(10.0),
// decoration: BoxDecoration(
// border: Border.all(color: Colors.black),
// ),
// child: _contents(size, snapshot.data)),
child: _table(snapshot.data)),
],
),
));
},
),
body: TabBarView(
controller: _tabController,
children: _tabs.map((tab) => tab.widget).toList()),
);
}
}

Widget _table(var shifts) {
return Table(
border: TableBorder.all(color: Colors.black),
columnWidths: const <int, TableColumnWidth>{
// 0: IntrinsicColumnWidth(),
0: FlexColumnWidth(1),
1: FlexColumnWidth(10),
// 2: FixedColumnWidth(100.0),
},
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: [
TableRow(children: [
TableCell(
child: Container(
child: Text("日時"),
alignment: Alignment.center,
color: Colors.lightGreen,
)),
TableCell(
child: Container(
child: Text("場所"),
alignment: Alignment.center,
color: Colors.lightGreen,
),
)
]),
for (var shift in shifts)
TableRow(
decoration: BoxDecoration(color: Colors.grey[200]),
children: [
TableCell(
child: Container(
alignment: Alignment.center,
child: new Text(shift["Time"].toString()),
)),
TableCell(
child: Container(
alignment: Alignment.center,
child: new Text(shift["Work"].toString()),
// margin: EdgeInsets.only(bottom: 10.0),
height: 25,
))
]),
]);
}

Future getData() async {
try {
var userID = await store.getUserID();
var res = await api.getMyShift(userID.toString());
return res;
} catch (err) {
logger.e('don`t response. error message: $err');
}
}
}
Loading

0 comments on commit 4d83429

Please sign in to comment.