fixed important things

url-works
Christopher Schmitt 2024-01-09 12:34:44 +01:00
parent 1add5bb6fe
commit cf53061e3a
29 changed files with 344 additions and 560 deletions

View File

@ -1,12 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:moody/utils/SlideDirection.dart'; import 'package:moody/utils/slide_direction.dart';
import 'package:moody/utils/widgets/QuestionSliderWidget.dart'; import 'package:moody/utils/widgets/question_slider_widget.dart';
import 'package:moody/views/color_page/color_page.dart'; import 'package:moody/views/color_page/color_page.dart';
import 'package:moody/views/entry_view/entry_page.dart'; import 'package:moody/views/entry_view/entry_page.dart';
import 'package:moody/views/first_page/first_page.dart'; import 'package:moody/views/first_page/first_page.dart';
import 'package:moody/views/home_page/home_page.dart'; import 'package:moody/views/home_page/home_page.dart';
import 'package:moody/views/home_page/kalendartryhome_page.dart';
import 'package:moody/views/settings_page/settings_page.dart'; import 'package:moody/views/settings_page/settings_page.dart';
import 'package:moody/views/start_page/start_page.dart'; import 'package:moody/views/start_page/start_page.dart';
import 'package:moody/views/statistic/statistic_page.dart'; import 'package:moody/views/statistic/statistic_page.dart';
@ -18,37 +17,32 @@ final GoRouter _router = GoRouter(
routes: [ routes: [
GoRoute( GoRoute(
path: '/', path: '/',
pageBuilder: (context, state) => pageBuilder: (context, state) => _noAnimationTransition(context, state, const StartPage()),
_noAnimationTransition(context, state, StartPage()),
), ),
GoRoute( GoRoute(
path: '/moods', path: '/moods',
builder: (context, state) => CalendarPage(), builder: (context, state) => const StatisticPage(),
), ),
GoRoute( GoRoute(
path: '/settings', path: '/settings',
pageBuilder: (context, state) => pageBuilder: (context, state) => _noAnimationTransition(context, state, const SettingsPage()),
_noAnimationTransition(context, state, SettingsPage()),
), ),
GoRoute( GoRoute(
path: '/statistic', path: '/statistic',
pageBuilder: (context, state) => // ignore: prefer_const_constructors
_noAnimationTransition(context, state, StatisticPage()), pageBuilder: (context, state) => _noAnimationTransition(context, state, StatisticPage()),
), ),
GoRoute( GoRoute(
path: '/home', path: '/home',
pageBuilder: (context, state) => pageBuilder: (context, state) => _noAnimationTransition(context, state, const HomePage()),
_noAnimationTransition(context, state, HomePage()),
), ),
GoRoute( GoRoute(
path: '/first', path: '/first',
pageBuilder: (context, state) => pageBuilder: (context, state) => _noAnimationTransition(context, state, const FirstPage()),
_noAnimationTransition(context, state, FirstPage()),
), ),
GoRoute( GoRoute(
path: '/color', path: '/color',
pageBuilder: (context, state) => pageBuilder: (context, state) => _noAnimationTransition(context, state, const ColorPage()),
_noAnimationTransition(context, state, ColorPage()),
), ),
GoRoute( GoRoute(
path: '/write', path: '/write',
@ -81,10 +75,9 @@ class MyApp extends StatelessWidget {
} }
} }
CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context, /* A Slide Transition that will may be used in future versions
GoRouterState state, Widget child, SlideDirection direction) { CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context, GoRouterState state, Widget child, SlideDirection direction) {
var beginOffset = var beginOffset = direction == SlideDirection.left ? Offset(1.0, 0.0) : Offset(-1.0, 0.0);
direction == SlideDirection.left ? Offset(1.0, 0.0) : Offset(-1.0, 0.0);
return CustomTransitionPage( return CustomTransitionPage(
key: state.pageKey, key: state.pageKey,
@ -93,8 +86,7 @@ CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context,
var end = Offset.zero; var end = Offset.zero;
var curve = Curves.easeInOut; var curve = Curves.easeInOut;
var tween = var tween = Tween(begin: beginOffset, end: end).chain(CurveTween(curve: curve));
Tween(begin: beginOffset, end: end).chain(CurveTween(curve: curve));
var offsetAnimation = animation.drive(tween); var offsetAnimation = animation.drive(tween);
return SlideTransition( return SlideTransition(
@ -103,15 +95,9 @@ CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context,
); );
}, },
); );
} }*/
SlideDirection determineSlideDirection( SlideDirection determineSlideDirection(String currentRoute, String targetRoute) {
String currentRoute, String targetRoute) {
print(currentRoute);
print(targetRoute);
if (currentRoute == targetRoute) {
print("Sameroute pls fix!!");
}
if (targetRoute == "/statistic") { if (targetRoute == "/statistic") {
return SlideDirection.right; return SlideDirection.right;
} else if (targetRoute == "/settings") { } else if (targetRoute == "/settings") {
@ -123,13 +109,10 @@ SlideDirection determineSlideDirection(
return SlideDirection.right; return SlideDirection.right;
} }
} }
return currentRoute.compareTo(targetRoute) < 0 return currentRoute.compareTo(targetRoute) < 0 ? SlideDirection.left : SlideDirection.right;
? SlideDirection.left
: SlideDirection.right;
} }
CustomTransitionPage<dynamic> _noAnimationTransition( CustomTransitionPage<dynamic> _noAnimationTransition(BuildContext context, GoRouterState state, Widget child) {
BuildContext context, GoRouterState state, Widget child) {
return CustomTransitionPage( return CustomTransitionPage(
key: state.pageKey, key: state.pageKey,
child: child, child: child,

View File

@ -1,4 +1,4 @@
import 'dart:math' as Math; import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -6,9 +6,7 @@ class CirclePainter extends CustomPainter {
final double value; final double value;
final Color color; // New field for color final Color color; // New field for color
CirclePainter(this.value, this.color) { CirclePainter(this.value, this.color);
print("CirclePainter " + value.toString());
}
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
@ -16,7 +14,7 @@ class CirclePainter extends CustomPainter {
..color = color.withOpacity(0.5) // Use the passed color ..color = color.withOpacity(0.5) // Use the passed color
..style = PaintingStyle.fill; ..style = PaintingStyle.fill;
double radius = Math.pow(((value + 5) * 500 / 100) / 1.5, 1.14).toDouble(); double radius = math.pow(((value + 5) * 500 / 100) / 1.5, 1.14).toDouble();
canvas.drawCircle(Offset(55, size.height / 4), radius, paint); canvas.drawCircle(Offset(55, size.height / 4), radius, paint);
} }

View File

@ -1,44 +0,0 @@
import 'package:flutter/material.dart';
class ColorPair {
final Color textColor;
final Color backgroundColor;
final String name;
ColorPair(
{required this.name,
required this.textColor,
required this.backgroundColor});
}
List<ColorPair> colorPairs = [
ColorPair(
name: "origin",
textColor: Color(0xff446F2F),
backgroundColor: Color(0xffC9E7BB)),
ColorPair(
name: "lavender",
textColor: Color(0xff765EAB),
backgroundColor: Color(0xffD3CAE7)),
ColorPair(
name: "orange",
textColor: Color(0xffC78233),
backgroundColor: Color(0xffF0CFA9)),
ColorPair(
name: "rose",
textColor: Color(0xffB15555),
backgroundColor: Color(0xffEBD6D6)),
ColorPair(
name: "mountain",
textColor: Color(0xff1D6289),
backgroundColor: Color(0xffB4D0E0)),
ColorPair(
name: "moon",
textColor: Color(0xff7A83C7),
backgroundColor: Color(0xff393C55)),
ColorPair(
name: "forest",
textColor: Color(0xffC9E7BB),
backgroundColor: Color(0xff4C5847)),
// ...add other color pairs with names...
];

View File

@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
class ColorPair {
final Color textColor;
final Color backgroundColor;
final String name;
ColorPair({required this.name, required this.textColor, required this.backgroundColor});
}
List<ColorPair> colorPairs = [
ColorPair(name: "origin", textColor: const Color(0xff446F2F), backgroundColor: const Color(0xffC9E7BB)),
ColorPair(name: "lavender", textColor: const Color(0xff765EAB), backgroundColor: const Color(0xffD3CAE7)),
ColorPair(name: "orange", textColor: const Color(0xffC78233), backgroundColor: const Color(0xffF0CFA9)),
ColorPair(name: "rose", textColor: const Color(0xffB15555), backgroundColor: const Color(0xffEBD6D6)),
ColorPair(name: "mountain", textColor: const Color(0xff1D6289), backgroundColor: const Color(0xffB4D0E0)),
ColorPair(name: "moon", textColor: const Color(0xff7A83C7), backgroundColor: const Color(0xff393C55)),
ColorPair(name: "forest", textColor: const Color(0xffC9E7BB), backgroundColor: const Color(0xff4C5847)),
];

View File

@ -4,7 +4,7 @@ import 'dart:ui';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../definitions/ColorPairs.dart'; import '../definitions/color_pair.dart';
class PreferencesService { class PreferencesService {
static const _keyColor1 = 'color1'; static const _keyColor1 = 'color1';
@ -138,7 +138,7 @@ class PreferencesService {
while (entryDates.contains(DateFormat('yyyy-MM-dd').format(currentDate))) { while (entryDates.contains(DateFormat('yyyy-MM-dd').format(currentDate))) {
streakCount++; streakCount++;
currentDate = currentDate.subtract(Duration(days: 1)); // Move to the previous day currentDate = currentDate.subtract(const Duration(days: 1)); // Move to the previous day
} }
return streakCount; return streakCount;

View File

@ -1,20 +1,18 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:moody/utils/definitions/ColorPairs.dart'; import 'package:moody/utils/definitions/color_pair.dart';
import 'package:moody/utils/logic/PreferencesService.dart'; import 'package:moody/utils/logic/preferences_service.dart';
class CustomBottomNavigationBar extends StatefulWidget { class CustomBottomNavigationBar extends StatefulWidget {
final int initialSelectedIndex; final int initialSelectedIndex;
CustomBottomNavigationBar({Key? key, this.initialSelectedIndex = 0}) const CustomBottomNavigationBar({Key? key, this.initialSelectedIndex = 0}) : super(key: key);
: super(key: key);
@override @override
_CustomBottomNavigationBarState createState() => State<CustomBottomNavigationBar> createState() => _CustomBottomNavigationBar();
_CustomBottomNavigationBarState();
} }
class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> { class _CustomBottomNavigationBar extends State<CustomBottomNavigationBar> {
late int _selectedIndex; late int _selectedIndex;
@override @override
@ -27,9 +25,7 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
setState(() { setState(() {
_selectedIndex = index; _selectedIndex = index;
}); });
print('Item $index clicked'); var currentRoute = GoRouter.of(context).routeInformationProvider.value.uri.toString();
var currentRoute =
GoRouter.of(context).routeInformationProvider.value.location;
var goToRoute = "/"; var goToRoute = "/";
switch (index) { switch (index) {
case 0: case 0:
@ -50,47 +46,41 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FutureBuilder<ColorPair>( return FutureBuilder<ColorPair>(
future: future: PreferencesService().loadColorPair(), // Async loading of the color
PreferencesService().loadColorPair(), // Async loading of the color
builder: (BuildContext context, AsyncSnapshot<ColorPair> snapshot) { builder: (BuildContext context, AsyncSnapshot<ColorPair> snapshot) {
if (snapshot.connectionState == ConnectionState.done && if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
snapshot.hasData) {
// When data is loaded // When data is loaded
Color backgroundColor = Color backgroundColor = snapshot.data!.backgroundColor; // Use loaded background color
snapshot.data!.backgroundColor; // Use loaded background color
return buildNavigationBar(backgroundColor); return buildNavigationBar(backgroundColor);
} else { } else {
// While loading or if no data, show default or loading indicator // While loading or if no data, show default or loading indicator
return buildNavigationBar( return buildNavigationBar(Colors.white); // Default color or loading indicator
Colors.white); // Default color or loading indicator
} }
}, },
); );
} }
@override
Widget buildNavigationBar(Color backgroundColor) { Widget buildNavigationBar(Color backgroundColor) {
return Container( return Container(
width: 175, width: 175,
margin: EdgeInsets.only(bottom: 30), margin: const EdgeInsets.only(bottom: 30),
padding: EdgeInsets.all(5), padding: const EdgeInsets.all(5),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
border: Border.all(color: Colors.transparent), border: Border.all(color: Colors.transparent),
borderRadius: borderRadius: BorderRadius.circular(35), // Adjust radius to fit your design
BorderRadius.circular(35), // Adjust radius to fit your design
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.grey.withOpacity(0.5), color: Colors.grey.withOpacity(0.5),
spreadRadius: 1, spreadRadius: 1,
blurRadius: 7, blurRadius: 7,
offset: Offset(3, 3), // changes position of shadow offset: const Offset(3, 3), // changes position of shadow
), ),
BoxShadow( BoxShadow(
color: Colors.grey.withOpacity(0.3), color: Colors.grey.withOpacity(0.3),
spreadRadius: 1, spreadRadius: 1,
blurRadius: 5, blurRadius: 5,
offset: Offset(-1, -1), // changes position of shadow offset: const Offset(-1, -1), // changes position of shadow
), ),
// You can add more BoxShadow layers to create more complex shadows // You can add more BoxShadow layers to create more complex shadows
], ],
@ -100,12 +90,9 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
_buildNavItem(Image.asset('assets/icons/icon-analyze.png'), 0, _buildNavItem(Image.asset('assets/icons/icon-analyze.png'), 0, backgroundColor),
backgroundColor), _buildNavItem(Image.asset('assets/icons/icon-logo.png'), 1, backgroundColor),
_buildNavItem( _buildNavItem(Image.asset('assets/icons/icon-settings.png'), 2, backgroundColor),
Image.asset('assets/icons/icon-logo.png'), 1, backgroundColor),
_buildNavItem(Image.asset('assets/icons/icon-settings.png'), 2,
backgroundColor),
], ],
), ),
), ),

View File

@ -8,7 +8,7 @@ class MoodTextAreaWidget extends StatefulWidget {
final bool forceBlinkingCursor; final bool forceBlinkingCursor;
final TextEditingController? controller; final TextEditingController? controller;
MoodTextAreaWidget({ const MoodTextAreaWidget({
Key? key, Key? key,
this.initialText = '', this.initialText = '',
this.isDisabled = false, this.isDisabled = false,
@ -19,10 +19,10 @@ class MoodTextAreaWidget extends StatefulWidget {
}) : super(key: key); }) : super(key: key);
@override @override
_MoodTextAreaWidgetState createState() => _MoodTextAreaWidgetState(); State<MoodTextAreaWidget> createState() => _MoodTextAreaWidget();
} }
class _MoodTextAreaWidgetState extends State<MoodTextAreaWidget> { class _MoodTextAreaWidget extends State<MoodTextAreaWidget> {
late TextEditingController _controller; late TextEditingController _controller;
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();
late bool _isEditingEnabled; late bool _isEditingEnabled;
@ -70,7 +70,6 @@ class _MoodTextAreaWidgetState extends State<MoodTextAreaWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("initialtext######${widget.initialText}");
if (!_isEditingEnabled) _controller.text = widget.initialText; if (!_isEditingEnabled) _controller.text = widget.initialText;
return TextField( return TextField(
controller: _controller, controller: _controller,

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:moody/utils/logic/QuestionGenerator.dart'; import 'package:moody/utils/logic/question_generator.dart';
class QuestionSliderWidget extends StatefulWidget { class QuestionSliderWidget extends StatefulWidget {
final DateTime date; final DateTime date;
@ -11,7 +11,7 @@ class QuestionSliderWidget extends StatefulWidget {
final ValueChanged<double> onSliderPositionChanged; final ValueChanged<double> onSliderPositionChanged;
final Color sliderColor; // parameter for the color final Color sliderColor; // parameter for the color
QuestionSliderWidget({ const QuestionSliderWidget({
Key? key, Key? key,
required this.date, required this.date,
required this.questionText, required this.questionText,
@ -23,10 +23,10 @@ class QuestionSliderWidget extends StatefulWidget {
}) : super(key: key); }) : super(key: key);
@override @override
_QuestionSliderWidgetState createState() => _QuestionSliderWidgetState(); State<QuestionSliderWidget> createState() => _QuestionSliderWidget();
} }
class _QuestionSliderWidgetState extends State<QuestionSliderWidget> { class _QuestionSliderWidget extends State<QuestionSliderWidget> {
bool _showDragText = true; bool _showDragText = true;
SliderChangeData? _sliderData; SliderChangeData? _sliderData;
QuestionGenerator generator = QuestionGenerator(); QuestionGenerator generator = QuestionGenerator();
@ -38,7 +38,6 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
super.initState(); super.initState();
//_sliderData?.value = widget.initialSliderValue; //_sliderData?.value = widget.initialSliderValue;
_sliderData = SliderChangeData(widget.initialSliderValue, 0); _sliderData = SliderChangeData(widget.initialSliderValue, 0);
print("innit");
if (!widget.isSliderEnabled) { if (!widget.isSliderEnabled) {
_showDragText = false; _showDragText = false;
} }
@ -51,13 +50,11 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
} else { } else {
if (!initValSet && changedInitValue != widget.initialSliderValue) { if (!initValSet && changedInitValue != widget.initialSliderValue) {
initValSet = true; initValSet = true;
print("here");
changedInitValue != widget.initialSliderValue; changedInitValue != widget.initialSliderValue;
_sliderData?.value = widget.initialSliderValue; _sliderData?.value = widget.initialSliderValue;
} }
} }
print(_sliderData?.value);
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(0, 150, 20, 0), padding: const EdgeInsets.fromLTRB(0, 150, 20, 0),
child: Column( child: Column(
@ -72,12 +69,12 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
children: [ children: [
Text( Text(
DateFormat('dd MM yyyy').format(widget.date), DateFormat('dd MM yyyy').format(widget.date),
style: TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
SizedBox(height: 10), const SizedBox(height: 10),
Text( Text(
widget.questionText == "" ? generator.getQuestionByDate(widget.date) : widget.questionText, widget.questionText == "" ? generator.getQuestionByDate(widget.date) : widget.questionText,
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
), ),
], ],
), ),
@ -91,7 +88,7 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
data: SliderTheme.of(context).copyWith( data: SliderTheme.of(context).copyWith(
disabledThumbColor: Colors.transparent, disabledThumbColor: Colors.transparent,
activeTrackColor: widget.sliderColor, activeTrackColor: widget.sliderColor,
trackShape: RectangularSliderTrackShape(), trackShape: const RectangularSliderTrackShape(),
inactiveTickMarkColor: Colors.transparent, inactiveTickMarkColor: Colors.transparent,
inactiveTrackColor: Colors.transparent, inactiveTrackColor: Colors.transparent,
valueIndicatorColor: Colors.transparent, valueIndicatorColor: Colors.transparent,

View File

@ -4,17 +4,17 @@ class WhyWidget extends StatefulWidget {
final TextEditingController controller; final TextEditingController controller;
final bool prependWhy; final bool prependWhy;
WhyWidget({ const WhyWidget({
Key? key, Key? key,
required this.controller, required this.controller,
this.prependWhy = true, this.prependWhy = true,
}) : super(key: key); }) : super(key: key);
@override @override
_WhyWidgetState createState() => _WhyWidgetState(); State<WhyWidget> createState() => _WhyWidget();
} }
class _WhyWidgetState extends State<WhyWidget> { class _WhyWidget extends State<WhyWidget> {
//final TextEditingController _controller = TextEditingController(text: "warum? "); //final TextEditingController _controller = TextEditingController(text: "warum? ");
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();

View File

@ -1,19 +1,21 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/BottomNavigationWidget.dart'; import '../../utils/widgets/custom_bottom_navigation_bar.dart';
// ...Include PreferencesService and other necessary imports // ...Include PreferencesService and other necessary imports
class ColorPage extends StatefulWidget { class ColorPage extends StatefulWidget {
const ColorPage({super.key});
@override @override
_ColorPageState createState() => _ColorPageState(); State<ColorPage> createState() => _ColorPage();
} }
class _ColorPageState extends State<ColorPage> { class _ColorPage extends State<ColorPage> {
int? selectedColorIndex; // Index of the selected color int? selectedColorIndex; // Index of the selected color
@override @override
@ -25,20 +27,13 @@ class _ColorPageState extends State<ColorPage> {
// Load selected color from preferences // Load selected color from preferences
void _loadSelectedColor() async { void _loadSelectedColor() async {
ColorPair? savedColorPair = await PreferencesService().loadColorPair(); ColorPair? savedColorPair = await PreferencesService().loadColorPair();
if (savedColorPair != null) { // Find the index of the saved color in the colorPairs list
// Find the index of the saved color in the colorPairs list int index = colorPairs.indexWhere(
int index = colorPairs.indexWhere( (pair) => pair.backgroundColor.value == savedColorPair.backgroundColor.value && pair.textColor.value == savedColorPair.textColor.value,
(pair) => pair.backgroundColor.value == savedColorPair.backgroundColor.value && pair.textColor.value == savedColorPair.textColor.value, );
); if (index != -1) {
if (index != -1) {
setState(() {
selectedColorIndex = index;
});
}
} else {
// If no color is selected, default to the first one
setState(() { setState(() {
selectedColorIndex = 0; selectedColorIndex = index;
}); });
} }
} }
@ -83,7 +78,7 @@ class _ColorPageState extends State<ColorPage> {
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 2), floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 2),
); );
} }
@ -101,7 +96,7 @@ class _ColorPageState extends State<ColorPage> {
child: Container( child: Container(
width: bubbleWidth, width: bubbleWidth,
height: bubbleWidth, height: bubbleWidth,
padding: EdgeInsets.all(10), // Padding for inner circle effect padding: const EdgeInsets.all(10), // Padding for inner circle effect
decoration: BoxDecoration( decoration: BoxDecoration(
color: colorPairs[index].backgroundColor, color: colorPairs[index].backgroundColor,
shape: BoxShape.circle, shape: BoxShape.circle,

View File

@ -2,24 +2,24 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import '../../utils/CirclePainter.dart'; import '../../utils/circle_painter.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/BottomNavigationWidget.dart'; import '../../utils/widgets/custom_bottom_navigation_bar.dart';
import '../../utils/widgets/MoodTextArea.dart'; import '../../utils/widgets/mood_text_area_widget.dart';
import '../../utils/widgets/QuestionSliderWidget.dart'; import '../../utils/widgets/question_slider_widget.dart';
class EntryPage extends StatefulWidget { class EntryPage extends StatefulWidget {
final DateTime date; final DateTime date;
EntryPage({Key? key, required this.date}) : super(key: key); const EntryPage({Key? key, required this.date}) : super(key: key);
@override @override
_EntryPageState createState() => _EntryPageState(); State<EntryPage> createState() => _EntryPage();
} }
class _EntryPageState extends State<EntryPage> { class _EntryPage extends State<EntryPage> {
SliderChangeData sliderData = SliderChangeData(0, 0); SliderChangeData sliderData = SliderChangeData(0, 0);
String _moodText = ""; String _moodText = "";
final PreferencesService _prefsService = PreferencesService(); final PreferencesService _prefsService = PreferencesService();
@ -59,7 +59,7 @@ class _EntryPageState extends State<EntryPage> {
}); });
} }
// _textController.text = _moodText; // _textController.text = _moodText;
_textController.text = currentEntry != null ? currentEntry!.texts.join(" ") : _moodText; _textController.text = (currentEntry != null ? currentEntry.texts.join(" ") : _moodText);
} }
void _toggleEdit() { void _toggleEdit() {
@ -72,7 +72,7 @@ class _EntryPageState extends State<EntryPage> {
} }
void _saveEntry() async { void _saveEntry() async {
print("saveEntry...."); //print("saveEntry...."); Todo for future versions
} }
@override @override
@ -114,11 +114,11 @@ class _EntryPageState extends State<EntryPage> {
child: Column( child: Column(
children: [ children: [
Text( Text(
sliderData.value.toString() + "%", "${sliderData.value}%",
style: TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
), ),
Text(DateFormat('dd MM yyyy').format(widget.date).toString(), Text(DateFormat('dd MM yyyy').format(widget.date).toString(),
style: TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold)), style: const TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold)),
], ],
), ),
), ),
@ -138,7 +138,7 @@ class _EntryPageState extends State<EntryPage> {
style: TextStyle(fontSize: 18, color: textColor), // Use appropriate styling style: TextStyle(fontSize: 18, color: textColor), // Use appropriate styling
), ),
), ),
SizedBox(height: 400), // Space for floating bottom navigation bar const SizedBox(height: 400), // Space for floating bottom navigation bar
], ],
), ),
], ],
@ -146,7 +146,7 @@ class _EntryPageState extends State<EntryPage> {
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 0), floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 0),
); );
} }
} }

