2023-12-17 23:00:31 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2023-12-25 14:10:31 +01:00
|
|
|
import '../../utils/CirclePainter.dart';
|
|
|
|
import '../../utils/logic/PreferencesService.dart';
|
2023-12-17 23:00:31 +01:00
|
|
|
import '../../utils/widgets/BottomNavigationWidget.dart';
|
|
|
|
import '../../utils/widgets/MoodTextArea.dart';
|
|
|
|
import '../../utils/widgets/QuestionSliderWidget.dart';
|
|
|
|
|
|
|
|
void main() => runApp(MyApp());
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Flutter Demo',
|
|
|
|
home: HomePage(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
const HomePage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<HomePage> createState() => _HomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _HomePageState extends State<HomePage> {
|
2023-12-25 14:10:31 +01:00
|
|
|
double _sliderValue = 0.0;
|
|
|
|
String _moodText = "No text given";
|
2023-12-17 23:00:31 +01:00
|
|
|
bool _isTextAreaEditable = false;
|
2023-12-25 14:10:31 +01:00
|
|
|
final PreferencesService _prefsService = PreferencesService();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_loadCurrentDiaryEntry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _loadCurrentDiaryEntry() async {
|
|
|
|
DiaryEntry? currentEntry = await _prefsService.getDiaryEntryByCurrentDate();
|
|
|
|
if (currentEntry != null) {
|
|
|
|
setState(() {
|
|
|
|
_sliderValue = currentEntry.percentValue.toDouble();
|
|
|
|
_moodText = currentEntry.texts
|
|
|
|
.join(" "); // Assuming you want to concatenate all texts
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
_sliderValue = 0.0;
|
|
|
|
_moodText = "No text given";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-12-17 23:00:31 +01:00
|
|
|
|
|
|
|
void _toggleTextAreaEditability() {
|
|
|
|
setState(() {
|
|
|
|
_isTextAreaEditable = !_isTextAreaEditable;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: SafeArea(
|
2023-12-25 14:10:31 +01:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
// Background circle
|
|
|
|
Positioned.fill(
|
|
|
|
child: CustomPaint(
|
2024-01-01 18:31:10 +01:00
|
|
|
painter: CirclePainter(_sliderValue, Colors.orange),
|
2023-12-17 23:00:31 +01:00
|
|
|
),
|
2023-12-25 14:10:31 +01:00
|
|
|
),
|
|
|
|
SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
QuestionSliderWidget(
|
2024-01-01 18:31:10 +01:00
|
|
|
onSliderPositionChanged: (value) {
|
|
|
|
print("sliderposchanged");
|
|
|
|
},
|
2024-01-01 19:52:42 +01:00
|
|
|
sliderColor: Colors.purple,
|
2023-12-25 14:10:31 +01:00
|
|
|
date: DateTime.now(),
|
|
|
|
questionText: 'this is how it is:',
|
|
|
|
initialSliderValue: _sliderValue,
|
|
|
|
isSliderEnabled: true,
|
|
|
|
onSliderChanged: (value) {
|
|
|
|
setState(() {
|
2024-01-01 18:31:10 +01:00
|
|
|
_sliderValue = value.value;
|
2023-12-25 14:10:31 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
MoodTextAreaWidget(
|
|
|
|
initialText: _moodText,
|
|
|
|
isDisabled: !_isTextAreaEditable,
|
|
|
|
hasPrefix: false,
|
|
|
|
autoFocus: false,
|
|
|
|
forceBlinkingCursor: false,
|
|
|
|
),
|
|
|
|
ElevatedButton(
|
|
|
|
onPressed: _toggleTextAreaEditability,
|
|
|
|
child: Text(_isTextAreaEditable ? "- Save" : "+ Edit"),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 100), // Space for floating bottom navigation bar
|
|
|
|
],
|
2023-12-17 23:00:31 +01:00
|
|
|
),
|
2023-12-25 14:10:31 +01:00
|
|
|
),
|
|
|
|
],
|
2023-12-17 23:00:31 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
|
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|