Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/bar_graph/bar_data.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:shleappy/data/session.dart';
import 'individual_bar.dart';

// TODO
class BarData {
final List<double> amounts;
List<IndividualBar> barData = [];
Expand All @@ -10,7 +10,7 @@ class BarData {
void initBarData() {
barData = List.generate(
amounts.length,
(index) => IndividualBar(day: Day.values[index%7], amount: amounts[index]),
(index) => IndividualBar(day: index, amount: amounts[index]),
);
}
}
6 changes: 2 additions & 4 deletions lib/bar_graph/individual_bar.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
enum Day { sun, mon, tue, wed, thu, fri, sat }

class IndividualBar {
final Day day;
final double amount;
int day;
double amount;

IndividualBar({
required this.day,
Expand Down
2 changes: 1 addition & 1 deletion lib/bar_graph/sleep_amount_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SleepAmountBar extends StatelessWidget {
),
barGroups: sleepAmountBarData.barData.map((data) {
return BarChartGroupData(
x: data.day.index,
x: data.day/* .index */,
barRods: [
BarChartRodData(
// bar chart rogs style
Expand Down
1 change: 0 additions & 1 deletion lib/line_graph/line_data.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'line_point.dart';

//TODO
class LineData {
final List<int> ratings;
List<LinePoint> lineData = [];
Expand Down
30 changes: 16 additions & 14 deletions lib/screens/calendar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ class CalendarScreen extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final chosenProvider = sleepWeekWidget.chosenProvider;
final SleepSession? chosen = ref.watch(chosenProvider);
return Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
flex: 3,
child: sleepWeekWidget,
),
Expanded(
flex: 5,
child: _sessionInfoWithBorder(chosen, context, ref),
),
],
return SafeArea(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
flex: 3,
child: sleepWeekWidget,
),
Expanded(
flex: 5,
child: _sessionInfoWithBorder(chosen, context, ref),
),
],
),
),
);
}
Expand Down Expand Up @@ -116,7 +118,7 @@ class CalendarScreen extends ConsumerWidget {
),
Align(
alignment: Alignment.bottomRight,
child: Visibility.maintain(
child: Visibility(
visible: chosen != null,
child: Padding(
padding: const EdgeInsets.all(16),
Expand Down
245 changes: 181 additions & 64 deletions lib/screens/dialogs/dialog_windows.dart
Original file line number Diff line number Diff line change
@@ -1,71 +1,186 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' hide DatePickerTheme;
import 'package:shleappy/data/history.dart';
import 'package:shleappy/data/session.dart';
import 'package:shleappy/screens/dialogs/mood_selection.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shleappy/screens/home_screen.dart';
import 'package:omni_datetime_picker/omni_datetime_picker.dart' as dtp;

final ratingProvider = StateProvider<int>((ref) => 1);

class DialogWindows {
static void showFeedbackDialog(BuildContext context, WidgetRef ref) {
final TextEditingController controller = TextEditingController();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
content: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(
height: 35,
),
Text("How did you sleep?",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w200,
color: Theme.of(context).focusColor)),
const SizedBox(
height: 35,
),
RatingStars(
leftCaption: "Terrible",
rightCaption: "Great",
),
const SizedBox(
height: 25,
),
Text("Leave additional comments",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w100,
color: Theme.of(context).shadowColor)),
const SizedBox(
height: 5,
),
SizedBox(
width: 250,
child: TextField(
controller: controller,
style: TextStyle(color: Theme.of(context).focusColor),
decoration: InputDecoration(
border: OutlineInputBorder(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
content: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("How did you sleep?",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w200,
color: Theme.of(context).focusColor)),
const SizedBox(
height: 35,
),
RatingStars(
leftCaption: "Terrible",
rightCaption: "Great",
),
const SizedBox(
height: 25,
),
Text("Leave additional comments",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w100,
color: Theme.of(context).shadowColor)),
const SizedBox(
height: 5,
),
SizedBox(
width: 250,
child: TextField(
controller: controller,
style: TextStyle(color: Theme.of(context).focusColor),
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).shadowColor,
),
),
),
),
),
const SizedBox(
height: 25,
),
SizedBox(
height: 60,
width: 170,
child: OutlinedButton(
onPressed: () {
String text = controller.text;
ref
.read(SleepSessionHistoryNotifier.provider.notifier)
.putItem(SleepSession(
started: ref.read(startSleepTimeProvider),
ended: ref.read(endSleepTimeProvider),
quality: ref.read(ratingProvider),
comment: text));

ref.read(ratingProvider.notifier).state = 1;
Navigator.of(context).pop();
},
child: Text(
"Proceed",
style: TextStyle(color: Theme.of(context).focusColor),
),
),
),
],
),
),
),
);
},
);
}

//TODO dev only!!
static void showEditorDialog(BuildContext context, WidgetRef ref) {
final TextEditingController controller = TextEditingController();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
content: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
child: const Text("Start time"),
onPressed: () {
dtp
.showOmniDateTimePicker(
context: context,
initialDate: DateTime.now(),
)
.then((value) {
ref.read(startSleepTimeProvider.notifier).state =
value!;
});
},
),
TextButton(
child: const Text("End time"),
onPressed: () {
dtp
.showOmniDateTimePicker(
context: context,
initialDate: DateTime.now(),
)
.then((value) {
ref.read(endSleepTimeProvider.notifier).state = value!;
});
},
),
Text("How did you sleep?",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w200,
color: Theme.of(context).focusColor)),
const SizedBox(
height: 35,
),
RatingStars(
leftCaption: "Terrible",
rightCaption: "Great",
),
const SizedBox(
height: 25,
),
Text("Leave additional comments",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w100,
color: Theme.of(context).shadowColor)),
const SizedBox(
height: 5,
),
SizedBox(
width: 250,
child: TextField(
controller: controller,
style: TextStyle(color: Theme.of(context).focusColor),
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).shadowColor,
)),
color: Theme.of(context).shadowColor,
),
),
),
),
),
),
const SizedBox(
height: 25,
),
SizedBox(
height: 60,
width: 170,
child: OutlinedButton(
const SizedBox(
height: 25,
),
SizedBox(
height: 60,
width: 170,
child: OutlinedButton(
onPressed: () {
String text = controller.text;
ref
Expand All @@ -79,16 +194,18 @@ class DialogWindows {
ref.read(ratingProvider.notifier).state = 1;
Navigator.of(context).pop();
},
child: Text("Proceed",
style:
TextStyle(color: Theme.of(context).focusColor))),
),
const SizedBox(
height: 35,
),
],
)),
);
});
child: Text(
"Proceed",
style: TextStyle(color: Theme.of(context).focusColor),
),
),
),
],
),
),
),
);
},
);
}
}
12 changes: 12 additions & 0 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ class HomeScreen extends ConsumerWidget {
PreferredSizeWidget _homeAppBar(BuildContext context) {
return AppBar(
backgroundColor: Theme.of(context).splashColor,
// TODO dev only!!
leading: Visibility.maintain(
visible: false,
child: Consumer(
builder: (context, ref, widget) => IconButton(
icon: const Icon(Icons.add),
onPressed: () {
DialogWindows.showEditorDialog(context, ref);
},
),
),
),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
Expand Down
Loading