View File

@ -1,11 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:moody/utils/widgets/QuestionSliderWidget.dart'; import 'package:moody/utils/widgets/question_slider_widget.dart';
import '../../utils/CirclePainter.dart'; import '../../utils/circle_painter.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
class FirstPage extends StatefulWidget { class FirstPage extends StatefulWidget {
final bool showSkipText; // Add this line final bool showSkipText; // Add this line
@ -14,10 +15,10 @@ class FirstPage extends StatefulWidget {
: super(key: key); : super(key: key);
@override @override
_FirstPageState createState() => _FirstPageState(); State<FirstPage> createState() => _FirstPage();
} }
class _FirstPageState extends State<FirstPage> { class _FirstPage extends State<FirstPage> {
SliderChangeData sliderData = SliderChangeData(0, 50); SliderChangeData sliderData = SliderChangeData(0, 50);
bool _sliderChanged = false; bool _sliderChanged = false;
final PreferencesService _prefsService = PreferencesService(); final PreferencesService _prefsService = PreferencesService();
@ -33,9 +34,9 @@ class _FirstPageState extends State<FirstPage> {
} }
void _checkExistingEntry() async { void _checkExistingEntry() async {
WidgetsBinding.instance?.addPostFrameCallback((_) async { WidgetsBinding.instance.addPostFrameCallback((_) async {
DiaryEntry? entry = await _prefsService.getDiaryEntryByCurrentDate(); DiaryEntry? entry = await _prefsService.getDiaryEntryByCurrentDate();
if (entry != null) { if (entry != null && mounted) {
context.go('/home'); context.go('/home');
} }
}); });
@ -60,7 +61,9 @@ class _FirstPageState extends State<FirstPage> {
await _prefsService.saveDiaryEntry(entry); await _prefsService.saveDiaryEntry(entry);
} catch (e) { } catch (e) {
print("Error saving entry: $e"); // Consider showing an error dialog or toast instead if (kDebugMode) {
print("Error saving entry: $e");
} // Consider showing an error dialog or toast instead
} }
} }
@ -91,7 +94,7 @@ class _FirstPageState extends State<FirstPage> {
children: [ children: [
QuestionSliderWidget( QuestionSliderWidget(
onSliderPositionChanged: (value) { onSliderPositionChanged: (value) {
print("sliderposchanged"); //print("slider Moved");
}, },
sliderColor: textColor, sliderColor: textColor,
date: DateTime.now(), date: DateTime.now(),
@ -129,7 +132,6 @@ class _FirstPageState extends State<FirstPage> {
right: 20, right: 20,
child: TextButton( child: TextButton(
onPressed: () { onPressed: () {
print(_sliderChanged);
if (_sliderChanged) { if (_sliderChanged) {
_saveEntry(); _saveEntry();
context.go('/home', extra: sliderData.value); context.go('/home', extra: sliderData.value);
@ -141,7 +143,7 @@ class _FirstPageState extends State<FirstPage> {
? Text("save.", style: TextStyle(fontSize: 18, color: textColor)) ? Text("save.", style: TextStyle(fontSize: 18, color: textColor))
: widget.showSkipText // Use the showSkipText parameter : widget.showSkipText // Use the showSkipText parameter
? const Text("skip", style: TextStyle(fontSize: 18, color: Colors.grey)) ? const Text("skip", style: TextStyle(fontSize: 18, color: Colors.grey))
: SizedBox.shrink(), : const SizedBox.shrink(),
), ),
), ),
], ],

View File

@ -1,13 +1,15 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../utils/CirclePainter.dart'; import '../../../utils/circle_painter.dart';
class DragWidget extends StatefulWidget { class DragWidget extends StatefulWidget {
const DragWidget({super.key});
@override @override
_DragWidgetState createState() => _DragWidgetState(); State<DragWidget> createState() => _DragWidget();
} }
class _DragWidgetState extends State<DragWidget> { class _DragWidget extends State<DragWidget> {
double _sliderValue = 0.0; double _sliderValue = 0.0;
@override @override
@ -28,7 +30,7 @@ class _DragWidgetState extends State<DragWidget> {
padding: const EdgeInsets.only(top: 20.0, left: 20.0), padding: const EdgeInsets.only(top: 20.0, left: 20.0),
child: Text( child: Text(
"${DateTime.now().toLocal()}", "${DateTime.now().toLocal()}",
style: TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
), ),
const Padding( const Padding(
@ -38,7 +40,7 @@ class _DragWidgetState extends State<DragWidget> {
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
), ),
), ),
SizedBox(height: 32), // 2 line padding const SizedBox(height: 32), // 2 line padding
SliderTheme( SliderTheme(
data: SliderTheme.of(context).copyWith( data: SliderTheme.of(context).copyWith(
trackShape: CustomTrackShape(), trackShape: CustomTrackShape(),
@ -57,10 +59,10 @@ class _DragWidgetState extends State<DragWidget> {
), ),
if (_sliderValue > 0) if (_sliderValue > 0)
Padding( Padding(
padding: EdgeInsets.only(left: 20.0), padding: const EdgeInsets.only(left: 20.0),
child: Text( child: Text(
"${_sliderValue.toStringAsFixed(0)}%", "${_sliderValue.toStringAsFixed(0)}%",
style: TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
), ),
], ],
@ -82,8 +84,7 @@ class CustomTrackShape extends RoundedRectSliderTrackShape {
}) { }) {
final double trackHeight = sliderTheme.trackHeight ?? 4; final double trackHeight = sliderTheme.trackHeight ?? 4;
final double trackLeft = offset.dx; final double trackLeft = offset.dx;
final double trackTop = final double trackTop = offset.dy + (parentBox.size.height - trackHeight) / 2;
offset.dy + (parentBox.size.height - trackHeight) / 2;
final double trackWidth = parentBox.size.width; final double trackWidth = parentBox.size.width;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight); return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
} }

View File

@ -1,13 +1,14 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:moody/utils/definitions/style_guide.dart'; import 'package:moody/utils/definitions/style_guide.dart';
import 'package:moody/views/first_page/first_page.dart'; import 'package:moody/views/first_page/first_page.dart';
import '../../utils/CirclePainter.dart'; import '../../utils/circle_painter.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/BottomNavigationWidget.dart'; import '../../utils/widgets/custom_bottom_navigation_bar.dart';
import '../../utils/widgets/QuestionSliderWidget.dart'; import '../../utils/widgets/question_slider_widget.dart';
import '../../utils/widgets/WhyWidget.dart'; import '../../utils/widgets/why_widget.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({super.key}); const HomePage({super.key});
@ -18,7 +19,6 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
SliderChangeData sliderData = SliderChangeData(0, 0); SliderChangeData sliderData = SliderChangeData(0, 0);
String _moodText = "";
bool _isTextAreaEditable = false; bool _isTextAreaEditable = false;
final PreferencesService _prefsService = PreferencesService(); final PreferencesService _prefsService = PreferencesService();
Color backgroundColor = Colors.lightGreenAccent; Color backgroundColor = Colors.lightGreenAccent;
@ -45,15 +45,11 @@ class _HomePageState extends State<HomePage> {
void _loadCurrentDiaryEntry() async { void _loadCurrentDiaryEntry() async {
DiaryEntry? currentEntry = await _prefsService.getDiaryEntryByCurrentDate(); DiaryEntry? currentEntry = await _prefsService.getDiaryEntryByCurrentDate();
if (currentEntry != null) { if (currentEntry != null) {
print(currentEntry.texts.join(" "));
setState(() { setState(() {
sliderData.value = currentEntry.percentValue.toDouble(); sliderData.value = currentEntry.percentValue.toDouble();
print(currentEntry.percentValue);
_moodText = currentEntry.texts.join(" "); // Assuming you want to concatenate all texts
_textController.text = currentEntry.texts.join(" "); _textController.text = currentEntry.texts.join(" ");
}); });
setState(() {}); setState(() {});
print(sliderData.value);
} else { } else {
setState(() { setState(() {
noData = true; noData = true;
@ -73,7 +69,6 @@ class _HomePageState extends State<HomePage> {
void _saveEntry() async { void _saveEntry() async {
try { try {
List<String> texts = _textController.text.isEmpty ? [] : [_textController.text]; List<String> texts = _textController.text.isEmpty ? [] : [_textController.text];
print("DerText:${_textController.text}");
DiaryEntry entry = DiaryEntry( DiaryEntry entry = DiaryEntry(
date: DateTime.now(), date: DateTime.now(),
percentValue: sliderData.value.toInt(), percentValue: sliderData.value.toInt(),
@ -82,15 +77,17 @@ class _HomePageState extends State<HomePage> {
await _prefsService.saveDiaryEntry(entry); await _prefsService.saveDiaryEntry(entry);
} catch (e) { } catch (e) {
print("Error saving entry: $e"); if (kDebugMode) {
print("Error saving entry: $e");
}
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return noData return noData
? Scaffold( ? const Scaffold(
body: const FirstPage(showSkipText: false), body: FirstPage(showSkipText: false),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1), floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1),
) )
@ -113,7 +110,7 @@ class _HomePageState extends State<HomePage> {
children: [ children: [
QuestionSliderWidget( QuestionSliderWidget(
onSliderPositionChanged: (value) { onSliderPositionChanged: (value) {
print("sliderposchanged"); //print("Slider moved");
}, },
sliderColor: textColor, sliderColor: textColor,
date: DateTime.now(), date: DateTime.now(),
@ -169,7 +166,7 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1), floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 1),
); );
} }
} }

View File

@ -1,100 +0,0 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: CalendarPage(),
);
}
}
class CalendarPage extends StatefulWidget {
@override
_CalendarPageState createState() => _CalendarPageState();
}
class _CalendarPageState extends State<CalendarPage> {
DateTime currentDate = DateTime.now();
late List<DateTime> dateList;
@override
void initState() {
super.initState();
dateList = _generateDateList(currentDate);
}
List<DateTime> _generateDateList(DateTime date) {
List<DateTime> list = [];
DateTime firstOfMonth = DateTime(date.year, date.month, 1);
int dayOfWeek = firstOfMonth.weekday;
// Adjust to Monday start
int startDay = dayOfWeek - 1;
if (startDay < 0) startDay = 6;
// Dates from previous month
for (int i = startDay; i > 0; i--) {
list.add(firstOfMonth.subtract(Duration(days: i)));
}
// Dates of current month
int daysInMonth = DateUtils.getDaysInMonth(date.year, date.month);
for (int i = 0; i < daysInMonth; i++) {
list.add(DateTime(date.year, date.month, i + 1));
}
return list;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Calendar"),
),
body: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
),
itemBuilder: (context, index) {
double radius =
(Random().nextInt(50).toDouble() + 20) / 2; // Reduced by 50%
DateTime date = dateList[index];
return Center(
child: Container(
width: radius * 2,
height: radius * 2,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.black, width: 2),
),
child: Center(
child: Container(
width: radius,
height: radius,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.lightGreen,
),
child: Center(
child: Text(
DateFormat("d").format(date),
style: TextStyle(color: Colors.black),
),
),
),
),
),
);
},
itemCount: dateList.length,
),
);
}
}

View File

@ -2,18 +2,20 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/BottomNavigationWidget.dart'; import '../../utils/widgets/custom_bottom_navigation_bar.dart';
import 'widgets/CustomDivider.dart'; import 'widgets/custom_divider_widget.dart';
import 'widgets/SetPinPopup.dart'; import 'widgets/set_pin_popup_widget.dart';
import 'widgets/TextSwitchContainer.dart'; import 'widgets/text_switch_container_widget.dart';
class SettingsPage extends StatefulWidget { class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@override @override
_SettingsPageState createState() => _SettingsPageState(); State<SettingsPage> createState() => _SettingsPage();
} }
class _SettingsPageState extends State<SettingsPage> { class _SettingsPage extends State<SettingsPage> {
bool isPinEnabled = false; // Default to false bool isPinEnabled = false; // Default to false
@override @override
@ -32,7 +34,7 @@ class _SettingsPageState extends State<SettingsPage> {
return Scaffold( return Scaffold(
backgroundColor: AppStyle.backgroundColor, backgroundColor: AppStyle.backgroundColor,
body: Container( body: Container(
padding: EdgeInsets.only(bottom: 0), padding: const EdgeInsets.only(bottom: 0),
margin: const EdgeInsets.fromLTRB(30, 30, 30, 0), margin: const EdgeInsets.fromLTRB(30, 30, 30, 0),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
@ -43,20 +45,20 @@ class _SettingsPageState extends State<SettingsPage> {
// Settings section // Settings section
Container( Container(
margin: EdgeInsets.only(bottom: 10), margin: const EdgeInsets.only(bottom: 10),
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: Text('settings', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)), child: const Text('settings', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
), ),
TextSwitchContainer( TextSwitchContainer(
leftText: "change color", leftText: "change color",
onTap: () => context.go("/color"), onTap: () => context.go("/color"),
), ),
CustomDivider(), const CustomDivider(),
FutureBuilder<bool>( FutureBuilder<bool>(
future: PreferencesService().isPinEnabled(), future: PreferencesService().isPinEnabled(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // or some other placeholder return const CircularProgressIndicator(); // or some other placeholder
} }
bool pinEnabled = snapshot.data ?? false; // Default to false if null bool pinEnabled = snapshot.data ?? false; // Default to false if null
return TextSwitchContainer( return TextSwitchContainer(
@ -75,63 +77,63 @@ class _SettingsPageState extends State<SettingsPage> {
); );
}, },
), ),
CustomDivider(), const CustomDivider(),
TextSwitchContainer( TextSwitchContainer(
leftText: "your data", leftText: "your data",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
// Community section // Community section
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10), padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
child: Container( child: Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
margin: EdgeInsets.only(bottom: 10), margin: const EdgeInsets.only(bottom: 10),
child: Text('community', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)), child: const Text('community', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
), ),
), ),
TextSwitchContainer( TextSwitchContainer(
leftText: "join our discord", leftText: "join our discord",
rightText: "fulfilled", rightText: "fulfilled",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
CustomDivider(), const CustomDivider(),
TextSwitchContainer( TextSwitchContainer(
leftText: "our instagram", leftText: "our instagram",
rightText: "@get.fulfilled", rightText: "@get.fulfilled",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
CustomDivider(), const CustomDivider(),
TextSwitchContainer( TextSwitchContainer(
leftText: "share fulfilled with your loved ones", leftText: "share fulfilled with your loved ones",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10), padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
child: Container( child: Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: Text('humans behind fulfilled', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)), child: const Text('humans behind fulfilled', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
), ),
), ),
TextSwitchContainer( TextSwitchContainer(
leftText: "about us", leftText: "about us",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
CustomDivider(), const CustomDivider(),
TextSwitchContainer( TextSwitchContainer(
leftText: "support us", leftText: "support us",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
CustomDivider(), const CustomDivider(),
TextSwitchContainer( TextSwitchContainer(
leftText: "give feedback", leftText: "give feedback",
onTap: () => print('Container tapped'), onTap: () => {},
), ),
// //
ListTile( ListTile(
title: Text('imprint & privacy policy', style: TextStyle(color: Colors.grey, fontSize: 15)), title: const Text('imprint & privacy policy', style: TextStyle(color: Colors.grey, fontSize: 15)),
onTap: () => {}, // Implement your logic onTap: () => {}, // Implement your logic
), ),
SizedBox( const SizedBox(
height: 150, height: 150,
) )
], ],
@ -139,7 +141,7 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 2), floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 2),
); );
} }
@ -147,7 +149,7 @@ class _SettingsPageState extends State<SettingsPage> {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return SetPinPopup(); return const SetPinPopup();
}, },
); );
} }

View File

@ -3,20 +3,21 @@ import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import '../../../utils/logic/PreferencesService.dart'; // For HapticFeedback import '../../../utils/logic/preferences_service.dart'; // For HapticFeedback
// ...Include PreferencesService and other necessary imports // ...Include PreferencesService and other necessary imports
class SetPinPopup extends StatefulWidget { class SetPinPopup extends StatefulWidget {
const SetPinPopup({super.key});
@override @override
_SetPinPopupState createState() => _SetPinPopupState(); State<SetPinPopup> createState() => _SetPinPopup();
} }
class _SetPinPopupState extends State<SetPinPopup> { class _SetPinPopup extends State<SetPinPopup> {
String _pin = ''; String _pin = '';
String _confirmedPin = ''; String _confirmedPin = '';
bool _isSettingPin = bool _isSettingPin = true; // True if setting the PIN, false if confirming the PIN
true; // True if setting the PIN, false if confirming the PIN
static const int pinLength = 4; static const int pinLength = 4;
@ -55,12 +56,11 @@ class _SetPinPopupState extends State<SetPinPopup> {
Widget _buildNumberButton(int number) { Widget _buildNumberButton(int number) {
return GestureDetector( return GestureDetector(
onTap: () => _onNumberTap(number), onTap: () => _onNumberTap(number),
onTapDown: (_) => onTapDown: (_) => HapticFeedback.lightImpact(), // Cool haptic feedback on tap
HapticFeedback.lightImpact(), // Cool haptic feedback on tap
child: Container( child: Container(
width: 70, width: 70,
height: 70, height: 70,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
border: Border.all(color: Colors.black), border: Border.all(color: Colors.black),
@ -69,7 +69,7 @@ class _SetPinPopupState extends State<SetPinPopup> {
child: Center( child: Center(
child: Text( child: Text(
number.toString(), number.toString(),
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
), ),
), ),
), ),
@ -85,8 +85,7 @@ class _SetPinPopupState extends State<SetPinPopup> {
} }
}); });
if ((_isSettingPin && _pin.length == pinLength) || if ((_isSettingPin && _pin.length == pinLength) || (!_isSettingPin && _confirmedPin.length == pinLength)) {
(!_isSettingPin && _confirmedPin.length == pinLength)) {
if (!_isSettingPin && _pin == _confirmedPin) { if (!_isSettingPin && _pin == _confirmedPin) {
// Call setPin and enablePin methods, assuming they are async // Call setPin and enablePin methods, assuming they are async
PreferencesService().setPin(int.parse(_pin)); PreferencesService().setPin(int.parse(_pin));
@ -117,35 +116,28 @@ class _SetPinPopupState extends State<SetPinPopup> {
child: Container( child: Container(
height: 600, height: 600,
width: 400, width: 400,
decoration: BoxDecoration( decoration: const BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50))),
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(50))),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text(_isSettingPin ? 'Set a PIN' : 'Repeat PIN', Text(_isSettingPin ? 'Set a PIN' : 'Repeat PIN', style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), const SizedBox(height: 20),
SizedBox(height: 20),
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: List.generate(pinLength, (index) { children: List.generate(pinLength, (index) {
return Container( return Container(
margin: EdgeInsets.all(4), margin: const EdgeInsets.all(4),
width: 15, width: 15,
height: 15, height: 15,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: (_isSettingPin ? _pin.length : _confirmedPin.length) > index ? Colors.black : Colors.transparent,
(_isSettingPin ? _pin.length : _confirmedPin.length) >
index
? Colors.black
: Colors.transparent,
border: Border.all(color: Colors.grey), border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
); );
}), }),
), ),
SizedBox(height: 20), const SizedBox(height: 20),
..._buildNumberPad(), ..._buildNumberPad(),
], ],
), ),

View File

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -5,8 +6,7 @@ class SettingsSection extends StatelessWidget {
final String title; final String title;
final List<SettingsItem> items; final List<SettingsItem> items;
SettingsSection({Key? key, required this.title, required this.items}) const SettingsSection({Key? key, required this.title, required this.items}) : super(key: key);
: super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -14,11 +14,10 @@ class SettingsSection extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
title, title,
style: TextStyle( style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
), ),
), ),
...items.map((item) => _buildItem(item)).toList(), ...items.map((item) => _buildItem(item)).toList(),
@ -36,9 +35,9 @@ class SettingsSection extends StatelessWidget {
? GestureDetector( ? GestureDetector(
child: Text( child: Text(
item.trailingText ?? "", item.trailingText ?? "",
style: TextStyle(color: Colors.grey), style: const TextStyle(color: Colors.grey),
), ),
onTap: () => _launchURL(item.url!), onTap: () => _launchURL(Uri.parse(item.url!)),
) )
: null, : null,
onTap: item.onTap, onTap: item.onTap,
@ -47,11 +46,13 @@ class SettingsSection extends StatelessWidget {
); );
} }
void _launchURL(String url) async { void _launchURL(Uri url) async {
if (await canLaunch(url)) { if (await canLaunchUrl(url)) {
await launch(url); await launchUrl(url);
} else { } else {
print("Could not launch $url"); if (kDebugMode) {
print("Could not launch $url");
}
} }
} }
} }

View File

@ -1,15 +1,19 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../utils/definitions/color_pair.dart';
import '../../../utils/logic/preferences_service.dart';
class TextSwitchContainer extends StatefulWidget { class TextSwitchContainer extends StatefulWidget {
final String leftText; final String leftText;
final String? rightText; final String? rightText;
final bool hasSwitch; final bool hasSwitch;
final Function onTap; final Function onTap;
final Function(bool)? onSwitchToggle; final Function(bool)? onSwitchToggle;
final bool switchDefaultValue; // Added parameter for the default switch value final bool switchDefaultValue; // Parameter for the default switch value
TextSwitchContainer({ const TextSwitchContainer({
super.key,
required this.leftText, required this.leftText,
this.rightText, this.rightText,
this.hasSwitch = false, this.hasSwitch = false,
@ -19,33 +23,46 @@ class TextSwitchContainer extends StatefulWidget {
}); });
@override @override
_TextSwitchContainerState createState() => State<TextSwitchContainer> createState() => _TextSwitchContainer();
_TextSwitchContainerState(switchValue: this.switchDefaultValue);
} }
class _TextSwitchContainerState extends State<TextSwitchContainer> { class _TextSwitchContainer extends State<TextSwitchContainer> {
bool switchValue; // No longer explicitly initialized here late bool switchValue;
Color backgroundColor = Colors.white; // Default value
Color textColor = Colors.black; // Default value
_TextSwitchContainerState( @override
{required this.switchValue}); // Constructor takes the initial switch value void initState() {
super.initState();
switchValue = widget.switchDefaultValue; // Initialize switchValue here
_loadColor();
}
void _loadColor() async {
ColorPair colorPair = await PreferencesService().loadColorPair();
setState(() {
backgroundColor = colorPair.backgroundColor;
textColor = colorPair.textColor;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () => widget.onTap(), onTap: () => widget.onTap(),
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 0, vertical: 20), padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 20),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
widget.leftText, widget.leftText,
style: TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
if (widget.hasSwitch) if (widget.hasSwitch)
CupertinoSwitch( CupertinoSwitch(
trackColor: Colors.white, trackColor: Colors.white,
thumbColor: switchValue ? Colors.lightGreen : Colors.grey, thumbColor: switchValue ? backgroundColor : Colors.grey,
value: switchValue, value: switchValue,
onChanged: (newValue) { onChanged: (newValue) {
setState(() { setState(() {
@ -60,7 +77,7 @@ class _TextSwitchContainerState extends State<TextSwitchContainer> {
else if (widget.rightText != null) else if (widget.rightText != null)
Text( Text(
widget.rightText!, widget.rightText!,
style: TextStyle(fontSize: 16, color: Colors.grey), style: const TextStyle(fontSize: 16, color: Colors.grey),
), ),
], ],
), ),

View File

@ -1,14 +1,17 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; // For Haptic Feedback import '../../utils/logic/preferences_service.dart'; // For Haptic Feedback
class StartPage extends StatelessWidget { class StartPage extends StatelessWidget {
const StartPage({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return const MaterialApp(
title: 'PIN Input', title: 'PIN Input',
home: PinInputScreen(), home: PinInputScreen(),
); );
@ -16,11 +19,13 @@ class StartPage extends StatelessWidget {
} }
class PinInputScreen extends StatefulWidget { class PinInputScreen extends StatefulWidget {
const PinInputScreen({super.key});
@override @override
_PinInputScreenState createState() => _PinInputScreenState(); State<PinInputScreen> createState() => _PinInputScreen();
} }
class _PinInputScreenState extends State<PinInputScreen> { class _PinInputScreen extends State<PinInputScreen> {
String _pin = ''; String _pin = '';
static const int pinLength = 4; static const int pinLength = 4;
@ -31,11 +36,13 @@ class _PinInputScreenState extends State<PinInputScreen> {
} }
Future<void> _checkPinStatus() async { Future<void> _checkPinStatus() async {
bool pinEnabled = await PreferencesService().isPinEnabled(); // Adjust with actual implementation bool pinEnabled = await PreferencesService().isPinEnabled();
if (!pinEnabled) { if (!pinEnabled) {
// If no PIN is enabled, navigate to the "/first" route. Future.microtask(() {
// Navigator context will be available after the widget build. if (mounted) {
Future.microtask(() => context.go("/first")); context.go("/first");
}
});
} }
} }
@ -61,12 +68,15 @@ class _PinInputScreenState extends State<PinInputScreen> {
Future<void> _validatePin() async { Future<void> _validatePin() async {
bool correct = await checkPin(int.parse(_pin)); bool correct = await checkPin(int.parse(_pin));
if (correct) { if (correct) {
print("Right"); if (mounted) {
context.go("/first"); context.go("/first");
}
// Perform any actions you need on successful pin entry // Perform any actions you need on successful pin entry
} else { } else {
// Handle wrong pin entry, e.g., reset pin, show error, etc. // Handle wrong pin entry, e.g., reset pin, show error, etc.
print("Wrong PIN"); if (kDebugMode) {
print("Wrong PIN");
}
} }
// Resetting the PIN for this example, you might want to do this differently // Resetting the PIN for this example, you might want to do this differently
@ -91,17 +101,17 @@ class _PinInputScreenState extends State<PinInputScreen> {
child: Container( child: Container(
height: 600, height: 600,
width: 400, width: 400,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50))), decoration: const BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(50))),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text('Welcome Back!', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), const Text('Welcome Back!', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
SizedBox(height: 20), const SizedBox(height: 20),
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: List.generate(pinLength, (index) { children: List.generate(pinLength, (index) {
return Container( return Container(
margin: EdgeInsets.all(4), margin: const EdgeInsets.all(4),
width: 15, width: 15,
height: 15, height: 15,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -112,7 +122,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
); );
}), }),
), ),
SizedBox(height: 20), const SizedBox(height: 20),
..._buildNumberPad(), ..._buildNumberPad(),
], ],
), ),
@ -160,7 +170,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
child: Container( child: Container(
width: 70, width: 70,
height: 70, height: 70,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black), border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(35), borderRadius: BorderRadius.circular(35),
@ -168,7 +178,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
child: Center( child: Center(
child: Text( child: Text(
number.toString(), number.toString(),
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
), ),
), ),
), ),

View File

@ -2,17 +2,19 @@ import 'package:flutter/material.dart';
import 'package:moody/views/statistic/widget/calendar_widget.dart'; import 'package:moody/views/statistic/widget/calendar_widget.dart';
import 'package:moody/views/statistic/widget/streak_widget.dart'; import 'package:moody/views/statistic/widget/streak_widget.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/BottomNavigationWidget.dart'; import '../../utils/widgets/custom_bottom_navigation_bar.dart';
class StatisticPage extends StatefulWidget { class StatisticPage extends StatefulWidget {
const StatisticPage({super.key});
@override @override
_StatisticPageState createState() => _StatisticPageState(); State<StatisticPage> createState() => _StatisticPage();
} }
class _StatisticPageState extends State<StatisticPage> { class _StatisticPage extends State<StatisticPage> {
Color backgroundColor = Colors.white; // Default fallback color Color backgroundColor = Colors.white; // Default fallback color
Color textColor = Colors.black; // Default fallback color Color textColor = Colors.black; // Default fallback color
final ScrollController _scrollController = ScrollController(); final ScrollController _scrollController = ScrollController();
@ -47,7 +49,7 @@ class _StatisticPageState extends State<StatisticPage> {
child: Scaffold( child: Scaffold(
backgroundColor: AppStyle.backgroundColor, backgroundColor: AppStyle.backgroundColor,
body: Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ body: Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
SizedBox( const SizedBox(
height: 50, height: 50,
), ),
Column( Column(
@ -61,11 +63,11 @@ class _StatisticPageState extends State<StatisticPage> {
color: backgroundColor, color: backgroundColor,
); );
} else { } else {
return CircularProgressIndicator(); // or some placeholder return const CircularProgressIndicator(); // or some placeholder
} }
}, },
), ),
Text( const Text(
"browse your memories!", "browse your memories!",
style: TextStyle(fontSize: 24), style: TextStyle(fontSize: 24),
), ),
@ -76,11 +78,11 @@ class _StatisticPageState extends State<StatisticPage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
SizedBox(height: 50), const SizedBox(height: 50),
Container(child: CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 2, 1))), CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 2, 1)),
Container(child: CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 1, 1))), CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 1, 1)),
Container(child: CalendarWidget(currentDate: DateTime.now())), CalendarWidget(currentDate: DateTime.now()),
SizedBox( const SizedBox(
height: 50, height: 50,
) )
], ],
@ -89,7 +91,7 @@ class _StatisticPageState extends State<StatisticPage> {
), ),
]), ]),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 0), floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 0),
), ),
), ),
); );

