fixed important things
parent
1add5bb6fe
commit
cf53061e3a
|
@ -1,12 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:moody/utils/SlideDirection.dart';
|
||||
import 'package:moody/utils/widgets/QuestionSliderWidget.dart';
|
||||
import 'package:moody/utils/slide_direction.dart';
|
||||
import 'package:moody/utils/widgets/question_slider_widget.dart';
|
||||
import 'package:moody/views/color_page/color_page.dart';
|
||||
import 'package:moody/views/entry_view/entry_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/kalendartryhome_page.dart';
|
||||
import 'package:moody/views/settings_page/settings_page.dart';
|
||||
import 'package:moody/views/start_page/start_page.dart';
|
||||
import 'package:moody/views/statistic/statistic_page.dart';
|
||||
|
@ -18,37 +17,32 @@ final GoRouter _router = GoRouter(
|
|||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, StartPage()),
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, const StartPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/moods',
|
||||
builder: (context, state) => CalendarPage(),
|
||||
builder: (context, state) => const StatisticPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/settings',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, SettingsPage()),
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, const SettingsPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/statistic',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, StatisticPage()),
|
||||
// ignore: prefer_const_constructors
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, StatisticPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/home',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, HomePage()),
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, const HomePage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/first',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, FirstPage()),
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, const FirstPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/color',
|
||||
pageBuilder: (context, state) =>
|
||||
_noAnimationTransition(context, state, ColorPage()),
|
||||
pageBuilder: (context, state) => _noAnimationTransition(context, state, const ColorPage()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/write',
|
||||
|
@ -81,10 +75,9 @@ class MyApp extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context,
|
||||
GoRouterState state, Widget child, SlideDirection direction) {
|
||||
var beginOffset =
|
||||
direction == SlideDirection.left ? Offset(1.0, 0.0) : Offset(-1.0, 0.0);
|
||||
/* A Slide Transition that will may be used in future versions
|
||||
CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context, GoRouterState state, Widget child, SlideDirection direction) {
|
||||
var beginOffset = direction == SlideDirection.left ? Offset(1.0, 0.0) : Offset(-1.0, 0.0);
|
||||
|
||||
return CustomTransitionPage(
|
||||
key: state.pageKey,
|
||||
|
@ -93,8 +86,7 @@ CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context,
|
|||
var end = Offset.zero;
|
||||
var curve = Curves.easeInOut;
|
||||
|
||||
var tween =
|
||||
Tween(begin: beginOffset, end: end).chain(CurveTween(curve: curve));
|
||||
var tween = Tween(begin: beginOffset, end: end).chain(CurveTween(curve: curve));
|
||||
var offsetAnimation = animation.drive(tween);
|
||||
|
||||
return SlideTransition(
|
||||
|
@ -103,15 +95,9 @@ CustomTransitionPage<dynamic> _createSlideTransition(BuildContext context,
|
|||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
SlideDirection determineSlideDirection(
|
||||
String currentRoute, String targetRoute) {
|
||||
print(currentRoute);
|
||||
print(targetRoute);
|
||||
if (currentRoute == targetRoute) {
|
||||
print("Sameroute pls fix!!");
|
||||
}
|
||||
SlideDirection determineSlideDirection(String currentRoute, String targetRoute) {
|
||||
if (targetRoute == "/statistic") {
|
||||
return SlideDirection.right;
|
||||
} else if (targetRoute == "/settings") {
|
||||
|
@ -123,13 +109,10 @@ SlideDirection determineSlideDirection(
|
|||
return SlideDirection.right;
|
||||
}
|
||||
}
|
||||
return currentRoute.compareTo(targetRoute) < 0
|
||||
? SlideDirection.left
|
||||
: SlideDirection.right;
|
||||
return currentRoute.compareTo(targetRoute) < 0 ? SlideDirection.left : SlideDirection.right;
|
||||
}
|
||||
|
||||
CustomTransitionPage<dynamic> _noAnimationTransition(
|
||||
BuildContext context, GoRouterState state, Widget child) {
|
||||
CustomTransitionPage<dynamic> _noAnimationTransition(BuildContext context, GoRouterState state, Widget child) {
|
||||
return CustomTransitionPage(
|
||||
key: state.pageKey,
|
||||
child: child,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'dart:math' as Math;
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
@ -6,9 +6,7 @@ class CirclePainter extends CustomPainter {
|
|||
final double value;
|
||||
final Color color; // New field for color
|
||||
|
||||
CirclePainter(this.value, this.color) {
|
||||
print("CirclePainter " + value.toString());
|
||||
}
|
||||
CirclePainter(this.value, this.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
|
@ -16,7 +14,7 @@ class CirclePainter extends CustomPainter {
|
|||
..color = color.withOpacity(0.5) // Use the passed color
|
||||
..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);
|
||||
}
|
||||
|
|
@ -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...
|
||||
];
|
|
@ -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)),
|
||||
];
|
|
@ -4,7 +4,7 @@ import 'dart:ui';
|
|||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../definitions/ColorPairs.dart';
|
||||
import '../definitions/color_pair.dart';
|
||||
|
||||
class PreferencesService {
|
||||
static const _keyColor1 = 'color1';
|
||||
|
@ -138,7 +138,7 @@ class PreferencesService {
|
|||
|
||||
while (entryDates.contains(DateFormat('yyyy-MM-dd').format(currentDate))) {
|
||||
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;
|
|
@ -1,20 +1,18 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:moody/utils/definitions/ColorPairs.dart';
|
||||
import 'package:moody/utils/logic/PreferencesService.dart';
|
||||
import 'package:moody/utils/definitions/color_pair.dart';
|
||||
import 'package:moody/utils/logic/preferences_service.dart';
|
||||
|
||||
class CustomBottomNavigationBar extends StatefulWidget {
|
||||
final int initialSelectedIndex;
|
||||
|
||||
CustomBottomNavigationBar({Key? key, this.initialSelectedIndex = 0})
|
||||
: super(key: key);
|
||||
const CustomBottomNavigationBar({Key? key, this.initialSelectedIndex = 0}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CustomBottomNavigationBarState createState() =>
|
||||
_CustomBottomNavigationBarState();
|
||||
State<CustomBottomNavigationBar> createState() => _CustomBottomNavigationBar();
|
||||
}
|
||||
|
||||
class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
|
||||
class _CustomBottomNavigationBar extends State<CustomBottomNavigationBar> {
|
||||
late int _selectedIndex;
|
||||
|
||||
@override
|
||||
|
@ -27,9 +25,7 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
|
|||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
print('Item $index clicked');
|
||||
var currentRoute =
|
||||
GoRouter.of(context).routeInformationProvider.value.location;
|
||||
var currentRoute = GoRouter.of(context).routeInformationProvider.value.uri.toString();
|
||||
var goToRoute = "/";
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -50,47 +46,41 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<ColorPair>(
|
||||
future:
|
||||
PreferencesService().loadColorPair(), // Async loading of the color
|
||||
future: PreferencesService().loadColorPair(), // Async loading of the color
|
||||
builder: (BuildContext context, AsyncSnapshot<ColorPair> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
|
||||
// When data is loaded
|
||||
Color backgroundColor =
|
||||
snapshot.data!.backgroundColor; // Use loaded background color
|
||||
Color backgroundColor = snapshot.data!.backgroundColor; // Use loaded background color
|
||||
return buildNavigationBar(backgroundColor);
|
||||
} else {
|
||||
// While loading or if no data, show default or loading indicator
|
||||
return buildNavigationBar(
|
||||
Colors.white); // Default color or loading indicator
|
||||
return buildNavigationBar(Colors.white); // Default color or loading indicator
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildNavigationBar(Color backgroundColor) {
|
||||
return Container(
|
||||
width: 175,
|
||||
margin: EdgeInsets.only(bottom: 30),
|
||||
padding: EdgeInsets.all(5),
|
||||
margin: const EdgeInsets.only(bottom: 30),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.transparent),
|
||||
borderRadius:
|
||||
BorderRadius.circular(35), // Adjust radius to fit your design
|
||||
borderRadius: BorderRadius.circular(35), // Adjust radius to fit your design
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 7,
|
||||
offset: Offset(3, 3), // changes position of shadow
|
||||
offset: const Offset(3, 3), // changes position of shadow
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 1,
|
||||
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
|
||||
],
|
||||
|
@ -100,12 +90,9 @@ class _CustomBottomNavigationBarState extends State<CustomBottomNavigationBar> {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
_buildNavItem(Image.asset('assets/icons/icon-analyze.png'), 0,
|
||||
backgroundColor),
|
||||
_buildNavItem(
|
||||
Image.asset('assets/icons/icon-logo.png'), 1, backgroundColor),
|
||||
_buildNavItem(Image.asset('assets/icons/icon-settings.png'), 2,
|
||||
backgroundColor),
|
||||
_buildNavItem(Image.asset('assets/icons/icon-analyze.png'), 0, backgroundColor),
|
||||
_buildNavItem(Image.asset('assets/icons/icon-logo.png'), 1, backgroundColor),
|
||||
_buildNavItem(Image.asset('assets/icons/icon-settings.png'), 2, backgroundColor),
|
||||
],
|
||||
),
|
||||
),
|
|
@ -8,7 +8,7 @@ class MoodTextAreaWidget extends StatefulWidget {
|
|||
final bool forceBlinkingCursor;
|
||||
final TextEditingController? controller;
|
||||
|
||||
MoodTextAreaWidget({
|
||||
const MoodTextAreaWidget({
|
||||
Key? key,
|
||||
this.initialText = '',
|
||||
this.isDisabled = false,
|
||||
|
@ -19,10 +19,10 @@ class MoodTextAreaWidget extends StatefulWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MoodTextAreaWidgetState createState() => _MoodTextAreaWidgetState();
|
||||
State<MoodTextAreaWidget> createState() => _MoodTextAreaWidget();
|
||||
}
|
||||
|
||||
class _MoodTextAreaWidgetState extends State<MoodTextAreaWidget> {
|
||||
class _MoodTextAreaWidget extends State<MoodTextAreaWidget> {
|
||||
late TextEditingController _controller;
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
late bool _isEditingEnabled;
|
||||
|
@ -70,7 +70,6 @@ class _MoodTextAreaWidgetState extends State<MoodTextAreaWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("initialtext######${widget.initialText}");
|
||||
if (!_isEditingEnabled) _controller.text = widget.initialText;
|
||||
return TextField(
|
||||
controller: _controller,
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/material.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 {
|
||||
final DateTime date;
|
||||
|
@ -11,7 +11,7 @@ class QuestionSliderWidget extends StatefulWidget {
|
|||
final ValueChanged<double> onSliderPositionChanged;
|
||||
final Color sliderColor; // parameter for the color
|
||||
|
||||
QuestionSliderWidget({
|
||||
const QuestionSliderWidget({
|
||||
Key? key,
|
||||
required this.date,
|
||||
required this.questionText,
|
||||
|
@ -23,10 +23,10 @@ class QuestionSliderWidget extends StatefulWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_QuestionSliderWidgetState createState() => _QuestionSliderWidgetState();
|
||||
State<QuestionSliderWidget> createState() => _QuestionSliderWidget();
|
||||
}
|
||||
|
||||
class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
|
||||
class _QuestionSliderWidget extends State<QuestionSliderWidget> {
|
||||
bool _showDragText = true;
|
||||
SliderChangeData? _sliderData;
|
||||
QuestionGenerator generator = QuestionGenerator();
|
||||
|
@ -38,7 +38,6 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
|
|||
super.initState();
|
||||
//_sliderData?.value = widget.initialSliderValue;
|
||||
_sliderData = SliderChangeData(widget.initialSliderValue, 0);
|
||||
print("innit");
|
||||
if (!widget.isSliderEnabled) {
|
||||
_showDragText = false;
|
||||
}
|
||||
|
@ -51,13 +50,11 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
|
|||
} else {
|
||||
if (!initValSet && changedInitValue != widget.initialSliderValue) {
|
||||
initValSet = true;
|
||||
print("here");
|
||||
changedInitValue != widget.initialSliderValue;
|
||||
_sliderData?.value = widget.initialSliderValue;
|
||||
}
|
||||
}
|
||||
|
||||
print(_sliderData?.value);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 150, 20, 0),
|
||||
child: Column(
|
||||
|
@ -72,12 +69,12 @@ class _QuestionSliderWidgetState extends State<QuestionSliderWidget> {
|
|||
children: [
|
||||
Text(
|
||||
DateFormat('dd MM yyyy').format(widget.date),
|
||||
style: TextStyle(fontSize: 18),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
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(
|
||||
disabledThumbColor: Colors.transparent,
|
||||
activeTrackColor: widget.sliderColor,
|
||||
trackShape: RectangularSliderTrackShape(),
|
||||
trackShape: const RectangularSliderTrackShape(),
|
||||
inactiveTickMarkColor: Colors.transparent,
|
||||
inactiveTrackColor: Colors.transparent,
|
||||
valueIndicatorColor: Colors.transparent,
|
|
@ -4,17 +4,17 @@ class WhyWidget extends StatefulWidget {
|
|||
final TextEditingController controller;
|
||||
final bool prependWhy;
|
||||
|
||||
WhyWidget({
|
||||
const WhyWidget({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
this.prependWhy = true,
|
||||
}) : super(key: key);
|
||||
|
||||
@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 FocusNode _focusNode = FocusNode();
|
||||
|
|
@ -1,19 +1,21 @@
|
|||
import 'package:flutter/material.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/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/BottomNavigationWidget.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
||||
|
||||
// ...Include PreferencesService and other necessary imports
|
||||
|
||||
class ColorPage extends StatefulWidget {
|
||||
const ColorPage({super.key});
|
||||
|
||||
@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
|
||||
|
||||
@override
|
||||
|
@ -25,7 +27,6 @@ class _ColorPageState extends State<ColorPage> {
|
|||
// Load selected color from preferences
|
||||
void _loadSelectedColor() async {
|
||||
ColorPair? savedColorPair = await PreferencesService().loadColorPair();
|
||||
if (savedColorPair != null) {
|
||||
// Find the index of the saved color in the colorPairs list
|
||||
int index = colorPairs.indexWhere(
|
||||
(pair) => pair.backgroundColor.value == savedColorPair.backgroundColor.value && pair.textColor.value == savedColorPair.textColor.value,
|
||||
|
@ -35,12 +36,6 @@ class _ColorPageState extends State<ColorPage> {
|
|||
selectedColorIndex = index;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// If no color is selected, default to the first one
|
||||
setState(() {
|
||||
selectedColorIndex = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -83,7 +78,7 @@ class _ColorPageState extends State<ColorPage> {
|
|||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 2),
|
||||
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 2),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -101,7 +96,7 @@ class _ColorPageState extends State<ColorPage> {
|
|||
child: Container(
|
||||
width: bubbleWidth,
|
||||
height: bubbleWidth,
|
||||
padding: EdgeInsets.all(10), // Padding for inner circle effect
|
||||
padding: const EdgeInsets.all(10), // Padding for inner circle effect
|
||||
decoration: BoxDecoration(
|
||||
color: colorPairs[index].backgroundColor,
|
||||
shape: BoxShape.circle,
|
||||
|
|
|
@ -2,24 +2,24 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../utils/CirclePainter.dart';
|
||||
import '../../utils/definitions/ColorPairs.dart';
|
||||
import '../../utils/circle_painter.dart';
|
||||
import '../../utils/definitions/color_pair.dart';
|
||||
import '../../utils/definitions/style_guide.dart';
|
||||
import '../../utils/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/BottomNavigationWidget.dart';
|
||||
import '../../utils/widgets/MoodTextArea.dart';
|
||||
import '../../utils/widgets/QuestionSliderWidget.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
||||
import '../../utils/widgets/mood_text_area_widget.dart';
|
||||
import '../../utils/widgets/question_slider_widget.dart';
|
||||
|
||||
class EntryPage extends StatefulWidget {
|
||||
final DateTime date;
|
||||
|
||||
EntryPage({Key? key, required this.date}) : super(key: key);
|
||||
const EntryPage({Key? key, required this.date}) : super(key: key);
|
||||
|
||||
@override
|
||||
_EntryPageState createState() => _EntryPageState();
|
||||
State<EntryPage> createState() => _EntryPage();
|
||||
}
|
||||
|
||||
class _EntryPageState extends State<EntryPage> {
|
||||
class _EntryPage extends State<EntryPage> {
|
||||
SliderChangeData sliderData = SliderChangeData(0, 0);
|
||||
String _moodText = "";
|
||||
final PreferencesService _prefsService = PreferencesService();
|
||||
|
@ -59,7 +59,7 @@ class _EntryPageState extends State<EntryPage> {
|
|||
});
|
||||
}
|
||||
// _textController.text = _moodText;
|
||||
_textController.text = currentEntry != null ? currentEntry!.texts.join(" ") : _moodText;
|
||||
_textController.text = (currentEntry != null ? currentEntry.texts.join(" ") : _moodText);
|
||||
}
|
||||
|
||||
void _toggleEdit() {
|
||||
|
@ -72,7 +72,7 @@ class _EntryPageState extends State<EntryPage> {
|
|||
}
|
||||
|
||||
void _saveEntry() async {
|
||||
print("saveEntry....");
|
||||
//print("saveEntry...."); Todo for future versions
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -114,11 +114,11 @@ class _EntryPageState extends State<EntryPage> {
|
|||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
sliderData.value.toString() + "%",
|
||||
style: TextStyle(color: Colors.black),
|
||||
"${sliderData.value}%",
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
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
|
||||
),
|
||||
),
|
||||
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,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 0),
|
||||
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.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/definitions/ColorPairs.dart';
|
||||
import '../../utils/circle_painter.dart';
|
||||
import '../../utils/definitions/color_pair.dart';
|
||||
import '../../utils/definitions/style_guide.dart';
|
||||
import '../../utils/logic/PreferencesService.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
|
||||
class FirstPage extends StatefulWidget {
|
||||
final bool showSkipText; // Add this line
|
||||
|
@ -14,10 +15,10 @@ class FirstPage extends StatefulWidget {
|
|||
: super(key: key);
|
||||
|
||||
@override
|
||||
_FirstPageState createState() => _FirstPageState();
|
||||
State<FirstPage> createState() => _FirstPage();
|
||||
}
|
||||
|
||||
class _FirstPageState extends State<FirstPage> {
|
||||
class _FirstPage extends State<FirstPage> {
|
||||
SliderChangeData sliderData = SliderChangeData(0, 50);
|
||||
bool _sliderChanged = false;
|
||||
final PreferencesService _prefsService = PreferencesService();
|
||||
|
@ -33,9 +34,9 @@ class _FirstPageState extends State<FirstPage> {
|
|||
}
|
||||
|
||||
void _checkExistingEntry() async {
|
||||
WidgetsBinding.instance?.addPostFrameCallback((_) async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
DiaryEntry? entry = await _prefsService.getDiaryEntryByCurrentDate();
|
||||
if (entry != null) {
|
||||
if (entry != null && mounted) {
|
||||
context.go('/home');
|
||||
}
|
||||
});
|
||||
|
@ -60,7 +61,9 @@ class _FirstPageState extends State<FirstPage> {
|
|||
|
||||
await _prefsService.saveDiaryEntry(entry);
|
||||
} 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: [
|
||||
QuestionSliderWidget(
|
||||
onSliderPositionChanged: (value) {
|
||||
print("sliderposchanged");
|
||||
//print("slider Moved");
|
||||
},
|
||||
sliderColor: textColor,
|
||||
date: DateTime.now(),
|
||||
|
@ -129,7 +132,6 @@ class _FirstPageState extends State<FirstPage> {
|
|||
right: 20,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
print(_sliderChanged);
|
||||
if (_sliderChanged) {
|
||||
_saveEntry();
|
||||
context.go('/home', extra: sliderData.value);
|
||||
|
@ -141,7 +143,7 @@ class _FirstPageState extends State<FirstPage> {
|
|||
? Text("save.", style: TextStyle(fontSize: 18, color: textColor))
|
||||
: widget.showSkipText // Use the showSkipText parameter
|
||||
? const Text("skip", style: TextStyle(fontSize: 18, color: Colors.grey))
|
||||
: SizedBox.shrink(),
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../utils/CirclePainter.dart';
|
||||
import '../../../utils/circle_painter.dart';
|
||||
|
||||
class DragWidget extends StatefulWidget {
|
||||
const DragWidget({super.key});
|
||||
|
||||
@override
|
||||
_DragWidgetState createState() => _DragWidgetState();
|
||||
State<DragWidget> createState() => _DragWidget();
|
||||
}
|
||||
|
||||
class _DragWidgetState extends State<DragWidget> {
|
||||
class _DragWidget extends State<DragWidget> {
|
||||
double _sliderValue = 0.0;
|
||||
|
||||
@override
|
||||
|
@ -28,7 +30,7 @@ class _DragWidgetState extends State<DragWidget> {
|
|||
padding: const EdgeInsets.only(top: 20.0, left: 20.0),
|
||||
child: Text(
|
||||
"${DateTime.now().toLocal()}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
|
@ -38,7 +40,7 @@ class _DragWidgetState extends State<DragWidget> {
|
|||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 32), // 2 line padding
|
||||
const SizedBox(height: 32), // 2 line padding
|
||||
SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
trackShape: CustomTrackShape(),
|
||||
|
@ -57,10 +59,10 @@ class _DragWidgetState extends State<DragWidget> {
|
|||
),
|
||||
if (_sliderValue > 0)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 20.0),
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: Text(
|
||||
"${_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 trackLeft = offset.dx;
|
||||
final double trackTop =
|
||||
offset.dy + (parentBox.size.height - trackHeight) / 2;
|
||||
final double trackTop = offset.dy + (parentBox.size.height - trackHeight) / 2;
|
||||
final double trackWidth = parentBox.size.width;
|
||||
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:moody/utils/definitions/style_guide.dart';
|
||||
import 'package:moody/views/first_page/first_page.dart';
|
||||
|
||||
import '../../utils/CirclePainter.dart';
|
||||
import '../../utils/definitions/ColorPairs.dart';
|
||||
import '../../utils/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/BottomNavigationWidget.dart';
|
||||
import '../../utils/widgets/QuestionSliderWidget.dart';
|
||||
import '../../utils/widgets/WhyWidget.dart';
|
||||
import '../../utils/circle_painter.dart';
|
||||
import '../../utils/definitions/color_pair.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
||||
import '../../utils/widgets/question_slider_widget.dart';
|
||||
import '../../utils/widgets/why_widget.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
@ -18,7 +19,6 @@ class HomePage extends StatefulWidget {
|
|||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
SliderChangeData sliderData = SliderChangeData(0, 0);
|
||||
String _moodText = "";
|
||||
bool _isTextAreaEditable = false;
|
||||
final PreferencesService _prefsService = PreferencesService();
|
||||
Color backgroundColor = Colors.lightGreenAccent;
|
||||
|
@ -45,15 +45,11 @@ class _HomePageState extends State<HomePage> {
|
|||
void _loadCurrentDiaryEntry() async {
|
||||
DiaryEntry? currentEntry = await _prefsService.getDiaryEntryByCurrentDate();
|
||||
if (currentEntry != null) {
|
||||
print(currentEntry.texts.join(" "));
|
||||
setState(() {
|
||||
sliderData.value = currentEntry.percentValue.toDouble();
|
||||
print(currentEntry.percentValue);
|
||||
_moodText = currentEntry.texts.join(" "); // Assuming you want to concatenate all texts
|
||||
_textController.text = currentEntry.texts.join(" ");
|
||||
});
|
||||
setState(() {});
|
||||
print(sliderData.value);
|
||||
} else {
|
||||
setState(() {
|
||||
noData = true;
|
||||
|
@ -73,7 +69,6 @@ class _HomePageState extends State<HomePage> {
|
|||
void _saveEntry() async {
|
||||
try {
|
||||
List<String> texts = _textController.text.isEmpty ? [] : [_textController.text];
|
||||
print("DerText:${_textController.text}");
|
||||
DiaryEntry entry = DiaryEntry(
|
||||
date: DateTime.now(),
|
||||
percentValue: sliderData.value.toInt(),
|
||||
|
@ -82,15 +77,17 @@ class _HomePageState extends State<HomePage> {
|
|||
|
||||
await _prefsService.saveDiaryEntry(entry);
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
print("Error saving entry: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return noData
|
||||
? Scaffold(
|
||||
body: const FirstPage(showSkipText: false),
|
||||
? const Scaffold(
|
||||
body: FirstPage(showSkipText: false),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1),
|
||||
)
|
||||
|
@ -113,7 +110,7 @@ class _HomePageState extends State<HomePage> {
|
|||
children: [
|
||||
QuestionSliderWidget(
|
||||
onSliderPositionChanged: (value) {
|
||||
print("sliderposchanged");
|
||||
//print("Slider moved");
|
||||
},
|
||||
sliderColor: textColor,
|
||||
date: DateTime.now(),
|
||||
|
@ -169,7 +166,7 @@ class _HomePageState extends State<HomePage> {
|
|||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 1),
|
||||
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 1),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,18 +2,20 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../utils/definitions/style_guide.dart';
|
||||
import '../../utils/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/BottomNavigationWidget.dart';
|
||||
import 'widgets/CustomDivider.dart';
|
||||
import 'widgets/SetPinPopup.dart';
|
||||
import 'widgets/TextSwitchContainer.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
||||
import 'widgets/custom_divider_widget.dart';
|
||||
import 'widgets/set_pin_popup_widget.dart';
|
||||
import 'widgets/text_switch_container_widget.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@override
|
||||
_SettingsPageState createState() => _SettingsPageState();
|
||||
State<SettingsPage> createState() => _SettingsPage();
|
||||
}
|
||||
|
||||
class _SettingsPageState extends State<SettingsPage> {
|
||||
class _SettingsPage extends State<SettingsPage> {
|
||||
bool isPinEnabled = false; // Default to false
|
||||
|
||||
@override
|
||||
|
@ -32,7 +34,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
return Scaffold(
|
||||
backgroundColor: AppStyle.backgroundColor,
|
||||
body: Container(
|
||||
padding: EdgeInsets.only(bottom: 0),
|
||||
padding: const EdgeInsets.only(bottom: 0),
|
||||
margin: const EdgeInsets.fromLTRB(30, 30, 30, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
|
@ -43,20 +45,20 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
|
||||
// Settings section
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
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(
|
||||
leftText: "change color",
|
||||
onTap: () => context.go("/color"),
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
FutureBuilder<bool>(
|
||||
future: PreferencesService().isPinEnabled(),
|
||||
builder: (context, snapshot) {
|
||||
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
|
||||
return TextSwitchContainer(
|
||||
|
@ -75,63 +77,63 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
);
|
||||
},
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
TextSwitchContainer(
|
||||
leftText: "your data",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
// Community section
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
child: Text('community', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: const Text('community', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
|
||||
),
|
||||
),
|
||||
TextSwitchContainer(
|
||||
leftText: "join our discord",
|
||||
rightText: "fulfilled",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
TextSwitchContainer(
|
||||
leftText: "our instagram",
|
||||
rightText: "@get.fulfilled",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
TextSwitchContainer(
|
||||
leftText: "share fulfilled with your loved ones",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
|
||||
child: Container(
|
||||
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(
|
||||
leftText: "about us",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
TextSwitchContainer(
|
||||
leftText: "support us",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
CustomDivider(),
|
||||
const CustomDivider(),
|
||||
TextSwitchContainer(
|
||||
leftText: "give feedback",
|
||||
onTap: () => print('Container tapped'),
|
||||
onTap: () => {},
|
||||
),
|
||||
//
|
||||
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
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 150,
|
||||
)
|
||||
],
|
||||
|
@ -139,7 +141,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 2),
|
||||
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 2),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -147,7 +149,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SetPinPopup();
|
||||
return const SetPinPopup();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,20 +3,21 @@ import 'dart:ui';
|
|||
import 'package:flutter/material.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
|
||||
|
||||
class SetPinPopup extends StatefulWidget {
|
||||
const SetPinPopup({super.key});
|
||||
|
||||
@override
|
||||
_SetPinPopupState createState() => _SetPinPopupState();
|
||||
State<SetPinPopup> createState() => _SetPinPopup();
|
||||
}
|
||||
|
||||
class _SetPinPopupState extends State<SetPinPopup> {
|
||||
class _SetPinPopup extends State<SetPinPopup> {
|
||||
String _pin = '';
|
||||
String _confirmedPin = '';
|
||||
bool _isSettingPin =
|
||||
true; // True if setting the PIN, false if confirming the PIN
|
||||
bool _isSettingPin = true; // True if setting the PIN, false if confirming the PIN
|
||||
|
||||
static const int pinLength = 4;
|
||||
|
||||
|
@ -55,12 +56,11 @@ class _SetPinPopupState extends State<SetPinPopup> {
|
|||
Widget _buildNumberButton(int number) {
|
||||
return GestureDetector(
|
||||
onTap: () => _onNumberTap(number),
|
||||
onTapDown: (_) =>
|
||||
HapticFeedback.lightImpact(), // Cool haptic feedback on tap
|
||||
onTapDown: (_) => HapticFeedback.lightImpact(), // Cool haptic feedback on tap
|
||||
child: Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
margin: EdgeInsets.all(10),
|
||||
margin: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.black),
|
||||
|
@ -69,7 +69,7 @@ class _SetPinPopupState extends State<SetPinPopup> {
|
|||
child: Center(
|
||||
child: Text(
|
||||
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) ||
|
||||
(!_isSettingPin && _confirmedPin.length == pinLength)) {
|
||||
if ((_isSettingPin && _pin.length == pinLength) || (!_isSettingPin && _confirmedPin.length == pinLength)) {
|
||||
if (!_isSettingPin && _pin == _confirmedPin) {
|
||||
// Call setPin and enablePin methods, assuming they are async
|
||||
PreferencesService().setPin(int.parse(_pin));
|
||||
|
@ -117,35 +116,28 @@ class _SetPinPopupState extends State<SetPinPopup> {
|
|||
child: Container(
|
||||
height: 600,
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(_isSettingPin ? 'Set a PIN' : 'Repeat PIN',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 20),
|
||||
Text(_isSettingPin ? 'Set a PIN' : 'Repeat PIN', style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(pinLength, (index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(4),
|
||||
margin: const EdgeInsets.all(4),
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
(_isSettingPin ? _pin.length : _confirmedPin.length) >
|
||||
index
|
||||
? Colors.black
|
||||
: Colors.transparent,
|
||||
color: (_isSettingPin ? _pin.length : _confirmedPin.length) > index ? Colors.black : Colors.transparent,
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
..._buildNumberPad(),
|
||||
],
|
||||
),
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
|
@ -5,8 +6,7 @@ class SettingsSection extends StatelessWidget {
|
|||
final String title;
|
||||
final List<SettingsItem> items;
|
||||
|
||||
SettingsSection({Key? key, required this.title, required this.items})
|
||||
: super(key: key);
|
||||
const SettingsSection({Key? key, required this.title, required this.items}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -14,11 +14,10 @@ class SettingsSection extends StatelessWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
|
||||
),
|
||||
),
|
||||
...items.map((item) => _buildItem(item)).toList(),
|
||||
|
@ -36,9 +35,9 @@ class SettingsSection extends StatelessWidget {
|
|||
? GestureDetector(
|
||||
child: Text(
|
||||
item.trailingText ?? "",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
),
|
||||
onTap: () => _launchURL(item.url!),
|
||||
onTap: () => _launchURL(Uri.parse(item.url!)),
|
||||
)
|
||||
: null,
|
||||
onTap: item.onTap,
|
||||
|
@ -47,14 +46,16 @@ class SettingsSection extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
void _launchURL(String url) async {
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
void _launchURL(Uri url) async {
|
||||
if (await canLaunchUrl(url)) {
|
||||
await launchUrl(url);
|
||||
} else {
|
||||
if (kDebugMode) {
|
||||
print("Could not launch $url");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsItem {
|
||||
final String title;
|
|
@ -1,15 +1,19 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../utils/definitions/color_pair.dart';
|
||||
import '../../../utils/logic/preferences_service.dart';
|
||||
|
||||
class TextSwitchContainer extends StatefulWidget {
|
||||
final String leftText;
|
||||
final String? rightText;
|
||||
final bool hasSwitch;
|
||||
final Function onTap;
|
||||
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,
|
||||
this.rightText,
|
||||
this.hasSwitch = false,
|
||||
|
@ -19,33 +23,46 @@ class TextSwitchContainer extends StatefulWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
_TextSwitchContainerState createState() =>
|
||||
_TextSwitchContainerState(switchValue: this.switchDefaultValue);
|
||||
State<TextSwitchContainer> createState() => _TextSwitchContainer();
|
||||
}
|
||||
|
||||
class _TextSwitchContainerState extends State<TextSwitchContainer> {
|
||||
bool switchValue; // No longer explicitly initialized here
|
||||
class _TextSwitchContainer extends State<TextSwitchContainer> {
|
||||
late bool switchValue;
|
||||
Color backgroundColor = Colors.white; // Default value
|
||||
Color textColor = Colors.black; // Default value
|
||||
|
||||
_TextSwitchContainerState(
|
||||
{required this.switchValue}); // Constructor takes the initial switch value
|
||||
@override
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => widget.onTap(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 0, vertical: 20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.leftText,
|
||||
style: TextStyle(fontSize: 18),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
if (widget.hasSwitch)
|
||||
CupertinoSwitch(
|
||||
trackColor: Colors.white,
|
||||
thumbColor: switchValue ? Colors.lightGreen : Colors.grey,
|
||||
thumbColor: switchValue ? backgroundColor : Colors.grey,
|
||||
value: switchValue,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
|
@ -60,7 +77,7 @@ class _TextSwitchContainerState extends State<TextSwitchContainer> {
|
|||
else if (widget.rightText != null)
|
||||
Text(
|
||||
widget.rightText!,
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey),
|
||||
style: const TextStyle(fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
|
@ -1,14 +1,17 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.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 {
|
||||
const StartPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return const MaterialApp(
|
||||
title: 'PIN Input',
|
||||
home: PinInputScreen(),
|
||||
);
|
||||
|
@ -16,11 +19,13 @@ class StartPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
class PinInputScreen extends StatefulWidget {
|
||||
const PinInputScreen({super.key});
|
||||
|
||||
@override
|
||||
_PinInputScreenState createState() => _PinInputScreenState();
|
||||
State<PinInputScreen> createState() => _PinInputScreen();
|
||||
}
|
||||
|
||||
class _PinInputScreenState extends State<PinInputScreen> {
|
||||
class _PinInputScreen extends State<PinInputScreen> {
|
||||
String _pin = '';
|
||||
static const int pinLength = 4;
|
||||
|
||||
|
@ -31,11 +36,13 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
}
|
||||
|
||||
Future<void> _checkPinStatus() async {
|
||||
bool pinEnabled = await PreferencesService().isPinEnabled(); // Adjust with actual implementation
|
||||
bool pinEnabled = await PreferencesService().isPinEnabled();
|
||||
if (!pinEnabled) {
|
||||
// If no PIN is enabled, navigate to the "/first" route.
|
||||
// Navigator context will be available after the widget build.
|
||||
Future.microtask(() => context.go("/first"));
|
||||
Future.microtask(() {
|
||||
if (mounted) {
|
||||
context.go("/first");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,13 +68,16 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
Future<void> _validatePin() async {
|
||||
bool correct = await checkPin(int.parse(_pin));
|
||||
if (correct) {
|
||||
print("Right");
|
||||
if (mounted) {
|
||||
context.go("/first");
|
||||
}
|
||||
// Perform any actions you need on successful pin entry
|
||||
} else {
|
||||
// Handle wrong pin entry, e.g., reset pin, show error, etc.
|
||||
if (kDebugMode) {
|
||||
print("Wrong PIN");
|
||||
}
|
||||
}
|
||||
|
||||
// Resetting the PIN for this example, you might want to do this differently
|
||||
setState(() {
|
||||
|
@ -91,17 +101,17 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
child: Container(
|
||||
height: 600,
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('Welcome Back!', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 20),
|
||||
const Text('Welcome Back!', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(pinLength, (index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(4),
|
||||
margin: const EdgeInsets.all(4),
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
|
@ -112,7 +122,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
..._buildNumberPad(),
|
||||
],
|
||||
),
|
||||
|
@ -160,7 +170,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
child: Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
margin: EdgeInsets.all(10),
|
||||
margin: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
borderRadius: BorderRadius.circular(35),
|
||||
|
@ -168,7 +178,7 @@ class _PinInputScreenState extends State<PinInputScreen> {
|
|||
child: Center(
|
||||
child: Text(
|
||||
number.toString(),
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -2,17 +2,19 @@ import 'package:flutter/material.dart';
|
|||
import 'package:moody/views/statistic/widget/calendar_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/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/BottomNavigationWidget.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
||||
|
||||
class StatisticPage extends StatefulWidget {
|
||||
const StatisticPage({super.key});
|
||||
|
||||
@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 textColor = Colors.black; // Default fallback color
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
@ -47,7 +49,7 @@ class _StatisticPageState extends State<StatisticPage> {
|
|||
child: Scaffold(
|
||||
backgroundColor: AppStyle.backgroundColor,
|
||||
body: Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Column(
|
||||
|
@ -61,11 +63,11 @@ class _StatisticPageState extends State<StatisticPage> {
|
|||
color: backgroundColor,
|
||||
);
|
||||
} else {
|
||||
return CircularProgressIndicator(); // or some placeholder
|
||||
return const CircularProgressIndicator(); // or some placeholder
|
||||
}
|
||||
},
|
||||
),
|
||||
Text(
|
||||
const Text(
|
||||
"browse your memories!",
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
|
@ -76,11 +78,11 @@ class _StatisticPageState extends State<StatisticPage> {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 50),
|
||||
Container(child: CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 2, 1))),
|
||||
Container(child: CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 1, 1))),
|
||||
Container(child: CalendarWidget(currentDate: DateTime.now())),
|
||||
SizedBox(
|
||||
const SizedBox(height: 50),
|
||||
CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 2, 1)),
|
||||
CalendarWidget(currentDate: DateTime(DateTime.now().year, DateTime.now().month - 1, 1)),
|
||||
CalendarWidget(currentDate: DateTime.now()),
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
)
|
||||
],
|
||||
|
@ -89,7 +91,7 @@ class _StatisticPageState extends State<StatisticPage> {
|
|||
),
|
||||
]),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: CustomBottomNavigationBar(initialSelectedIndex: 0),
|
||||
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2,19 +2,19 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../utils/definitions/ColorPairs.dart';
|
||||
import '../../../utils/logic/PreferencesService.dart'; // Correct the path as necessary
|
||||
import '../../../utils/definitions/color_pair.dart';
|
||||
import '../../../utils/logic/preferences_service.dart'; // Correct the path as necessary
|
||||
|
||||
class CalendarWidget extends StatefulWidget {
|
||||
final DateTime currentDate;
|
||||
|
||||
CalendarWidget({Key? key, required this.currentDate}) : super(key: key);
|
||||
const CalendarWidget({Key? key, required this.currentDate}) : super(key: key);
|
||||
|
||||
@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
|
||||
Map<String, DiaryEntry?> diaryEntries = {}; // Holds diary entries by date
|
||||
late ColorPair currentColorPair; // Holds the current color pair
|
||||
|
@ -28,7 +28,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
|||
|
||||
void _loadColorPairAndDiaryData() async {
|
||||
// Load color pair
|
||||
currentColorPair = await PreferencesService().loadColorPair() ?? colorPairs[0];
|
||||
currentColorPair = await PreferencesService().loadColorPair();
|
||||
|
||||
// Generate date list
|
||||
//dateList = _generateDateList(widget.currentDate);
|
||||
|
@ -67,7 +67,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
|||
|
||||
// Adjust list to end with a complete week
|
||||
while (list.length % 7 != 0) {
|
||||
list.add(list.last.add(Duration(days: 1)));
|
||||
list.add(list.last.add(const Duration(days: 1)));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -82,24 +82,24 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
|||
future: PreferencesService().loadColorPair(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
ColorPair colorPair = snapshot.data!;
|
||||
|
||||
return Container(
|
||||
return SizedBox(
|
||||
height: 360 + addon,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Text(monthName, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), // Month Header
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Text(monthName, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), // Month Header
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(25, 0, 25, 0),
|
||||
child: GridView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 7,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
|
@ -109,18 +109,23 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
|||
|
||||
// Fetching diary entry percentage value
|
||||
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;
|
||||
|
||||
return Center(
|
||||
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(
|
||||
width: 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
|
||||
? "today"
|
||||
: 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 {
|
||||
final double radius;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -4,7 +4,7 @@ class StreakWidget extends StatelessWidget {
|
|||
final int dayCount;
|
||||
final Color color; // Optional color parameter
|
||||
|
||||
StreakWidget({
|
||||
const StreakWidget({
|
||||
Key? key,
|
||||
required this.dayCount,
|
||||
this.color = Colors.white, // Default to white if not provided
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,22 +1,23 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.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/definitions/ColorPairs.dart';
|
||||
import '../../utils/circle_painter.dart';
|
||||
import '../../utils/definitions/color_pair.dart';
|
||||
import '../../utils/definitions/style_guide.dart';
|
||||
import '../../utils/logic/PreferencesService.dart';
|
||||
import '../../utils/widgets/QuestionSliderWidget.dart';
|
||||
import '../../utils/logic/preferences_service.dart';
|
||||
import '../../utils/widgets/question_slider_widget.dart';
|
||||
|
||||
class WritePage extends StatefulWidget {
|
||||
final SliderChangeData sliderData;
|
||||
|
||||
const WritePage({Key? key, required this.sliderData}) : super(key: key);
|
||||
@override
|
||||
_WritePageState createState() => _WritePageState();
|
||||
State<WritePage> createState() => _WritePage();
|
||||
}
|
||||
|
||||
class _WritePageState extends State<WritePage> {
|
||||
class _WritePage extends State<WritePage> {
|
||||
SliderChangeData _sliderData = SliderChangeData(0, 0);
|
||||
final bool _sliderChanged = true;
|
||||
final PreferencesService _prefsService = PreferencesService();
|
||||
|
@ -43,7 +44,6 @@ class _WritePageState extends State<WritePage> {
|
|||
// Create a DiaryEntry object from the input
|
||||
try {
|
||||
List<String> texts = _textController.text.isEmpty ? [] : [_textController.text];
|
||||
print("DerText:${_textController.text}");
|
||||
DiaryEntry entry = DiaryEntry(
|
||||
date: DateTime.now(), // or some date picker value
|
||||
percentValue: _sliderData.value.toInt(),
|
||||
|
@ -55,7 +55,9 @@ class _WritePageState extends State<WritePage> {
|
|||
// Handle successful save here, maybe show a snackbar or navigate away
|
||||
} catch (e) {
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue