Skip to content

Commit

Permalink
Merge pull request #117 from krolmic/feat/optimize-for-tablet
Browse files Browse the repository at this point in the history
Feat/optimize for tablet
  • Loading branch information
krolmic authored Sep 3, 2024
2 parents d28021c + aac37b1 commit 0eee32d
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 116 deletions.
15 changes: 15 additions & 0 deletions tracking_flutter/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,13 @@
);
PRODUCT_BUNDLE_IDENTIFIER = app.healthyhustle;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
Expand Down Expand Up @@ -685,9 +690,14 @@
);
PRODUCT_BUNDLE_IDENTIFIER = app.healthyhustle;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand All @@ -709,8 +719,13 @@
);
PRODUCT_BUNDLE_IDENTIFIER = app.healthyhustle;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand Down
97 changes: 52 additions & 45 deletions tracking_flutter/lib/calendar/view/calendar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:tracking_app/shared/theme/layout.dart';
import 'package:tracking_app/shared/toast.dart';
import 'package:tracking_app/shared/widgets/loading_indicator.dart';
import 'package:tracking_app/shared/widgets/mood_emoji.dart';
import 'package:tracking_app/shared/widgets/moods_shader_mask.dart';
import 'package:tracking_app/shared/widgets/spacing.dart';
import 'package:tracking_app/update_mood/bloc/update_mood_bloc.dart';
import 'package:user_profile_repository/user_profile_repository.dart';
Expand Down Expand Up @@ -113,54 +114,60 @@ class _CalendarView extends StatelessWidget {
buildWhen: (previous, current) =>
previous.moodsState != current.moodsState,
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const VerticalSpacing.large(),
Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 430),
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
return Center(
child: Container(
constraints: const BoxConstraints(maxWidth: maxViewWidth),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const VerticalSpacing.large(),
Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 430),
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
),
child: _Calendar(
targetMonthDate: state.targetDate.date,
moods: state.moodsState.moods,
),
),
),
child: _Calendar(
targetMonthDate: state.targetDate.date,
moods: state.moodsState.moods,
const VerticalSpacing.medium(),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
),
child: Text(
translations.trackedMood,
style: Theme.of(context).textTheme.headlineSmall,
),
),
),
const VerticalSpacing.medium(),
if (state.moodsState.isLoading ||
state.moodsState.isInitial)
const SizedBox(
height: 125,
child: Center(child: LoadingIndicator()),
)
else if (state.moodsState.isSuccess &&
state.moodsState.moods.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
),
child: Text(
translations.noTrackedMood,
style: Theme.of(context).textTheme.bodyMedium,
),
)
else if (state.moodsState.isSuccess)
_MoodsInMonth(moods: state.moodsState.moods)
.animate()
.fadeIn(duration: animationDuration),
],
),
const VerticalSpacing.large(),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
),
child: Text(
translations.trackedMood,
style: Theme.of(context).textTheme.headlineSmall,
),
),
const VerticalSpacing.medium(),
if (state.moodsState.isLoading || state.moodsState.isInitial)
const SizedBox(
height: 125,
child: Center(child: LoadingIndicator()),
)
else if (state.moodsState.isSuccess &&
state.moodsState.moods.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: viewPaddingHorizontal,
),
child: Text(
translations.noTrackedMood,
style: Theme.of(context).textTheme.bodyMedium,
),
)
else if (state.moodsState.isSuccess)
_MoodsInMonth(moods: state.moodsState.moods)
.animate()
.fadeIn(duration: animationDuration),
],
),
);
},
),
Expand Down
8 changes: 4 additions & 4 deletions tracking_flutter/lib/calendar/view/widgets/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ class _Calendar extends StatelessWidget {
return Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 12, right: 2),
padding:
const EdgeInsets.symmetric(horizontal: horizontalPaddingLarge),
child: _CalendarHeader(targetMonthDate: targetMonthDate),
),
const VerticalSpacing.extraLarge(),
CalendarCarousel<Event>(
firstDayOfWeek: (0 + 1) % 7,
height: 350,
height: 335,
todayButtonColor: _CalendarTheme.todayButtonColor,
todayTextStyle: _CalendarTheme.todayTextStyle,
daysTextStyle: _CalendarTheme.calendarDaysTextStyle,
Expand Down Expand Up @@ -128,7 +129,6 @@ class _Calendar extends StatelessWidget {
date: mood.createdOn.dateOnly,
dot: Container(
decoration: _CalendarTheme.eventDotDecoration,
margin: const EdgeInsets.symmetric(horizontal: 1),
height: 6,
width: 6,
).animate().fadeIn(
Expand Down Expand Up @@ -190,7 +190,7 @@ class _CalendarHeader extends StatelessWidget {
),
),
),
const HorizontalSpacing.large(),
const HorizontalSpacing.extraLarge(),
Material(
color: Colors.transparent,
child: InkWell(
Expand Down
33 changes: 19 additions & 14 deletions tracking_flutter/lib/calendar/view/widgets/moods_in_month.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ class _MoodsInMonth extends StatelessWidget {

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
const SizedBox(width: viewPaddingHorizontal),
for (final mood in moods)
Padding(
key: ValueKey(mood),
padding: const EdgeInsets.only(
right: verticalPaddingSmall,
return MoodsShaderMask(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
stops: const [0.0, 0.9, 1.0],
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
const SizedBox(width: viewPaddingHorizontal),
for (final mood in moods)
Padding(
key: ValueKey(mood),
padding: const EdgeInsets.only(
right: verticalPaddingSmall,
),
child: _TrackedMood(mood: mood),
),
child: _TrackedMood(mood: mood),
),
const SizedBox(width: viewPaddingHorizontal),
],
const SizedBox(width: viewPaddingHorizontal),
],
),
),
);
}
Expand Down
37 changes: 5 additions & 32 deletions tracking_flutter/lib/home/view/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import 'package:tracking_app/update_mood/bloc/update_mood_bloc.dart';
import 'package:tracking_app/user_profile/cubit/user_profile_cubit.dart';
import 'package:user_profile_repository/user_profile_repository.dart';