View File

@ -2,19 +2,19 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import '../../../utils/definitions/ColorPairs.dart'; import '../../../utils/definitions/color_pair.dart';
import '../../../utils/logic/PreferencesService.dart'; // Correct the path as necessary import '../../../utils/logic/preferences_service.dart'; // Correct the path as necessary
class CalendarWidget extends StatefulWidget { class CalendarWidget extends StatefulWidget {
final DateTime currentDate; final DateTime currentDate;
CalendarWidget({Key? key, required this.currentDate}) : super(key: key); const CalendarWidget({Key? key, required this.currentDate}) : super(key: key);
@override @override
_CalendarWidgetState createState() => _CalendarWidgetState(); State<CalendarWidget> createState() => _CalendarWidget();
} }
class _CalendarWidgetState extends State<CalendarWidget> { class _CalendarWidget extends State<CalendarWidget> {
List<DateTime> dateList = []; // Initialized immediately as an empty list List<DateTime> dateList = []; // Initialized immediately as an empty list
Map<String, DiaryEntry?> diaryEntries = {}; // Holds diary entries by date Map<String, DiaryEntry?> diaryEntries = {}; // Holds diary entries by date
late ColorPair currentColorPair; // Holds the current color pair late ColorPair currentColorPair; // Holds the current color pair
@ -28,7 +28,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
void _loadColorPairAndDiaryData() async { void _loadColorPairAndDiaryData() async {
// Load color pair // Load color pair
currentColorPair = await PreferencesService().loadColorPair() ?? colorPairs[0]; currentColorPair = await PreferencesService().loadColorPair();
// Generate date list // Generate date list
//dateList = _generateDateList(widget.currentDate); //dateList = _generateDateList(widget.currentDate);
@ -67,7 +67,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
// Adjust list to end with a complete week // Adjust list to end with a complete week
while (list.length % 7 != 0) { while (list.length % 7 != 0) {
list.add(list.last.add(Duration(days: 1))); list.add(list.last.add(const Duration(days: 1)));
} }
return list; return list;
@ -82,24 +82,24 @@ class _CalendarWidgetState extends State<CalendarWidget> {
future: PreferencesService().loadColorPair(), future: PreferencesService().loadColorPair(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (!snapshot.hasData) { if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
ColorPair colorPair = snapshot.data!; ColorPair colorPair = snapshot.data!;
return Container( return SizedBox(
height: 360 + addon, height: 360 + addon,
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric(vertical: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Text(monthName, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), // Month Header child: Text(monthName, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), // Month Header
), ),
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(25, 0, 25, 0), padding: const EdgeInsets.fromLTRB(25, 0, 25, 0),
child: GridView.builder( child: GridView.builder(
physics: NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, crossAxisCount: 7,
), ),
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -109,18 +109,23 @@ class _CalendarWidgetState extends State<CalendarWidget> {
// Fetching diary entry percentage value // Fetching diary entry percentage value
DiaryEntry? entry = diaryEntries[DateFormat('yyyy-MM-dd').format(date)]; DiaryEntry? entry = diaryEntries[DateFormat('yyyy-MM-dd').format(date)];
if (entry != null) {
print(entry);
print(entry!.date.toString());
print(entry!.percentValue);
print(entry!.texts);
}
double fillPercentage = entry != null ? entry.percentValue / 100.0 : 0.0; double fillPercentage = entry != null ? entry.percentValue / 100.0 : 0.0;
return Center( return Center(
child: GestureDetector( child: GestureDetector(
onTap: () => {context.go('/entry', extra: date)}, onTap: () {
DiaryEntry? entry = diaryEntries[DateFormat('yyyy-MM-dd').format(date)];
if (entry != null) {
context.go('/entry', extra: date);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("no entry there :("),
duration: Duration(seconds: 2),
),
);
}
},
child: Container( child: Container(
width: 50, width: 50,
height: 50, height: 50,
@ -142,7 +147,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
DateTime.now().day == date.day && DateTime.now().month == date.month && DateTime.now().year == date.year DateTime.now().day == date.day && DateTime.now().month == date.month && DateTime.now().year == date.year
? "today" ? "today"
: DateFormat("d").format(date), : DateFormat("d").format(date),
style: TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
), ),
], ],
), ),
@ -159,40 +164,13 @@ class _CalendarWidgetState extends State<CalendarWidget> {
); );
}); });
} }
Widget _buildDateCell(DateTime date, DiaryEntry? entry) {
bool isCurrentMonth = date.month == widget.currentDate.month;
double opacity = isCurrentMonth ? 1.0 : 0.5;
Color bgColor = entry != null ? currentColorPair.backgroundColor.withOpacity(opacity) : Colors.transparent;
double fillPercentage = entry != null ? entry.percentValue / 100 : 0; // Assuming percentValue is 0-100
return GestureDetector(
onTap: () {
context.go('/entry', extra: date);
},
child: Container(
child: Stack(
alignment: Alignment.center,
children: [
CircleWidget(
radius: 25 * fillPercentage, // Adjust radius based on value
color: fillPercentage > 0 ? currentColorPair.backgroundColor : Colors.grey.withOpacity(opacity)),
Text(
DateFormat("d").format(date),
style: TextStyle(color: Colors.black),
),
],
),
),
);
}
} }
class CircleWidget extends StatelessWidget { class CircleWidget extends StatelessWidget {
final double radius; final double radius;
final Color color; final Color color;
CircleWidget({Key? key, required this.radius, required this.color}) : super(key: key); const CircleWidget({Key? key, required this.radius, required this.color}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -4,7 +4,7 @@ class StreakWidget extends StatelessWidget {
final int dayCount; final int dayCount;
final Color color; // Optional color parameter final Color color; // Optional color parameter
StreakWidget({ const StreakWidget({
Key? key, Key? key,
required this.dayCount, required this.dayCount,
this.color = Colors.white, // Default to white if not provided this.color = Colors.white, // Default to white if not provided

View File

@ -1,81 +0,0 @@
import 'package:flutter/material.dart';
class WritePageOLD extends StatefulWidget {
final double moodPercentage;
const WritePageOLD({Key? key, required this.moodPercentage})
: super(key: key);
@override
_WritePageState createState() => _WritePageState();
}
class _WritePageState extends State<WritePageOLD> {
final TextEditingController _textController = TextEditingController();
bool _hasText = false;
@override
void initState() {
super.initState();
_textController.addListener(() {
setState(() {
_hasText = _textController.text.isNotEmpty;
});
});
}
@override
void dispose() {
_textController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Displaying the mood percentage
Text(
"${widget.moodPercentage.toStringAsFixed(0)}%",
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
Text("Today", style: TextStyle(fontSize: 20)),
SizedBox(height: 4),
Text(
"Why was today only ${widget.moodPercentage.toStringAsFixed(0)}% good?",
style: TextStyle(fontSize: 16),
),
SizedBox(height: 20),
// Text area
Expanded(
child: TextField(
controller: _textController,
maxLines: null, // Allows for unlimited lines
expands: true,
decoration: InputDecoration(
hintText: "Enter your thoughts here...",
border: OutlineInputBorder(),
),
),
),
],
),
),
),
// Dynamic Save or Skip button
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
// Implement save or skip functionality
},
label: Text(_hasText ? 'Save' : 'Skip'),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
}

View File

@ -1,22 +1,23 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:moody/utils/widgets/WhyWidget.dart'; import 'package:moody/utils/widgets/why_widget.dart';
import '../../utils/CirclePainter.dart'; import '../../utils/circle_painter.dart';
import '../../utils/definitions/ColorPairs.dart'; import '../../utils/definitions/color_pair.dart';
import '../../utils/definitions/style_guide.dart'; import '../../utils/definitions/style_guide.dart';
import '../../utils/logic/PreferencesService.dart'; import '../../utils/logic/preferences_service.dart';
import '../../utils/widgets/QuestionSliderWidget.dart'; import '../../utils/widgets/question_slider_widget.dart';
class WritePage extends StatefulWidget { class WritePage extends StatefulWidget {
final SliderChangeData sliderData; final SliderChangeData sliderData;
const WritePage({Key? key, required this.sliderData}) : super(key: key); const WritePage({Key? key, required this.sliderData}) : super(key: key);
@override @override
_WritePageState createState() => _WritePageState(); State<WritePage> createState() => _WritePage();
} }
class _WritePageState extends State<WritePage> { class _WritePage extends State<WritePage> {
SliderChangeData _sliderData = SliderChangeData(0, 0); SliderChangeData _sliderData = SliderChangeData(0, 0);
final bool _sliderChanged = true; final bool _sliderChanged = true;
final PreferencesService _prefsService = PreferencesService(); final PreferencesService _prefsService = PreferencesService();
@ -43,7 +44,6 @@ class _WritePageState extends State<WritePage> {
// Create a DiaryEntry object from the input // Create a DiaryEntry object from the input
try { try {
List<String> texts = _textController.text.isEmpty ? [] : [_textController.text]; List<String> texts = _textController.text.isEmpty ? [] : [_textController.text];
print("DerText:${_textController.text}");
DiaryEntry entry = DiaryEntry( DiaryEntry entry = DiaryEntry(
date: DateTime.now(), // or some date picker value date: DateTime.now(), // or some date picker value
percentValue: _sliderData.value.toInt(), percentValue: _sliderData.value.toInt(),
@ -55,7 +55,9 @@ class _WritePageState extends State<WritePage> {
// Handle successful save here, maybe show a snackbar or navigate away // Handle successful save here, maybe show a snackbar or navigate away
} catch (e) { } catch (e) {
// Handle any errors here, such as invalid percent value or failed save // Handle any errors here, such as invalid percent value or failed save
print("Error saving entry: $e"); // Consider showing an error dialog or toast instead if (kDebugMode) {
print("Error saving entry: $e");
} // Consider showing an error dialog or toast instead
} }
} }

View File

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moody/main.dart';
import 'package:moody/utils/slide_direction.dart';
import 'package:moody/views/settings_page/settings_page.dart';
void main() {
// Test for basic rendering of MyApp
testWidgets('MyApp renders correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MyApp());
expect(find.byType(MaterialApp), findsOneWidget);
});
// Test for route configuration
testWidgets('Navigating to /settings shows SettingsPage', (WidgetTester tester) async {
await tester.pumpWidget(const MyApp());
await tester.tap(find.text('Settings'));
await tester.pumpAndSettle();
expect(find.byType(SettingsPage), findsOneWidget);
});
// Test for custom logic - determineSlideDirection
test('determineSlideDirection returns correct SlideDirection', () {
expect(determineSlideDirection('/', '/settings'), equals(SlideDirection.left));
// Add more test cases for different route combinations
});
}