part 'widgets/progress.dart';
part 'widgets/home_moods.dart';
part 'widgets/home_moods_header.dart';
part 'widgets/home_progress.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
Expand Down Expand Up @@ -286,37 +288,8 @@ class _HomeContentView extends StatelessWidget {
),
),
const VerticalSpacing.large(),
if (moods.isNotEmpty)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
translations.recentlyTracked,
style: Theme.of(context).textTheme.headlineSmall,
),
TextButton(
onPressed: () {
context.goNamed(RoutesNames.moods);
},
child: Text(
translations.seeAll,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: AppColors.blue,
),
),
),
],
),
for (final mood in moods)
TrackedMood(
mood: mood,
onTap: () => context.pushNamed(
RoutesNames.updateMoodFromHome,
extra: UpdateMoodRouteParameters(mood: mood),
),
).animate().fadeIn(
duration: animationDuration,
),
if (moods.isNotEmpty) const _HomeMoodsHeader(),
_HomeMoods(moods: moods),
if (addExtraBottomSpace) const VerticalSpacing.extraLarge(),
],
),
Expand Down
26 changes: 26 additions & 0 deletions tracking_flutter/lib/home/view/widgets/home_moods.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
part of '../home_screen.dart';

class _HomeMoods extends StatelessWidget {
const _HomeMoods({required this.moods});

final List<Mood> moods;

@override
Widget build(BuildContext context) {
return Column(
children: [
for (final mood in moods)
TrackedMood(
mood: mood,
onTap: () => context.pushNamed(
RoutesNames.updateMoodFromHome,
extra: UpdateMoodRouteParameters(mood: mood),
),
).animate().fadeIn(
duration: animationDuration,
),
const VerticalSpacing.medium(),
],
);
}
}
31 changes: 31 additions & 0 deletions tracking_flutter/lib/home/view/widgets/home_moods_header.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
part of '../home_screen.dart';

class _HomeMoodsHeader extends StatelessWidget {
const _HomeMoodsHeader();

@override
Widget build(BuildContext context) {
final translations = AppLocalizations.of(context)!;

return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
translations.recentlyTracked,
style: Theme.of(context).textTheme.headlineSmall,
),
TextButton(
onPressed: () {
context.goNamed(RoutesNames.moods);
},
child: Text(
translations.seeAll,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: AppColors.blue,
),
),
),
],
);
}
}
7 changes: 4 additions & 3 deletions tracking_flutter/lib/moods/view/moods_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ import 'package:tracking_app/moods/cubit/moods_cubit.dart';
import 'package:tracking_app/shared/router/routes_names.dart';
import 'package:tracking_app/shared/router/routes_parameters.dart';
import 'package:tracking_app/shared/theme/animation.dart';
import 'package:tracking_app/shared/theme/colors.dart';
import 'package:tracking_app/shared/theme/layout.dart';
import 'package:tracking_app/shared/view/base_view.dart';
import 'package:tracking_app/shared/widgets/app_elevated_button.dart';
import 'package:tracking_app/shared/widgets/error_message.dart';
import 'package:tracking_app/shared/widgets/loading_indicator.dart';
import 'package:tracking_app/shared/widgets/moods_shader_mask.dart';
import 'package:tracking_app/shared/widgets/tracked_mood.dart';
import 'package:tracking_app/update_mood/bloc/update_mood_bloc.dart';
import 'package:tracking_app/user_profile/cubit/user_profile_cubit.dart';
import 'package:user_profile_repository/user_profile_repository.dart';

part 'widgets/moods_shader_mask.dart';

class MoodsScreen extends StatelessWidget {
const MoodsScreen({super.key});

Expand Down Expand Up @@ -211,6 +209,9 @@ class _MoodsContentViewState extends State<_MoodsContentView> {
children: [
Expanded(
child: MoodsShaderMask(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: const [0.0, 0.95, 1.0],
child: _buildMoods(),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ class _UserProfileAvatar extends StatelessWidget {
title: AppLocalizations.of(context)!.selectEmoji,
body: Padding(
padding: const EdgeInsets.only(top: verticalPaddingLarge),
child: SizedBox(
child: Container(
constraints: const BoxConstraints(maxWidth: 500),
width: double.maxFinite,
height: MediaQuery.of(context).size.height * 0.4,
child: GridView.count(
crossAxisCount: 4,
crossAxisSpacing: 15,
Expand Down
4 changes: 4 additions & 0 deletions tracking_flutter/lib/shared/theme/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ const double verticalPaddingExtraExtraLarge = 60;
const double horizontalPaddingSmall = 5;
const double horizontalPaddingMedium = 10;
const double horizontalPaddingLarge = 15;
const double horizontalPaddingExtraLarge = 30;
const double viewPaddingVertical = 15;
const double viewPaddingHorizontal = 25;

// View size constants
const double maxViewWidth = 700;
Loading

0 comments on commit 0eee32d

Please sign in to comment.