repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/flutterstudyjam_gdg
|
mirrored_repositories/flutterstudyjam_gdg/INDRANI SEN-sen.indrani0608@gmail.com/main.dart
|
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Color favColor = Colors.black;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Instagram', style: TextStyle(color: Colors.black),),
leading: Icon(Icons.camera_alt, color: Colors.black,),
backgroundColor: Colors.white,
actions: <Widget>[
Icon(Icons.tv, color: Colors.black,),
Icon(Icons.send, color: Colors.black,),
]
),
body: ListView.builder(
physics: BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return buildInstagramTile();
},
itemCount: 10,
),
),
);
}
Widget buildInstagramTile() {
return Column(
children: <Widget>[
ListTile(
leading: Image.network(
'https://cdn.shopify.com/s/files/1/1698/6547/files/starcatalog_600x600.jpg?v=1511346010',
),
title: Text('Indrani Sen'),
trailing: Icon(Icons.more_horiz),
),
Image.network(
'https://www.abc.net.au/news/image/9744422-1x1-940x940.jpg',
height: 200,
fit: BoxFit.fill,
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
IconButton(
icon: Icon(
Icons.favorite,
color: favColor,
),
onPressed: () {
setState(() {
favColor = Colors.red;
});
favColor = Colors.red;
},
),
SizedBox(width: 8),
Icon(Icons.mode_comment),
SizedBox(width: 8),
Icon(Icons.share),
],
),
Icon(Icons.bookmark_border),
],
)
],
);
}
}
| 0
|
mirrored_repositories/flutterstudyjam_gdg
|
mirrored_repositories/flutterstudyjam_gdg/AyushAcharya- ayushjash1323@gmail.com/main.dart
|
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
Color favColor = Colors.black;
int c=0;
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Instagram', style: TextStyle(color: Colors.black),),
leading: Icon(Icons.camera_alt, color: Colors.black,),
backgroundColor: Colors.white,
actions: <Widget>[
Icon(Icons.tv, color: Colors.black,),
SizedBox(width: 10.0,),
Icon(Icons.send, color: Colors.black,),
],
),
body: ListView.builder(
physics: BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return buildInstagramTile();
},
itemCount: 10,
),
),
);
}
buildInstagramTile() {
return Column(
children: <Widget>[
ListTile(
leading: Image.network(
'https://media.geeksforgeeks.org/wp-content/cdn-uploads/20191021012537/P100-Right-Top.jpg'),
title: Text('Ayush'),
trailing: Icon(Icons.more_horiz),
),
SizedBox(height: 20.0,),
Image.network('https://www.symbolab.com/public/images/home_left.png',
height: 200,
width: double.infinity,
fit: BoxFit.cover,
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
IconButton(
icon: Icon(
Icons.favorite, color: favColor,
),
onPressed: () {
if(c%2!=0){
setState(() {
favColor = Colors.redAccent;
});
c++;
}
else{
setState(() {
favColor = Colors.black;
});
c++;
}
},
),
SizedBox(width: 10.0,),
Icon(Icons.chat_bubble_outline),
SizedBox(width: 10.0,),
Icon(Icons.send),
],
),
Icon(Icons.bookmark_border),
],
)
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge
|
mirrored_repositories/fluter_tasks_challenge/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/presentation/home/bindings/home_page_bindings.dart';
import 'package:flutter_tasks_challenge/presentation/home/pages/home_page.dart';
import 'package:flutter_tasks_challenge/app/utils/routes.dart';
import 'package:get/get.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
getPages: getPages,
debugShowCheckedModeBanner: false,
initialBinding: const HomePageBindings(),
title: 'Tasks Challenge',
home: const HomePage(),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/types/http_methods.dart
|
enum HttpMethods {
getD,
put,
post,
delete,
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/types/tabs_types.dart
|
enum TaskTypes {
completed,
notCompleted,
}
extension ParseToString on TaskTypes {
String convertToText() {
final strings = toString().replaceAll('.', '_').split('_').last;
final exp = RegExp(r"(?=[A-Z])");
final parts = strings.split(exp);
String name = '';
for (String p in parts) {
name += '${p[0].toUpperCase() + p.substring(1)} ';
}
return name;
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/config/text_styles.dart
|
import 'package:flutter/widgets.dart';
import 'app_colors.dart';
class TextStyles {
static TextStyle _getCopy(
final double size,
final FontWeight weight,
final Color color,
) {
return TextStyle(
fontFamily: 'OpenSans',
fontSize: size,
fontWeight: weight,
color: color,
);
}
static TextStyle w100(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w100, color);
}
static TextStyle w200(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w200, color);
}
static TextStyle w300(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w300, color);
}
static TextStyle w400(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w400, color);
}
static TextStyle w500(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w500, color);
}
static TextStyle w600(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w600, color);
}
static TextStyle w700(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w700, color);
}
static TextStyle w800(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w800, color);
}
static TextStyle w900(final double size, [final Color color = black]) {
return _getCopy(size, FontWeight.w900, color);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/config/app_colors.dart
|
import 'package:flutter/material.dart';
const Color accent = Color(0xff4776E6);
const Color darkAccent = Color(0xff8E54E9);
const Color red = Color(0xffEB5353);
const Color green = Color(0xffA0D995);
// const Color backgroundColor = Color(0xff131417);
const Color backgroundColor = Color(0xfffffefe);
// const Color containersBackgroundColor = Color(0xff1e2021);
const Color containersBackgroundColor = Color.fromARGB(255, 242, 242, 242);
const Color black = Color(0xff192252);
const Color grey = Color.fromARGB(255, 87, 88, 89);
const Color middleGrey = Color(0xffb9bfce);
const Color lightGrey = Color.fromARGB(255, 247, 247, 247);
// Gradients
const LinearGradient accentGradient = LinearGradient(colors: [
accent,
darkAccent,
]);
const List<Color> colors = [
Colors.red,
Colors.blue,
Colors.green,
Colors.orange,
Colors.yellow,
Colors.teal
];
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/config/constants.dart
|
import 'package:flutter/painting.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
const String baseUrl = 'https://ecsdevapi.nextline.mx/vdev/tasks-challenge';
const String token =
'e864a0c9eda63181d7d65bc73e61e3dc6b74ef9b82f7049f1fc7d9fc8f29706025bd271d1ee1822b15d654a84e1a0997b973a46f923cc9977b3fcbb064179ecd';
const Map<String, String> headers = {
'Authorization': 'Bearer $token',
"Content-Type": "application/json; charset=utf-8",
};
const String tasksEndPoint = 'tasks';
List<BoxShadow> shadows = [
BoxShadow(
color: black.withOpacity(0.12),
blurRadius: 24,
offset: const Offset(0, 8),
)
];
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/utils/responsive_util.dart
|
import 'dart:math';
import 'package:flutter/widgets.dart';
class ResponsiveUtil {
static final ResponsiveUtil _resp = ResponsiveUtil._internal();
late double _height;
late double _width;
late double _diagonal;
// late DeviceType _device;
double get height => _height;
double get width => _width;
// DeviceType get device => _device;
// Font sizes
double get sp40 => dp(4.0); // Big titles
double get sp30 => dp(3.0); // Middle titles
double get sp20 => dp(2.0); // Page titles
double get sp16 => dp(1.6); // Data titles
double get sp14 => dp(1.4); // Body
factory ResponsiveUtil.of(final BuildContext context) {
final size = MediaQuery.of(context).size;
_resp._height = size.height;
_resp._width = size.width;
// _resp._device = _resp._width <= 480
// ? DeviceType.phone
// : _resp._width <= 1439
// ? DeviceType.tablet
// : _resp._width > 1439
// ? DeviceType.desktop
// : DeviceType.phone;
_resp._diagonal = sqrt((pow(_resp._height, 2) + pow(_resp._width, 2)));
return _resp;
}
double hp(final double percent) => _height * (percent / 100);
double wp(final double percent) => _width * (percent / 100);
double dp(final double percent) => _diagonal * (percent / 100);
ResponsiveUtil._internal();
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/utils/routes.dart
|
import 'package:flutter_tasks_challenge/presentation/home/bindings/home_page_bindings.dart';
import 'package:flutter_tasks_challenge/presentation/home/pages/home_page.dart';
import 'package:flutter_tasks_challenge/presentation/task_details/pages/task_details_page.dart';
import 'package:get/get_navigation/src/routes/get_route.dart';
List<GetPage> getPages = [
GetPage(
name: '/home',
page: () => const HomePage(),
binding: const HomePageBindings(),
),
GetPage(
name: '/taskDetails',
page: () => const TaskDetailsPage(),
),
];
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/utils/dialogs_util.dart
|
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import '../../presentation/home/widgets/error_getting_data_widget.dart';
import '../../presentation/home/widgets/loading_data_widget.dart';
import '../../presentation/task_details/widgets/custom_text_form_field_widget.dart';
import '../config/app_colors.dart';
import '../config/text_styles.dart';
class DialogsUtil {
static Future withActions({
required String firstText,
required List<Widget> actions,
String? coloredText,
String? finalText,
bool? withImage = true,
}) {
return Get.defaultDialog(
titlePadding: const EdgeInsets.only(top: 20),
title: '',
actions: actions,
content: Column(
children: [
if (withImage != null && withImage) ...[
Container(
decoration: const BoxDecoration(
color: containersBackgroundColor,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Image.asset('assets/images/delete_task.png'),
),
const SizedBox(height: 20),
],
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: firstText,
style: TextStyles.w500(16),
children: [
TextSpan(
text: ' $coloredText ',
style: TextStyles.w800(16, accent),
),
TextSpan(
text: finalText,
style: TextStyles.w500(16),
),
],
),
),
],
),
);
}
static Future<void> loading() {
return Get.defaultDialog(
titlePadding: const EdgeInsets.only(top: 20),
barrierDismissible: false,
title: '',
content: const LoadingDataWidget(fontColor: grey),
);
}
static Future<void> error() {
return Get.defaultDialog(
titlePadding: const EdgeInsets.only(top: 20),
title: '',
content: const ErrorGettingDataWidget(
fontColor: grey,
showSubtitle: false,
),
);
}
static Future<void> withTextField({
required String title,
required String initialText,
void Function(String)? onSummitCallback,
}) {
return Get.defaultDialog(
titlePadding: const EdgeInsets.only(top: 20),
title: 'Set $title',
titleStyle: TextStyles.w500(14, grey),
content: Column(
children: [
CustomTextFormFieldWidget(
initialText: initialText,
label: title,
maxLines: 5,
onAcceptCallback: (value) {
Get.back();
if (onSummitCallback != null) {
onSummitCallback(value);
}
},
)
],
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/app
|
mirrored_repositories/fluter_tasks_challenge/lib/app/utils/snackbars_util.dart
|
import 'package:flutter/widgets.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:get/route_manager.dart';
import '../config/text_styles.dart';
class SnackBarsUtil {
static void forStatus({
required String message,
required bool hasError,
}) {
Get.showSnackbar(
GetSnackBar(
titleText: Text(
'Message',
style: TextStyles.w800(16),
),
messageText: Text(
message,
style: TextStyles.w500(14),
),
backgroundColor: hasError ? red : green,
duration: const Duration(milliseconds: 2000),
snackPosition: SnackPosition.TOP,
borderRadius: 15,
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network/models/api_response_model.dart
|
class ApiResponseModel {
final int statusCode;
final bool hasErrors;
final String message;
const ApiResponseModel({
required this.hasErrors,
required this.message,
required this.statusCode,
});
@override
String toString() =>
'Details: $message - Code: $statusCode - Has Errors: $hasErrors';
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network/models/task_model.dart
|
import 'package:flutter_tasks_challenge/app/config/constants.dart';
import 'package:intl/intl.dart';
class TaskModel {
final int id;
String title;
bool isCompleted;
DateTime? dueDate;
String? comments;
String? description;
String? tags;
final DateTime? createdAt;
final DateTime? updatedAt;
TaskModel({
required this.id,
required this.title,
required this.isCompleted,
this.dueDate,
this.comments,
this.description,
this.createdAt,
this.updatedAt,
this.tags,
});
Map<String, dynamic> toMap() {
return {
'title': title,
'is_completed': isCompleted ? 1 : 0,
'due_date':
dueDate == null ? null : DateFormat('yyyy-MM-dd').format(dueDate!),
'comments': comments,
'description': description,
'token': token,
'tags': tags,
};
}
factory TaskModel.fromMap(Map<String, dynamic> map) {
return TaskModel(
id: map['id'],
title: map['title'] ?? '',
isCompleted: map['is_completed'] == 1,
dueDate: map['due_date'] != null ? DateTime.parse(map['due_date']) : null,
comments: map['comments'],
description: map['description'],
tags: map['tags'],
createdAt: map['created_at'] != null
? DateTime.parse(map['created_at']!)
: map['created_at'],
updatedAt: map['updated_at'] != null
? DateTime.parse(map['updated_at']!)
: map['updated_at'],
);
}
String getExpirationTime() {
if (dueDate == null) return 'No date';
final difference = dueDate!.difference(DateTime.now());
final days = difference.inDays;
final hours = difference.inHours - difference.inDays * 24;
final minutes = difference.inMinutes - difference.inHours * 60;
return '${_checkTime(days, 'day')}${_checkTime(hours, 'hour')}${_checkTime(minutes, 'minute')}';
}
String _checkTime(int time, String label) {
if (time == 0) return '';
final finalLabel = time.abs() > 1 ? '${label}s' : label;
return '$time $finalLabel ';
}
double getResidue(double value) => value - value.toInt();
String getDate() =>
dueDate == null ? 'No date' : DateFormat.yMMMEd().format(dueDate!);
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network/client/nextline_api_client.dart
|
import 'dart:convert';
import 'package:flutter_tasks_challenge/app/config/constants.dart';
import 'package:flutter_tasks_challenge/app/types/http_methods.dart';
import 'package:flutter_tasks_challenge/data/network/client/base_client.dart';
import '../models/api_response_model.dart';
import '../models/task_model.dart';
class NextlineApiClient extends BaseClient {
static const _query = {'token': token};
Future<List<TaskModel>?> getTasks() async {
final response = await call(
'$baseUrl/$tasksEndPoint',
method: HttpMethods.getD,
queryParameters: _query,
);
if (response.statusCode == 200) {
final list = List.from((jsonDecode(response.body)));
return list.map((e) => TaskModel.fromMap(e)).toList();
}
return null;
}
Future<TaskModel?> getTask(final int id) async {
final response = await call(
'$baseUrl/$tasksEndPoint/$id',
method: HttpMethods.getD,
queryParameters: _query,
);
if (response.statusCode == 200) {
final list = List.from((jsonDecode(response.body)));
return list.map((e) => TaskModel.fromMap(e)).toList().first;
}
return null;
}
Future<ApiResponseModel?> editTask(final TaskModel task) async {
final response = await call(
'$baseUrl/$tasksEndPoint/${task.id}',
method: HttpMethods.put,
queryParameters: _query,
body: jsonEncode(task.toMap()),
);
final json = jsonDecode(response.body);
return _getApiResponse(response.statusCode, 201, json['detail']);
}
Future<ApiResponseModel?> createTask(final TaskModel task) async {
final response = await call(
'$baseUrl/$tasksEndPoint',
method: HttpMethods.post,
queryParameters: _query,
body: jsonEncode(task.toMap()),
);
final json = jsonDecode(response.body);
return _getApiResponse(response.statusCode, 201, json['detail']);
}
Future<ApiResponseModel?> deleteTasks(TaskModel task) async {
final response = await call(
'$baseUrl/$tasksEndPoint/${task.id}',
method: HttpMethods.delete,
queryParameters: _query,
);
final json = jsonDecode(response.body);
return _getApiResponse(response.statusCode, 201, json['detail']);
}
ApiResponseModel _getApiResponse(int code, int correctCode, String message) {
if (code == correctCode) {
return ApiResponseModel(
hasErrors: false,
message: message,
statusCode: code,
);
}
return ApiResponseModel(
hasErrors: true,
message: message,
statusCode: code,
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network
|
mirrored_repositories/fluter_tasks_challenge/lib/data/network/client/base_client.dart
|
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:flutter_tasks_challenge/app/types/http_methods.dart';
import 'package:http/http.dart' as http;
import '../../../app/config/constants.dart';
abstract class BaseClient {
static const _timeOut = 30000;
static const _retries = 1;
late final http.Client _client;
BaseClient() {
_client = http.Client();
}
@protected
Future<http.Response> call(
String url, {
required HttpMethods method,
int? currentTry,
Map<String, String>? queryParameters,
String? body,
}) async {
int retry = currentTry ?? 0;
String queryParams = '';
if (queryParameters != null) {
queryParams += '?';
queryParameters.forEach((key, value) => queryParams += '$key=$value&');
}
try {
final uri = Uri.parse('$url$queryParams');
debugPrint('Calling: $uri');
late final http.Response response;
switch (method) {
case HttpMethods.getD:
response = await _client
.get(uri, headers: headers)
.timeout(const Duration(milliseconds: _timeOut));
break;
case HttpMethods.delete:
response = await _client
.delete(uri, headers: headers)
.timeout(const Duration(milliseconds: _timeOut));
break;
case HttpMethods.post:
response = await _client
.post(uri, body: body, headers: headers)
.timeout(const Duration(milliseconds: _timeOut));
break;
case HttpMethods.put:
response = await _client
.put(uri, body: body, headers: headers)
.timeout(const Duration(milliseconds: _timeOut));
break;
}
return response;
} on TimeoutException catch (_) {
if (retry < _retries) {
retry++;
return call(url, currentTry: retry, method: method);
} else {
rethrow;
}
} catch (e) {
rethrow;
}
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/data
|
mirrored_repositories/fluter_tasks_challenge/lib/data/repositories/tasks_repository.dart
|
import 'package:flutter_tasks_challenge/data/network/client/nextline_api_client.dart';
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import '../network/models/api_response_model.dart';
class TasksRepository {
final NextlineApiClient _api = NextlineApiClient();
Future<List<TaskModel>?> getTasks() async {
return await _api.getTasks();
}
Future<TaskModel?> getTask(final int id) async {
return await _api.getTask(id);
}
Future<ApiResponseModel?> editTask(TaskModel task) async {
return await _api.editTask(task);
}
Future<ApiResponseModel?> createTask(TaskModel task) async {
return await _api.createTask(task);
}
Future<ApiResponseModel?> deleteTask(TaskModel task) async {
return await _api.deleteTasks(task);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/task_details_header_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/utils/dialogs_util.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_navigation/get_navigation.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class TaskDetailsHeaderWidget extends StatelessWidget {
final void Function(String) onNameChangedCallback;
final String title;
const TaskDetailsHeaderWidget({
super.key,
required this.title,
required this.onNameChangedCallback,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Center(
child: Row(
children: [
Expanded(
child: IconButton(
splashColor: accent,
highlightColor: lightGrey,
padding: EdgeInsets.zero,
alignment: Alignment.centerLeft,
icon: const Icon(
Icons.arrow_back_ios_new_rounded,
color: accent,
),
onPressed: () => Get.back(),
),
),
Expanded(
flex: 10,
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
vertical: resp.hp(1),
horizontal: resp.wp(1),
),
decoration: BoxDecoration(
color: lightGrey,
borderRadius: BorderRadius.circular(20),
),
child: Text(
title.isEmpty ? 'No title' : title,
overflow: TextOverflow.ellipsis,
maxLines: 1,
textAlign: TextAlign.center,
style: TextStyles.w800(20),
),
),
),
Expanded(
child: IconButton(
splashColor: accent,
highlightColor: lightGrey,
icon: const Icon(
Icons.edit,
color: accent,
),
onPressed: () => DialogsUtil.withTextField(
title: 'Title',
initialText: title,
onSummitCallback: onNameChangedCallback,
),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/task_data_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/utils/dialogs_util.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class TaskDataWidget extends StatelessWidget {
final String title;
final IconData icon;
final bool canEdit;
final bool isRequiredToSave;
final String? subTitle;
final String? originalValue;
final Widget? extraWidget;
final bool hideSubtitle;
final void Function(String)? onSummitCallback;
const TaskDataWidget({
super.key,
required this.title,
required this.icon,
this.subTitle,
this.extraWidget,
this.onSummitCallback,
this.originalValue,
this.canEdit = false,
this.isRequiredToSave = false,
this.hideSubtitle = false,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, color: middleGrey),
SizedBox(width: resp.wp(5)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
textAlign: TextAlign.justify,
text: TextSpan(
text: title,
style: TextStyles.w700(16),
children: [
TextSpan(
text: isRequiredToSave ? ' *' : null,
style: TextStyles.w700(
16,
Colors.red.withOpacity(0.5),
),
),
],
),
),
if (!hideSubtitle) ...[
SizedBox(height: resp.hp(0.5)),
Text(
subTitle == null || subTitle!.isEmpty
? 'No $title'
: subTitle!,
style: TextStyles.w500(14, grey),
),
],
if (extraWidget != null) ...[
SizedBox(height: resp.hp(0.5)),
extraWidget!,
],
],
),
),
if (canEdit)
IconButton(
highlightColor: lightGrey.withOpacity(0.8),
splashColor: accent.withOpacity(0.25),
padding: EdgeInsets.zero,
icon: const Icon(Icons.edit, color: accent),
onPressed: () {
DialogsUtil.withTextField(
title: title,
initialText: originalValue ?? '',
onSummitCallback: onSummitCallback,
);
},
),
],
),
SizedBox(height: resp.hp(3)),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/tag_chip_widget.dart
|
import 'package:flutter/material.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class TagChipWidget extends StatelessWidget {
final String title;
const TagChipWidget({
super.key,
required this.title,
});
@override
Widget build(BuildContext context) {
return Chip(
label: Text(title),
labelStyle: TextStyles.w500(12),
backgroundColor: middleGrey.withOpacity(0.25),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/widgets.dart
|
export 'custom_checkbox_with_label_widget.dart';
export 'custom_text_form_field_widget.dart';
export 'tag_chip_widget.dart';
export 'task_data_widget.dart';
export 'task_details_header_widget.dart';
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/custom_checkbox_with_label_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class CustomCheckboxWithLabelWidget extends StatelessWidget {
final void Function(bool?) onPress;
final bool isSelected;
const CustomCheckboxWithLabelWidget({
super.key,
required this.isSelected,
required this.onPress,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Row(
children: [
SizedBox(
height: resp.hp(2.5),
width: resp.wp(5),
child: Checkbox(
activeColor: accent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
value: isSelected,
onChanged: onPress,
),
),
SizedBox(width: resp.wp(1)),
Text(
isSelected ? 'Completed' : 'Not completed',
style: TextStyles.w500(14, grey),
),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/widgets/custom_text_form_field_widget.dart
|
import 'package:flutter/material.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class CustomTextFormFieldWidget extends StatelessWidget {
final void Function(String) onAcceptCallback;
final String initialText;
final String label;
final int maxLines;
late final TextEditingController controller;
CustomTextFormFieldWidget({
super.key,
required this.initialText,
required this.label,
required this.maxLines,
required this.onAcceptCallback,
}) {
controller = TextEditingController(text: initialText);
}
@override
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
keyboardType: TextInputType.text,
maxLines: maxLines,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
disabledBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: accent,
width: 1.0,
),
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: accent,
width: 1.0,
),
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: accent,
width: 1.0,
),
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
labelText: label,
labelStyle: TextStyles.w500(14, middleGrey),
),
onFieldSubmitted: (value) {
onAcceptCallback(value);
},
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/task_details/pages/task_details_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/app/utils/snackbars_util.dart';
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/tasks_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/custom_button_widget.dart';
import 'package:get/get_core/get_core.dart';
import 'package:get/get_instance/get_instance.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'package:intl/intl.dart';
import '../widgets/widgets.dart';
class TaskDetailsPage extends StatefulWidget {
final TaskModel? task;
const TaskDetailsPage({
super.key,
this.task,
});
@override
State<TaskDetailsPage> createState() => _TaskDetailsPageState();
}
class _TaskDetailsPageState extends State<TaskDetailsPage> {
late final TaskModel task;
late final bool isEditingMode;
@override
void initState() {
super.initState();
if (widget.task != null) {
task = widget.task!;
return;
}
final arguments = Get.arguments;
isEditingMode = arguments != null;
task = arguments ?? TaskModel(id: -1, title: '', isCompleted: false);
}
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Scaffold(
backgroundColor: backgroundColor,
floatingActionButton: FloatingActionButton(
backgroundColor: accent,
child: const Icon(Icons.check),
onPressed: () async {
final TasksController taskController = Get.find();
if (taskController.isSavingTask.value) return;
final res = await (isEditingMode
? taskController.editTask(task)
: taskController.createTask(task));
if (res == null) {
SnackBarsUtil.forStatus(
message: 'Error interno en la aplicación.',
hasError: true,
);
return;
}
if (!res.hasErrors) {
Get.offAllNamed('/home');
await taskController.getAllTasks();
}
SnackBarsUtil.forStatus(
message: res.message,
hasError: res.hasErrors,
);
},
),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: resp.wp(7),
vertical: resp.hp(7),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TaskDetailsHeaderWidget(
title: task.title,
onNameChangedCallback: (t) => setState(() => task.title = t),
),
SizedBox(height: resp.hp(5)),
TaskDataWidget(
title: 'Status',
isRequiredToSave: true,
hideSubtitle: true,
icon: Icons.check,
extraWidget: CustomCheckboxWithLabelWidget(
isSelected: task.isCompleted,
onPress: (value) => setState(() => task.isCompleted = value!),
),
),
TaskDataWidget(
title: 'Due date',
subTitle: task.getDate(),
icon: Icons.date_range_rounded,
extraWidget: CustomButtonWidget(
text: 'Select date',
color: accent,
onPress: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2021),
lastDate: DateTime(2030),
);
if (pickedDate == null) return;
setState(() {
task.dueDate = pickedDate;
});
},
),
),
TaskDataWidget(
title: 'Description',
subTitle: task.description,
originalValue: task.description,
icon: Icons.text_snippet_rounded,
canEdit: true,
onSummitCallback: (value) =>
setState(() => task.description = value),
),
TaskDataWidget(
title: 'Comments',
subTitle: task.comments,
originalValue: task.comments,
icon: Icons.comment,
canEdit: true,
onSummitCallback: (value) =>
setState(() => task.comments = value),
),
TaskDataWidget(
title: 'Tags',
subTitle: task.tags == null ? 'No Tags' : null,
hideSubtitle: task.tags != null,
originalValue: task.tags,
icon: Icons.tag,
canEdit: true,
extraWidget:
task.tags == null ? null : TagChipWidget(title: task.tags!),
onSummitCallback: (value) => setState(() => task.tags = value),
),
if (task.createdAt != null)
TaskDataWidget(
title: 'Creation date',
icon: Icons.date_range_rounded,
subTitle: task.createdAt == null
? 'No date'
: DateFormat.yMMMEd().format(task.createdAt!),
),
if (task.updatedAt != null)
TaskDataWidget(
title: 'Last update',
icon: Icons.date_range_rounded,
subTitle: task.updatedAt == null
? 'No date'
: DateFormat.yMMMEd().format(task.updatedAt!),
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/controllers/tasks_controller.dart
|
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import 'package:flutter_tasks_challenge/data/repositories/tasks_repository.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/home_tab_controller.dart';
import 'package:get/get.dart';
import '../../../data/network/models/api_response_model.dart';
class TasksController extends GetxController {
final TasksRepository _repository = TasksRepository();
Rx<List<TaskModel>?> tasks = Rx([]);
Rx<List<TaskModel>?> completedTasks = Rx([]);
Rx<List<TaskModel>?> notCompletedTasks = Rx([]);
RxBool isLoading = RxBool(false);
RxBool isSavingTask = RxBool(false);
@override
void onInit() async {
getAllTasks();
super.onInit();
}
Future<void> getAllTasks() async {
isLoading.value = true;
tasks.value = await _repository.getTasks();
if (tasks.value != null) {
completedTasks.value = tasks.value!.where((t) => t.isCompleted).toList();
notCompletedTasks.value =
tasks.value!.where((t) => !t.isCompleted).toList();
final HomeTabController tabsController = Get.find();
tabsController.initTabs(
completedTasks: completedTasks.value,
notCompletedTasks: notCompletedTasks.value,
);
}
isLoading.value = false;
}
Future<TaskModel?> getTask(final int id) async {
final task = _repository.getTask(id);
return task;
}
Future<ApiResponseModel?> deleteTask(final TaskModel task) async {
final res = await _repository.deleteTask(task);
await getAllTasks();
return res;
}
Future<ApiResponseModel?> editTask(final TaskModel task) async {
return await _repository.editTask(task);
}
Future<ApiResponseModel?> createTask(final TaskModel task) async {
final res = _repository.createTask(task);
await getAllTasks();
return res;
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/controllers/home_tab_controller.dart
|
import 'package:flutter_tasks_challenge/app/types/tabs_types.dart';
import 'package:flutter_tasks_challenge/presentation/home/data/models/tab_model.dart';
import 'package:get/get.dart';
import '../../../data/network/models/task_model.dart';
class HomeTabController extends GetxController {
RxList<TabModel> tabs = RxList([]);
Rx<TabModel?> selectedTab = Rx(null);
@override
void onInit() {
initTabs(completedTasks: null, notCompletedTasks: null);
super.onInit();
}
void initTabs({
required List<TaskModel>? completedTasks,
required List<TaskModel>? notCompletedTasks,
}) {
tabs.value = [
TabModel(type: TaskTypes.completed, tasks: completedTasks),
TabModel(type: TaskTypes.notCompleted, tasks: notCompletedTasks),
];
if (selectedTab.value == null) {
selectedTab.value = tabs.first;
} else {
switch (selectedTab.value!.type) {
case TaskTypes.completed:
selectedTab.value =
TabModel(type: TaskTypes.completed, tasks: completedTasks);
break;
case TaskTypes.notCompleted:
selectedTab.value =
TabModel(type: TaskTypes.notCompleted, tasks: notCompletedTasks);
}
}
selectedTab.value ??= tabs.first;
}
bool isSelected(TabModel tab) => tab.type == selectedTab.value!.type;
void onNewSelection(TabModel tab) {
if (tab != selectedTab.value) {
selectedTab.value = tab;
}
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/custom_button_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/text_styles.dart';
class CustomButtonWidget extends StatelessWidget {
final VoidCallback onPress;
final String text;
final Color color;
const CustomButtonWidget({
super.key,
required this.text,
required this.color,
required this.onPress,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPress,
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
),
backgroundColor: MaterialStateColor.resolveWith((states) => color),
),
child: Text(text, style: TextStyles.w500(14, Colors.white)),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/loading_data_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class LoadingDataWidget extends StatelessWidget {
final Color fontColor;
const LoadingDataWidget({
super.key,
this.fontColor = middleGrey,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Column(
children: [
SizedBox(height: resp.hp(2)),
const CircularProgressIndicator(color: darkAccent),
SizedBox(height: resp.hp(2)),
Text('Loading data...', style: TextStyles.w500(20, fontColor)),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/tasks_list_widget.dart
|
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/config/text_styles.dart';
import 'package:flutter_tasks_challenge/app/utils/dialogs_util.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/app/utils/snackbars_util.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/home_tab_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/tasks_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/custom_button_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/error_getting_data_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/loading_data_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/task_container_widget.dart';
import 'package:get/get.dart';
class TasksListWidget extends GetView<HomeTabController> {
const TasksListWidget({super.key});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
final TasksController tasks = Get.find();
return Obx(
() {
final errorGettingTasks = controller.selectedTab.value!.tasks == null;
bool hasData = false;
if (!errorGettingTasks) {
hasData = controller.selectedTab.value!.tasks!.isNotEmpty;
}
return Column(
children: [
if (tasks.isLoading.value)
const LoadingDataWidget()
else if (errorGettingTasks)
const ErrorGettingDataWidget()
else if (hasData)
...List.generate(
controller.selectedTab.value!.tasks!.length,
(x) => TaskContainerWidget(
task: controller.selectedTab.value!.tasks![x],
color: colors[Random().nextInt(colors.length - 1)],
onLongPress: () {
final task = controller.selectedTab.value!.tasks![x];
DialogsUtil.withActions(
firstText: 'Are you sure you want to delete',
coloredText: task.title,
finalText: 'task?',
actions: [
CustomButtonWidget(
text: 'Aceptar',
color: const Color(0xff90B77D),
onPress: () async {
Get.back();
DialogsUtil.loading();
final res = await tasks.deleteTask(task);
if (Get.isDialogOpen != null && Get.isDialogOpen!) {
// Close all dialogs
Get.back(closeOverlays: true);
}
if (res == null) {
DialogsUtil.error();
return;
}
SnackBarsUtil.forStatus(
message: res.message,
hasError: res.hasErrors,
);
},
),
CustomButtonWidget(
text: 'Cancelar',
color: const Color(0xffE64848),
onPress: () => Get.back(),
),
],
);
},
),
)
else ...[
SizedBox(height: resp.hp(1.5)),
Text('No tasks in list', style: TextStyles.w500(20, middleGrey)),
]
],
);
},
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/task_date_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import '../../../app/config/text_styles.dart';
class TaskDateWidget extends StatelessWidget {
final String date;
const TaskDateWidget({
super.key,
required this.date,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Column(
children: [
Text(
'Due Date',
style: TextStyles.w700(16),
textAlign: TextAlign.center,
),
SizedBox(height: resp.hp(0.5)),
Text(
date,
textAlign: TextAlign.center,
style: TextStyles.w500(14, grey),
),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/task_animated_line_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
class TaskAnimatedLineWidget extends StatelessWidget {
final double height;
final Color color;
const TaskAnimatedLineWidget({
super.key,
required this.height,
required this.color,
});
@override
Widget build(BuildContext context) {
return Expanded(
flex: 1,
child: AnimatedContainer(
curve: Curves.ease,
duration: const Duration(milliseconds: 500),
height: height,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: accentGradient.colors,
begin: Alignment.topLeft,
end: Alignment.bottomLeft,
),
borderRadius: BorderRadius.circular(20),
),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/task_information_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import '../../../app/config/text_styles.dart';
class TaskInformationWidget extends StatelessWidget {
final TaskModel task;
const TaskInformationWidget({
super.key,
required this.task,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Padding(
padding: EdgeInsets.symmetric(vertical: resp.hp(1)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Title:', style: TextStyles.w700(16)),
Text(task.title, style: TextStyles.w500(14, grey)),
SizedBox(height: resp.hp(1)),
if (task.description != null) ...[
Text('Description:', style: TextStyles.w700(16)),
Text(task.description!, style: TextStyles.w500(14, grey)),
SizedBox(height: resp.hp(1)),
],
if (task.tags != null) ...[
Text('Tags:', style: TextStyles.w700(16)),
Text(task.tags!, style: TextStyles.w500(14, grey)),
SizedBox(height: resp.hp(1)),
],
Text(
'Expires in:',
style: TextStyles.w700(16),
),
Text(
task.getExpirationTime(),
style: TextStyles.w500(14, grey),
),
],
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/home_announcement_container_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/config/text_styles.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/tasks_controller.dart';
import 'package:get/get.dart';
class HomeAnnouncementContainerWidget extends GetView<TasksController> {
const HomeAnnouncementContainerWidget({super.key});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Container(
height: resp.hp(25),
width: resp.width,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: containersBackgroundColor,
borderRadius: BorderRadius.circular(35),
),
child: Obx(
() {
final hasErrors = controller.tasks.value == null;
int notCompletedTasksQuantity = 0;
if (!hasErrors) {
notCompletedTasksQuantity =
controller.notCompletedTasks.value!.length;
}
late final String imageName;
late final String message;
if (notCompletedTasksQuantity == 0 ||
controller.isLoading.value ||
hasErrors) {
imageName = 'no_tasks';
message = "No tasks";
} else {
imageName = 'has_tasks';
message = "You have $notCompletedTasksQuantity task not completed";
}
return Column(
children: [
Expanded(
flex: 3,
child: Stack(
alignment: Alignment.topCenter,
clipBehavior: Clip.none,
children: [
Padding(
padding: EdgeInsets.only(
right: resp.wp(2.5),
left: resp.wp(2.5),
top: resp.hp(1.25),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: accentGradient,
),
),
),
Positioned(
bottom: resp.hp(5),
right: resp.wp(5),
child: Image.asset('assets/images/$imageName.png'),
),
],
),
),
Expanded(
flex: 1,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
message,
style: TextStyles.w500(18),
)
],
),
),
],
);
},
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/error_getting_data_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import '../../../app/config/text_styles.dart';
class ErrorGettingDataWidget extends StatelessWidget {
final Color fontColor;
final bool showSubtitle;
const ErrorGettingDataWidget({
super.key,
this.fontColor = middleGrey,
this.showSubtitle = true,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Column(
children: [
SizedBox(height: resp.hp(1)),
Opacity(
opacity: 0.25,
child: Image.asset(
'assets/images/not_load.png',
),
),
SizedBox(height: resp.hp(1)),
Text(
'Error getting data.',
style: TextStyles.w600(20, fontColor),
),
if (showSubtitle)
Text(
'Please refresh page',
style: TextStyles.w500(14, middleGrey),
),
SizedBox(height: resp.hp(1)),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/tab_container_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/types/tabs_types.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/presentation/home/data/models/tab_model.dart';
import '../../../app/config/app_colors.dart';
import '../../../app/config/text_styles.dart';
class TabContainerWidget extends StatelessWidget {
final TabModel tab;
final double rightPadding;
final bool isSelected;
const TabContainerWidget({
super.key,
required this.tab,
required this.rightPadding,
required this.isSelected,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Padding(
padding: EdgeInsets.only(
right: rightPadding,
),
child: Container(
alignment: Alignment.center,
child: Column(
children: [
Text(
tab.type.convertToText(),
style: TextStyles.w600(
16,
isSelected ? black : grey.withOpacity(0.5),
),
),
SizedBox(height: resp.hp(0.5)),
AnimatedContainer(
duration: const Duration(milliseconds: 250),
height: resp.hp(0.8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: isSelected
? accentGradient
: const LinearGradient(colors: [lightGrey, lightGrey]),
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/home_tab_bar_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/home_tab_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/data/models/tab_model.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/tab_container_widget.dart';
import 'package:get/get.dart';
class HomeTabBarWidget extends GetView<HomeTabController> {
const HomeTabBarWidget({
super.key,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return SizedBox(
height: resp.hp(5),
width: resp.width,
child: Obx(
() => Row(
children: [
...List.generate(
controller.tabs.length,
(x) {
final TabModel tab = controller.tabs[x];
final bool isSelected = controller.isSelected(tab);
final bool isFinalElement = x == controller.tabs.length - 1;
return Expanded(
child: GestureDetector(
onTap: () => controller.onNewSelection(tab),
child: TabContainerWidget(
tab: tab,
key: Key(x.toString()),
rightPadding: isFinalElement ? 0 : resp.wp(2),
isSelected: isSelected,
),
),
);
},
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/widgets/task_container_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/config/constants.dart';
import 'package:flutter_tasks_challenge/app/utils/dialogs_util.dart';
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/tasks_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/task_animated_line_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/task_date_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/task_information_widget.dart';
import 'package:get/get_instance/get_instance.dart';
import 'package:get/route_manager.dart';
import '../../../app/utils/responsive_util.dart';
class TaskContainerWidget extends StatelessWidget {
final TaskModel task;
final VoidCallback onLongPress;
final ValueNotifier<double> height = ValueNotifier(0);
final Color color;
final GlobalKey testKey = GlobalKey();
TaskContainerWidget({
super.key,
required this.color,
required this.task,
required this.onLongPress,
});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
SchedulerBinding.instance.addPostFrameCallback((_) {
if (testKey.currentContext == null) return;
final RenderObject? renderBoxRed =
testKey.currentContext?.findRenderObject();
final size = renderBoxRed!.paintBounds;
height.value = size.size.height;
});
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: lightGrey.withOpacity(0.8),
borderRadius: BorderRadius.circular(15),
boxShadow: shadows,
),
child: InkWell(
splashColor: color,
highlightColor: Colors.transparent,
borderRadius: BorderRadius.circular(15),
onLongPress: onLongPress,
onTap: () async {
final TasksController controller = Get.find();
DialogsUtil.loading();
final res = await controller
.getTask(task.id)
.whenComplete(() => Get.back());
Get.back();
if (res == null) {
DialogsUtil.error();
return;
}
await Get.toNamed('/taskDetails', arguments: res);
},
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: resp.wp(3),
vertical: resp.hp(1.5),
),
child: Column(
key: testKey,
children: [
Row(
children: [
Expanded(
flex: 8,
child: TaskDateWidget(date: task.getDate()),
),
SizedBox(width: resp.wp(2)),
ValueListenableBuilder(
valueListenable: height,
builder: (context, value, child) {
return TaskAnimatedLineWidget(
height: value,
color: color,
);
},
),
SizedBox(width: resp.wp(2)),
Expanded(
flex: 30,
child: TaskInformationWidget(
task: task,
),
),
SizedBox(width: resp.wp(1)),
],
),
],
),
),
),
),
SizedBox(height: resp.hp(1.5)),
],
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/pages/home_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_tasks_challenge/app/config/app_colors.dart';
import 'package:flutter_tasks_challenge/app/config/text_styles.dart';
import 'package:flutter_tasks_challenge/app/utils/responsive_util.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/home_announcement_container_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/home_tab_bar_widget.dart';
import 'package:flutter_tasks_challenge/presentation/home/widgets/tasks_list_widget.dart';
import 'package:get/route_manager.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
final ResponsiveUtil resp = ResponsiveUtil.of(context);
return Scaffold(
backgroundColor: backgroundColor,
floatingActionButton: FloatingActionButton(
backgroundColor: accent,
child: const Icon(Icons.add),
onPressed: () => Get.toNamed('/taskDetails'),
),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Container(
alignment: Alignment.topLeft,
decoration: const BoxDecoration(
gradient: accentGradient,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: resp.wp(7),
vertical: resp.hp(5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: resp.hp(4)),
Text(
'Tasks challenge',
style: TextStyles.w800(35, Colors.white),
),
SizedBox(height: resp.hp(12.5)),
const HomeAnnouncementContainerWidget(),
],
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: resp.wp(7),
),
child: Column(
children: [
SizedBox(height: resp.hp(4)),
const HomeTabBarWidget(),
SizedBox(height: resp.hp(2)),
const TasksListWidget(),
],
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/data
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/data/models/tab_model.dart
|
import 'package:flutter_tasks_challenge/data/network/models/task_model.dart';
import '../../../../app/types/tabs_types.dart';
class TabModel {
final TaskTypes type;
final List<TaskModel>? tasks;
const TabModel({
required this.type,
required this.tasks,
});
}
| 0
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home
|
mirrored_repositories/fluter_tasks_challenge/lib/presentation/home/bindings/home_page_bindings.dart
|
import 'package:flutter_tasks_challenge/presentation/home/controllers/home_tab_controller.dart';
import 'package:flutter_tasks_challenge/presentation/home/controllers/tasks_controller.dart';
import 'package:get/get.dart';
class HomePageBindings implements Bindings {
const HomePageBindings();
@override
void dependencies() {
Get.put(HomeTabController());
Get.put(TasksController());
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/globals.dart
|
library planet_health.globals;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
//const String api_key = '0a66e421-c755-4794-82c3-451bed8ff4fd';
String? apiKey = dotenv.env['API_KEY'];
const String TENANT_ID = 'hackzurich';
const String base_url = 'https://api.fitrockr.com';
const String greet_url = '/v1/status/greet';
const String user = '613dc4c9309a3f06bfa716ee';
const String profile_url = '/v1/users/$user/profile';
const String heart_url =
'/v1/users/$user/heartRate?startDate=2021-10-04&endDate=2021-10-04';
const String daily_summary_uri =
'/v1/users/$user/dailySummaries?startDate=2021-10-04&endDate=2021-10-04';
Map<String, String> headers = {
'Accept': 'application/json',
'X-Tenant': TENANT_ID,
'X-API-Key':
'' //dotenv.env['API_KEY'], //if(api_key != null ? api_key : 'NULL';
};
final heartRateProvider = StateProvider((ref) => 0);
int heartRate = 0;
int heartRateHigh = 0;
int heartRateLow = 60;
int weight = 55;
int dailyCals = 1000;
int dailySteps = 1000;
double dailyKm = 1.5;
class EnergyMap {
String name = '';
int calories = 0;
int co2 = 0;
EnergyMap(String name, int calories, int co2) {
this.name = name;
this.calories = calories;
this.co2 = co2;
}
}
var bread = EnergyMap("Bread", 66, 120);
var beef = EnergyMap("Beef", 348, 30000);
var salmon = EnergyMap("Salmon", 115, 2500);
var tofu = EnergyMap("Tofu", 77, 150);
var milk = EnergyMap("Milk", 122, 280);
var water = EnergyMap("Water", 0, 5);
List<EnergyMap> day1 = [bread, beef, salmon];
List<EnergyMap> day2 = [tofu, milk, water];
int totalCo2e = 0;
var energyMap = {
'white_bread': {
'name': 'White Bread',
'calories': 66,
'co2': 120,
},
'beef': {
'name': 'Beef',
'calories': 30000,
},
};
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/home_screen.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
import 'model/homelist.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
List<HomeList> homeList = HomeList.homeList;
AnimationController? animationController;
bool multiple = true;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 0));
return true;
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppTheme.white,
body: FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return Padding(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
appBar(),
Expanded(
child: FutureBuilder<bool>(
future: getData(),
builder:
(BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return GridView(
padding: const EdgeInsets.only(
top: 0, left: 12, right: 12),
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
children: List<Widget>.generate(
homeList.length,
(int index) {
final int count = homeList.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn),
),
);
animationController?.forward();
return HomeListView(
animation: animation,
animationController: animationController,
listData: homeList[index],
callBack: () {
Navigator.push<dynamic>(
context,
MaterialPageRoute<dynamic>(
builder: (BuildContext context) =>
homeList[index].navigateScreen!,
),
);
},
);
},
),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: multiple ? 2 : 1,
mainAxisSpacing: 12.0,
crossAxisSpacing: 12.0,
childAspectRatio: 1.5,
),
);
}
},
),
),
],
),
);
}
},
),
);
}
Widget appBar() {
return SizedBox(
height: AppBar().preferredSize.height,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8, left: 8),
child: Container(
width: AppBar().preferredSize.height - 8,
height: AppBar().preferredSize.height - 8,
),
),
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'Flutter UI',
style: TextStyle(
fontSize: 22,
color: AppTheme.darkText,
fontWeight: FontWeight.w700,
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8, right: 8),
child: Container(
width: AppBar().preferredSize.height - 8,
height: AppBar().preferredSize.height - 8,
color: Colors.white,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius:
BorderRadius.circular(AppBar().preferredSize.height),
child: Icon(
multiple ? Icons.dashboard : Icons.view_agenda,
color: AppTheme.dark_grey,
),
onTap: () {
setState(() {
multiple = !multiple;
});
},
),
),
),
),
],
),
);
}
}
class HomeListView extends StatelessWidget {
const HomeListView(
{Key? key,
this.listData,
this.callBack,
this.animationController,
this.animation})
: super(key: key);
final HomeList? listData;
final VoidCallback? callBack;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 50 * (1.0 - animation!.value), 0.0),
child: AspectRatio(
aspectRatio: 1.5,
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
child: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
Positioned.fill(
child: Image.asset(
listData!.imagePath,
fit: BoxFit.cover,
),
),
Material(
color: Colors.transparent,
child: InkWell(
splashColor: Colors.grey.withOpacity(0.2),
borderRadius:
const BorderRadius.all(Radius.circular(4.0)),
onTap: callBack,
),
),
],
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/app_theme.dart
|
import 'package:flutter/material.dart';
class AppTheme {
AppTheme._();
static const Color notWhite = Color(0xFFEDF0F2);
static const Color nearlyWhite = Color(0xFFFEFEFE);
static const Color white = Color(0xFFFFFFFF);
static const Color nearlyBlack = Color(0xFF213333);
static const Color grey = Color(0xFF3A5160);
static const Color dark_grey = Color(0xFF313A44);
static const Color darkText = Color(0xFF253840);
static const Color darkerText = Color(0xFF17262A);
static const Color lightText = Color(0xFF4A6572);
static const Color deactivatedText = Color(0xFF767676);
static const Color dismissibleBackground = Color(0xFF364A54);
static const Color chipBackground = Color(0xFFEEF1F3);
static const Color spacer = Color(0xFFF2F2F2);
static const String fontName = 'WorkSans';
static const TextTheme textTheme = TextTheme(
headline4: display1,
headline5: headline,
headline6: title,
subtitle2: subtitle,
bodyText2: body2,
bodyText1: body1,
caption: caption,
);
static const TextStyle display1 = TextStyle( // h4 -> display1
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 36,
letterSpacing: 0.4,
height: 0.9,
color: darkerText,
);
static const TextStyle headline = TextStyle( // h5 -> headline
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 24,
letterSpacing: 0.27,
color: darkerText,
);
static const TextStyle title = TextStyle( // h6 -> title
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.18,
color: darkerText,
);
static const TextStyle subtitle = TextStyle( // subtitle2 -> subtitle
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.04,
color: darkText,
);
static const TextStyle body2 = TextStyle( // body1 -> body2
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: 0.2,
color: darkText,
);
static const TextStyle body1 = TextStyle( // body2 -> body1
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.05,
color: darkText,
);
static const TextStyle caption = TextStyle( // Caption -> caption
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 12,
letterSpacing: 0.2,
color: lightText, // was lightText
);
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/feedback_screen.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
class FeedbackScreen extends StatefulWidget {
@override
_FeedbackScreenState createState() => _FeedbackScreenState();
}
class _FeedbackScreenState extends State<FeedbackScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
color: AppTheme.nearlyWhite,
child: SafeArea(
top: false,
child: Scaffold(
backgroundColor: AppTheme.nearlyWhite,
body: SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
left: 16,
right: 16),
child: Image.asset('assets/images/feedbackImage.png'),
),
Container(
padding: const EdgeInsets.only(top: 8),
child: Text(
'Your FeedBack',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
Container(
padding: const EdgeInsets.only(top: 16),
child: const Text(
'Give your best time for this moment.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
),
),
),
_buildComposer(),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Center(
child: Container(
width: 120,
height: 40,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius:
const BorderRadius.all(Radius.circular(4.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.6),
offset: const Offset(4, 4),
blurRadius: 8.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
'Send',
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
),
),
),
),
),
)
],
),
),
),
),
),
);
}
Widget _buildComposer() {
return Padding(
padding: const EdgeInsets.only(top: 16, left: 32, right: 32),
child: Container(
decoration: BoxDecoration(
color: AppTheme.white,
borderRadius: BorderRadius.circular(8),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.8),
offset: const Offset(4, 4),
blurRadius: 8),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Container(
padding: const EdgeInsets.all(4.0),
constraints: const BoxConstraints(minHeight: 80, maxHeight: 160),
color: AppTheme.white,
child: SingleChildScrollView(
padding:
const EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 0),
child: TextField(
maxLines: null,
onChanged: (String txt) {},
style: TextStyle(
fontFamily: AppTheme.fontName,
fontSize: 16,
color: AppTheme.dark_grey,
),
cursorColor: Colors.blue,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Enter your feedback...'),
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/user_data.dart
|
import 'package:flutter/foundation.dart';
class Counter extends ChangeNotifier {
int _count = 0;
int get count => _count;
void increment() {
_count++;
notifyListeners();
}
void decrement() {
_count--;
notifyListeners();
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/help_screen.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
class HelpScreen extends StatefulWidget {
@override
_HelpScreenState createState() => _HelpScreenState();
}
class _HelpScreenState extends State<HelpScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
color: AppTheme.nearlyWhite,
child: SafeArea(
top: false,
child: Scaffold(
backgroundColor: AppTheme.nearlyWhite,
body: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
left: 16,
right: 16),
child: Image.asset('assets/images/helpImage.png'),
),
Container(
padding: const EdgeInsets.only(top: 8),
child: Text(
'How can we help you?',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
Container(
padding: const EdgeInsets.only(top: 16),
child: const Text(
'It looks like you are experiencing problems\nwith our sign up process. We are here to\nhelp so please get in touch with us',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Container(
width: 140,
height: 40,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius:
const BorderRadius.all(Radius.circular(4.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.6),
offset: const Offset(4, 4),
blurRadius: 8.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {},
child: Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
'Chat with Us',
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
),
),
),
),
),
),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/invite_friend_screen.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
class InviteFriend extends StatefulWidget {
@override
_InviteFriendState createState() => _InviteFriendState();
}
class _InviteFriendState extends State<InviteFriend> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
color: AppTheme.nearlyWhite,
child: SafeArea(
top: false,
child: Scaffold(
backgroundColor: AppTheme.nearlyWhite,
body: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
left: 16,
right: 16),
child: Image.asset('assets/images/inviteImage.png'),
),
Container(
padding: const EdgeInsets.only(top: 8),
child: Text(
'Invite Your Friends',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
Container(
padding: const EdgeInsets.only(top: 16),
child: const Text(
'Are you one of those who makes everything\n at the last moment?',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Container(
width: 120,
height: 40,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius:
const BorderRadius.all(Radius.circular(4.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.6),
offset: const Offset(4, 4),
blurRadius: 8.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
//method here for functionality
print('Share Action.');
},
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.share,
color: Colors.white,
size: 22,
),
Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
'Share',
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
],
),
),
),
),
),
),
),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/main.dart
|
import 'dart:io';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
//import 'package:planet_health/user_data.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'navigation_home_screen.dart';
//import 'fitness_app/fitness_app_home_screen.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
//import 'package:provider/provider.dart';
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:planet_health/globals.dart' as globals;
import 'dart:convert' as convert;
//import 'package:flutter_dotenv/flutter_dotenv.dart';
void main() async {
await dotenv.load(fileName: '.env');
//fetchData();
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]).then(
(_) => runApp(
ProviderScope(
child: MyApp(),
),
),
);
}
//class MyApp extends StatelessWidget {
class MyApp extends ConsumerWidget {
Future<void> fetchApiHeart(WidgetRef ref) async {
try {
var response = await http.get(
Uri.parse(globals.base_url + globals.heart_url),
headers: globals.headers);
if (response.statusCode == 200) {
Iterable user = convert.jsonDecode(response.body);
//print('Message: ${user.first}');
//print(user.first['value']);
globals.heartRate = user.first['value'];
//globals.heartRateProvider = user.first['value'];
ref.watch(globals.heartRateProvider).state = globals.heartRate;
if (globals.heartRate > globals.heartRateHigh) {
globals.heartRateHigh = globals.heartRate;
}
if (globals.heartRate < globals.heartRateLow) {
globals.heartRateLow = globals.heartRate;
}
} else {
print('Request failed with status: ${response.statusCode}.');
}
} catch (e) {
print("$e");
}
}
Future<void> fetchApiCalories(String uri) async {
try {
var response = await http.get(Uri.parse(uri), headers: globals.headers);
if (response.statusCode == 200) {
Iterable user = convert.jsonDecode(response.body);
print('Cals: ${user.first}');
print(user.first['value']);
globals.dailySteps = user.first['steps'];
globals.dailyCals = user.first['calories'];
globals.dailyKm = user.first['distance'] / 1000.0;
} else {
print('Request failed with status: ${response.statusCode}.');
}
} catch (e) {
print("$e");
}
}
Future<void> fetchApiProfile() async {
try {
var response = await http.get(
Uri.parse(globals.base_url + globals.profile_url),
headers: globals.headers);
if (response.statusCode == 200) {
var user = convert.jsonDecode(response.body);
print('Message: $user');
print('weight: ${user['weight']}');
globals.weight = user['weight'];
} else {
print('Request failed with status: ${response.statusCode}.');
}
} catch (e) {
print("$e");
}
}
void fetchData(WidgetRef ref) {
globals.headers['X-API-Key'] = dotenv.env['API_KEY'] ?? '';
if (globals.headers['X-API-key'] == '') {
throw Exception('API Key can not be empty!');
}
const fiveSec = Duration(seconds: 5);
//const oneMin = Duration(seconds: 60);
Timer.periodic(
fiveSec,
(Timer t) => fetchApiHeart(ref).then(
(value) => print("Heart Rate fetch success"), onError: (e) {
print("Error: in HTTP invocation: $e");
}));
fetchApiProfile();
fetchApiCalories(globals.base_url + globals.daily_summary_uri);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
//ref.watch(globals.heartRateProvider).state = globals.heartRate;
fetchData(ref);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness:
!kIsWeb && Platform.isAndroid ? Brightness.dark : Brightness.light,
systemNavigationBarColor: Colors.white,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
));
return MaterialApp(
title: 'Planet Health',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: AppTheme.textTheme,
platform: TargetPlatform.iOS,
),
home: NavigationHomeScreen(),
//home: FitnessAppHomeScreen(),
);
}
}
class HexColor extends Color {
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll('#', '');
if (hexColor.length == 6) {
hexColor = 'FF' + hexColor;
}
return int.parse(hexColor, radix: 16);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/lib/navigation_home_screen.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:planet_health/custom_drawer/drawer_user_controller.dart';
import 'package:planet_health/custom_drawer/home_drawer.dart';
import 'package:planet_health/feedback_screen.dart';
import 'package:planet_health/help_screen.dart';
//import 'package:planet_health/home_screen.dart';
import 'package:planet_health/invite_friend_screen.dart';
//import 'package:planet_health/user_data.dart';
//import 'package:provider/provider.dart';
import 'fitness_app/fitness_app_home_screen.dart';
import 'package:flutter/material.dart';
class NavigationHomeScreen extends StatefulWidget {
@override
_NavigationHomeScreenState createState() => _NavigationHomeScreenState();
}
class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
Widget? screenView;
DrawerIndex? drawerIndex;
@override
void initState() {
drawerIndex = DrawerIndex.HOME;
screenView = FitnessAppHomeScreen();
//screenView = const MyHomePage();
super.initState();
}
@override
Widget build(BuildContext context) {
//var count = Provider.of<Counter>(context); // <--
return Container(
color: AppTheme.nearlyWhite,
child: SafeArea(
top: false,
bottom: false,
child: Scaffold(
backgroundColor: AppTheme.nearlyWhite,
body: DrawerUserController(
screenIndex: drawerIndex,
drawerWidth: MediaQuery.of(context).size.width * 0.75,
onDrawerCall: (DrawerIndex drawerIndexdata) {
changeIndex(drawerIndexdata);
//callback from drawer for replace screen as user need with passing DrawerIndex(Enum index)
},
screenView: screenView,
//we replace screen view as we need on navigate starting screens like MyHomePage, HelpScreen, FeedbackScreen, etc...
),
),
),
);
}
//);
//}
void changeIndex(DrawerIndex drawerIndexdata) {
if (drawerIndex != drawerIndexdata) {
drawerIndex = drawerIndexdata;
if (drawerIndex == DrawerIndex.HOME) {
setState(() {
screenView = FitnessAppHomeScreen();
//screenView = const MyHomePage();
});
} else if (drawerIndex == DrawerIndex.Help) {
setState(() {
screenView = HelpScreen();
});
} else if (drawerIndex == DrawerIndex.FeedBack) {
setState(() {
screenView = FeedbackScreen();
});
} else if (drawerIndex == DrawerIndex.Invite) {
setState(() {
screenView = InviteFriend();
});
} else {
//do in your way......
}
}
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib
|
mirrored_repositories/hack_zurich/planet_health/lib/model/homelist.dart
|
//import 'package:best_flutter_ui_templates/design_course/home_design_course.dart';
import 'package:planet_health/fitness_app/fitness_app_home_screen.dart';
//import 'package:best_flutter_ui_templates/hotel_booking/hotel_home_screen.dart';
//import 'package:best_flutter_ui_templates/introduction_animation/introduction_animation_screen.dart';
import 'package:flutter/widgets.dart';
class HomeList {
HomeList({
this.navigateScreen,
this.imagePath = '',
});
Widget? navigateScreen;
String imagePath;
static List<HomeList> homeList = [
//HomeList(
// imagePath: 'assets/introduction_animation/introduction_animation.png',
// navigateScreen: IntroductionAnimationScreen(),
//),
//HomeList(
// imagePath: 'assets/hotel/hotel_booking.png',
// navigateScreen: HotelHomeScreen(),
//),
HomeList(
imagePath: 'assets/fitness_app/fitness_app.png',
navigateScreen: FitnessAppHomeScreen(),
),
//HomeList(
// imagePath: 'assets/design_course/design_course.png',
// navigateScreen: DesignCourseHomeScreen(),
//),
];
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib
|
mirrored_repositories/hack_zurich/planet_health/lib/custom_drawer/home_drawer.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:flutter/material.dart';
class HomeDrawer extends StatefulWidget {
const HomeDrawer(
{Key? key,
this.screenIndex,
this.iconAnimationController,
this.callBackIndex})
: super(key: key);
final AnimationController? iconAnimationController;
final DrawerIndex? screenIndex;
final Function(DrawerIndex)? callBackIndex;
@override
_HomeDrawerState createState() => _HomeDrawerState();
}
class _HomeDrawerState extends State<HomeDrawer> {
List<DrawerList>? drawerList;
@override
void initState() {
setDrawerListArray();
super.initState();
}
void setDrawerListArray() {
drawerList = <DrawerList>[
DrawerList(
index: DrawerIndex.HOME,
labelName: 'Home',
icon: Icon(Icons.home),
),
DrawerList(
index: DrawerIndex.Help,
labelName: 'Help',
isAssetsImage: true,
imageName: 'assets/images/supportIcon.png',
),
DrawerList(
index: DrawerIndex.FeedBack,
labelName: 'FeedBack',
icon: Icon(Icons.help),
),
DrawerList(
index: DrawerIndex.Invite,
labelName: 'Invite Friend',
icon: Icon(Icons.email),
),
DrawerList(
index: DrawerIndex.Share,
labelName: 'Become a sponsor',
icon: Icon(Icons.group),
),
DrawerList(
index: DrawerIndex.About,
labelName: 'About Us',
icon: Icon(Icons.info),
),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppTheme.notWhite.withOpacity(0.5),
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
width: double.infinity,
padding: const EdgeInsets.only(top: 40.0),
child: Container(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
AnimatedBuilder(
animation: widget.iconAnimationController!,
builder: (BuildContext context, Widget? child) {
return ScaleTransition(
scale: AlwaysStoppedAnimation<double>(1.0 -
(widget.iconAnimationController!.value) * 0.2),
child: RotationTransition(
turns: AlwaysStoppedAnimation<double>(Tween<double>(
begin: 0.0, end: 24.0)
.animate(CurvedAnimation(
parent: widget.iconAnimationController!,
curve: Curves.fastOutSlowIn))
.value /
360),
child: Container(
height: 120,
width: 120,
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: AppTheme.grey.withOpacity(0.6),
offset: const Offset(2.0, 4.0),
blurRadius: 8),
],
),
child: ClipRRect(
borderRadius:
const BorderRadius.all(Radius.circular(60.0)),
child: Image.asset('assets/images/greta.jpeg'),
),
),
),
);
},
),
Padding(
padding: const EdgeInsets.only(top: 8, left: 4),
child: Text(
'Greta Thunberg',
style: TextStyle(
fontWeight: FontWeight.w600,
color: AppTheme.grey,
fontSize: 18,
),
),
),
],
),
),
),
const SizedBox(
height: 4,
),
Divider(
height: 1,
color: AppTheme.grey.withOpacity(0.6),
),
Expanded(
child: ListView.builder(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.all(0.0),
itemCount: drawerList?.length,
itemBuilder: (BuildContext context, int index) {
return inkwell(drawerList![index]);
},
),
),
Divider(
height: 1,
color: AppTheme.grey.withOpacity(0.6),
),
Column(
children: <Widget>[
ListTile(
title: Text(
'Sign Out',
style: TextStyle(
fontFamily: AppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 16,
color: AppTheme.darkText,
),
textAlign: TextAlign.left,
),
trailing: Icon(
Icons.power_settings_new,
color: Colors.red,
),
onTap: () {
onTapped();
},
),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
],
),
);
}
void onTapped() {
print('Doing Something...'); // Print to console.
}
Widget inkwell(DrawerList listData) {
return Material(
color: Colors.transparent,
child: InkWell(
splashColor: Colors.grey.withOpacity(0.1),
highlightColor: Colors.transparent,
onTap: () {
navigationtoScreen(listData.index!);
},
child: Stack(
children: <Widget>[
Container(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Row(
children: <Widget>[
Container(
width: 6.0,
height: 46.0,
// decoration: BoxDecoration(
// color: widget.screenIndex == listData.index
// ? Colors.blue
// : Colors.transparent,
// borderRadius: new BorderRadius.only(
// topLeft: Radius.circular(0),
// topRight: Radius.circular(16),
// bottomLeft: Radius.circular(0),
// bottomRight: Radius.circular(16),
// ),
// ),
),
const Padding(
padding: EdgeInsets.all(4.0),
),
listData.isAssetsImage
? Container(
width: 24,
height: 24,
child: Image.asset(listData.imageName,
color: widget.screenIndex == listData.index
? Colors.blue
: AppTheme.nearlyBlack),
)
: Icon(listData.icon?.icon,
color: widget.screenIndex == listData.index
? Colors.blue
: AppTheme.nearlyBlack),
const Padding(
padding: EdgeInsets.all(4.0),
),
Text(
listData.labelName,
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16,
color: widget.screenIndex == listData.index
? Colors.blue
: AppTheme.nearlyBlack,
),
textAlign: TextAlign.left,
),
],
),
),
widget.screenIndex == listData.index
? AnimatedBuilder(
animation: widget.iconAnimationController!,
builder: (BuildContext context, Widget? child) {
return Transform(
transform: Matrix4.translationValues(
(MediaQuery.of(context).size.width * 0.75 - 64) *
(1.0 -
widget.iconAnimationController!.value -
1.0),
0.0,
0.0),
child: Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Container(
width:
MediaQuery.of(context).size.width * 0.75 - 64,
height: 46,
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.2),
borderRadius: new BorderRadius.only(
topLeft: Radius.circular(0),
topRight: Radius.circular(28),
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(28),
),
),
),
),
);
},
)
: const SizedBox()
],
),
),
);
}
Future<void> navigationtoScreen(DrawerIndex indexScreen) async {
widget.callBackIndex!(indexScreen);
}
}
enum DrawerIndex {
HOME,
FeedBack,
Help,
Share,
About,
Invite,
Testing,
}
class DrawerList {
DrawerList({
this.isAssetsImage = false,
this.labelName = '',
this.icon,
this.index,
this.imageName = '',
});
String labelName;
Icon? icon;
bool isAssetsImage;
String imageName;
DrawerIndex? index;
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib
|
mirrored_repositories/hack_zurich/planet_health/lib/custom_drawer/drawer_user_controller.dart
|
import 'package:planet_health/app_theme.dart';
import 'package:planet_health/custom_drawer/home_drawer.dart';
import 'package:flutter/material.dart';
class DrawerUserController extends StatefulWidget {
const DrawerUserController({
Key? key,
this.drawerWidth = 250,
this.onDrawerCall,
this.screenView,
this.animatedIconData = AnimatedIcons.arrow_menu,
this.menuView,
this.drawerIsOpen,
this.screenIndex,
}) : super(key: key);
final double drawerWidth;
final Function(DrawerIndex)? onDrawerCall;
final Widget? screenView;
final Function(bool)? drawerIsOpen;
final AnimatedIconData? animatedIconData;
final Widget? menuView;
final DrawerIndex? screenIndex;
@override
_DrawerUserControllerState createState() => _DrawerUserControllerState();
}
class _DrawerUserControllerState extends State<DrawerUserController>
with TickerProviderStateMixin {
ScrollController? scrollController;
AnimationController? iconAnimationController;
AnimationController? animationController;
double scrolloffset = 0.0;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
iconAnimationController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 0));
iconAnimationController
?..animateTo(1.0,
duration: const Duration(milliseconds: 0),
curve: Curves.fastOutSlowIn);
scrollController =
ScrollController(initialScrollOffset: widget.drawerWidth);
scrollController!
..addListener(() {
if (scrollController!.offset <= 0) {
if (scrolloffset != 1.0) {
setState(() {
scrolloffset = 1.0;
try {
widget.drawerIsOpen!(true);
} catch (_) {}
});
}
iconAnimationController?.animateTo(0.0,
duration: const Duration(milliseconds: 0),
curve: Curves.fastOutSlowIn);
} else if (scrollController!.offset > 0 &&
scrollController!.offset < widget.drawerWidth.floor()) {
iconAnimationController?.animateTo(
(scrollController!.offset * 100 / (widget.drawerWidth)) / 100,
duration: const Duration(milliseconds: 0),
curve: Curves.fastOutSlowIn);
} else {
if (scrolloffset != 0.0) {
setState(() {
scrolloffset = 0.0;
try {
widget.drawerIsOpen!(false);
} catch (_) {}
});
}
iconAnimationController?.animateTo(1.0,
duration: const Duration(milliseconds: 0),
curve: Curves.fastOutSlowIn);
}
});
WidgetsBinding.instance?.addPostFrameCallback((_) => getInitState());
super.initState();
}
Future<bool> getInitState() async {
scrollController?.jumpTo(
widget.drawerWidth,
);
return true;
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppTheme.white,
body: SingleChildScrollView(
controller: scrollController,
scrollDirection: Axis.horizontal,
physics: const PageScrollPhysics(parent: ClampingScrollPhysics()),
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width + widget.drawerWidth,
//we use with as screen width and add drawerWidth (from navigation_home_screen)
child: Row(
children: <Widget>[
SizedBox(
width: widget.drawerWidth,
//we divided first drawer Width with HomeDrawer and second full-screen Width with all home screen, we called screen View
height: MediaQuery.of(context).size.height,
child: AnimatedBuilder(
animation: iconAnimationController!,
builder: (BuildContext context, Widget? child) {
return Transform(
//transform we use for the stable drawer we, not need to move with scroll view
transform: Matrix4.translationValues(
scrollController!.offset, 0.0, 0.0),
child: HomeDrawer(
screenIndex: widget.screenIndex == null
? DrawerIndex.HOME
: widget.screenIndex,
iconAnimationController: iconAnimationController,
callBackIndex: (DrawerIndex indexType) {
onDrawerClick();
try {
widget.onDrawerCall!(indexType);
} catch (e) {}
},
),
);
},
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
//full-screen Width with widget.screenView
child: Container(
decoration: BoxDecoration(
color: AppTheme.white,
boxShadow: <BoxShadow>[
BoxShadow(
color: AppTheme.grey.withOpacity(0.6),
blurRadius: 24),
],
),
child: Stack(
children: <Widget>[
//this IgnorePointer we use as touch(user Interface) widget.screen View, for example scrolloffset == 1 means drawer is close we just allow touching all widget.screen View
IgnorePointer(
ignoring: scrolloffset == 1 || false,
child: widget.screenView,
),
//alternative touch(user Interface) for widget.screen, for example, drawer is close we need to tap on a few home screen area and close the drawer
if (scrolloffset == 1.0)
InkWell(
onTap: () {
onDrawerClick();
},
),
// this just menu and arrow icon animation
Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 8,
left: 8),
child: SizedBox(
width: AppBar().preferredSize.height - 8,
height: AppBar().preferredSize.height - 8,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(
AppBar().preferredSize.height),
child: Center(
// if you use your own menu view UI you add form initialization
child: widget.menuView != null
? widget.menuView
: AnimatedIcon(
icon: widget.animatedIconData ??
AnimatedIcons.arrow_menu,
progress: iconAnimationController!),
),
onTap: () {
FocusScope.of(context)
.requestFocus(FocusNode());
onDrawerClick();
},
),
),
),
),
],
),
),
),
],
),
),
),
);
}
void onDrawerClick() {
//if scrollcontroller.offset != 0.0 then we set to closed the drawer(with animation to offset zero position) if is not 1 then open the drawer
if (scrollController!.offset != 0.0) {
scrollController?.animateTo(
0.0,
duration: const Duration(milliseconds: 400),
curve: Curves.fastOutSlowIn,
);
} else {
scrollController?.animateTo(
widget.drawerWidth,
duration: const Duration(milliseconds: 400),
curve: Curves.fastOutSlowIn,
);
}
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/fitness_app_theme.dart
|
import 'package:flutter/material.dart';
class FitnessAppTheme {
FitnessAppTheme._();
static const Color nearlyWhite = Color(0xFFFAFAFA);
static const Color white = Color(0xFFFFFFFF);
static const Color background = Color(0xFFF2F3F8);
static const Color nearlyDarkBlue = Color(0xFF2633C5);
static const Color nearlyPink = Color(0xFFF5C9DB);
static const Color nearlyRed = Colors.red;
static Color nearlyYellow = Colors.orange.shade400;
static Color nearlyGreen = Colors.green.shade400;
static Color nearlyGreen1 = Colors.green.shade900;
static const Color nearlyBlue = Color(0xFF00B6F0);
static const Color nearlyBlack = Color(0xFF213333);
static const Color grey = Color(0xFF3A5160);
static const Color dark_grey = Color(0xFF313A44);
static const Color darkText = Color(0xFF253840);
static const Color darkerText = Color(0xFF17262A);
static const Color lightText = Color(0xFF4A6572);
static const Color deactivatedText = Color(0xFF767676);
static const Color dismissibleBackground = Color(0xFF364A54);
static const Color spacer = Color(0xFFF2F2F2);
static const String fontName = 'Roboto';
static const TextTheme textTheme = TextTheme(
headline4: display1,
headline5: headline,
headline6: title,
subtitle2: subtitle,
bodyText2: body2,
bodyText1: body1,
caption: caption,
);
static const TextStyle display1 = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 36,
letterSpacing: 0.4,
height: 0.9,
color: darkerText,
);
static const TextStyle headline = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 24,
letterSpacing: 0.27,
color: darkerText,
);
static const TextStyle title = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.18,
color: darkerText,
);
static const TextStyle subtitle = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.04,
color: darkText,
);
static const TextStyle body2 = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: 0.2,
color: darkText,
);
static const TextStyle body1 = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.05,
color: darkText,
);
static const TextStyle caption = TextStyle(
fontFamily: fontName,
fontWeight: FontWeight.w400,
fontSize: 12,
letterSpacing: 0.2,
color: lightText, // was lightText
);
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/fitness_app_home_screen.dart
|
import 'package:planet_health/fitness_app/models/tabIcon_data.dart';
import 'package:planet_health/fitness_app/my_covid/my_covid_screen.dart';
import 'package:planet_health/fitness_app/training/training_screen.dart';
import 'package:planet_health/fitness_app/my_co2/my_co2_screen.dart';
import 'package:flutter/material.dart';
import 'bottom_navigation_view/bottom_bar_view.dart';
import 'fitness_app_theme.dart';
import 'my_diary/my_diary_screen.dart';
//import 'dart:convert' as convert;
//import 'package:http/http.dart' as http;
//import 'package:planet_health/globals.dart' as globals;
class FitnessAppHomeScreen extends StatefulWidget {
@override
_FitnessAppHomeScreenState createState() => _FitnessAppHomeScreenState();
}
class _FitnessAppHomeScreenState extends State<FitnessAppHomeScreen>
with TickerProviderStateMixin {
AnimationController? animationController;
List<TabIconData> tabIconsList = TabIconData.tabIconsList;
Widget tabBody = Container(
color: FitnessAppTheme.background,
);
@override
void initState() {
tabIconsList.forEach((TabIconData tab) {
tab.isSelected = false;
});
tabIconsList[0].isSelected = true;
animationController = AnimationController(
duration: const Duration(milliseconds: 600), vsync: this);
tabBody = MyDiaryScreen(animationController: animationController);
super.initState();
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
color: FitnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return Stack(
children: <Widget>[
tabBody,
bottomBar(),
],
);
}
},
),
),
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 200));
return true;
}
Widget setupAlertDialogContainer() {
double _fontsz = 20;
return Container(
height: 400.0, // Change as per your requirement
width: 300.0, // Change as per your requirement
//color: Colors.blue.shade50,
//padding: EdgeInsets.all(10.0),
//margin: EdgeInsets.all(15.0),
//decoration: BoxDecoration(
// borderRadius: BorderRadius.only(
// topRight: Radius.circular(500),
// ),
//),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'Doctor visit',
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
Icon(Icons.local_hospital,
color: Colors.white, size: _fontsz + 10),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'Personal trainer',
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
Icon(Icons.fitness_center,
color: Colors.white, size: _fontsz + 10),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'COVID-19',
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
Icon(Icons.coronavirus, color: Colors.white, size: _fontsz + 10),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'Emergency',
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
Icon(Icons.phone, color: Colors.white, size: _fontsz + 10),
],
),
],
),
);
}
Widget bottomBar() {
return Column(
children: <Widget>[
const Expanded(
child: SizedBox(),
),
BottomBarView(
tabIconsList: tabIconsList,
addClick: () {
print('Call Doctor');
print('Call AR');
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.only(topRight: Radius.circular(50))),
backgroundColor: Colors.black.withOpacity(0.3),
title: new Text(''),
content: setupAlertDialogContainer(),
);
});
},
changeIndex: (int index) {
if (index == 0) {
animationController?.reverse().then<dynamic>((data) {
if (!mounted) {
return;
}
setState(() {
tabBody =
MyDiaryScreen(animationController: animationController);
});
});
} else if (index == 2) {
animationController?.reverse().then<dynamic>((data) {
if (!mounted) {
return;
}
setState(() {
tabBody =
MyCo2Screen(animationController: animationController);
});
});
} else if (index == 1) {
animationController?.reverse().then<dynamic>((data) {
if (!mounted) {
return;
}
setState(() {
tabBody =
TrainingScreen(animationController: animationController);
});
});
} else if (index == 3) {
animationController?.reverse().then<dynamic>((data) {
if (!mounted) {
return;
}
setState(() {
tabBody =
MyCovidScreen(animationController: animationController);
});
});
}
},
),
],
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/training/meals_list_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/models/meals_list_data.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../../main.dart';
class MealsListView extends StatefulWidget {
const MealsListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_MealsListViewState createState() => _MealsListViewState();
}
class _MealsListViewState extends State<MealsListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<MealsListData> mealsListData = MealsListData.tabIconsList;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Container(
height: 216,
width: double.infinity,
child: ListView.builder(
padding: const EdgeInsets.only(
top: 0, bottom: 0, right: 16, left: 16),
itemCount: mealsListData.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
final int count =
mealsListData.length > 10 ? 10 : mealsListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn)));
animationController?.forward();
return MealsView(
mealsListData: mealsListData[index],
animation: animation,
animationController: animationController!,
);
},
),
),
),
);
},
);
}
}
class MealsView extends StatelessWidget {
const MealsView(
{Key? key, this.mealsListData, this.animationController, this.animation})
: super(key: key);
final MealsListData? mealsListData;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
100 * (1.0 - animation!.value), 0.0, 0.0),
child: SizedBox(
width: 130,
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 32, left: 8, right: 8, bottom: 16),
child: Container(
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: HexColor(mealsListData!.endColor)
.withOpacity(0.6),
offset: const Offset(1.1, 4.0),
blurRadius: 8.0),
],
gradient: LinearGradient(
colors: <HexColor>[
HexColor(mealsListData!.startColor),
HexColor(mealsListData!.endColor),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: const BorderRadius.only(
bottomRight: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
topLeft: Radius.circular(8.0),
topRight: Radius.circular(54.0),
),
),
child: Padding(
padding: const EdgeInsets.only(
top: 54, left: 16, right: 16, bottom: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.titleTxt,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.meals!.join('\n'),
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
],
),
),
),
mealsListData?.kacl != 0
? Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
mealsListData!.kacl.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 24,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'CO2',
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
),
],
)
: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color:
HexColor(mealsListData!.endColor),
size: 24,
),
),
),
],
),
),
),
),
Positioned(
top: 0,
left: 0,
child: Container(
width: 84,
height: 84,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite.withOpacity(0.2),
shape: BoxShape.circle,
),
),
),
Positioned(
top: 0,
left: 8,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset(mealsListData!.imagePath),
),
)
],
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/training/training_screen.dart
|
//import 'package:planet_health/fitness_app/models/meals_list_data.dart';
//import 'package:planet_health/fitness_app/models/meals_list_data_diary.dart';
//import 'package:planet_health/fitness_app/training/meals_list_view.dart';
import 'package:planet_health/fitness_app/ui_view/training_list_view.dart';
//import 'package:planet_health/fitness_app/ui_view/running_view.dart';
import 'package:planet_health/fitness_app/ui_view/title_view.dart';
import 'package:planet_health/fitness_app/ui_view/glass_view_training.dart';
import 'package:planet_health/fitness_app/ui_view/workout_view.dart';
import 'package:planet_health/fitness_app/ui_view/training_measurement_card.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class TrainingScreen extends StatefulWidget {
const TrainingScreen({Key? key, this.animationController}) : super(key: key);
final AnimationController? animationController;
@override
_TrainingScreenState createState() => _TrainingScreenState();
}
class _TrainingScreenState extends State<TrainingScreen>
with TickerProviderStateMixin {
Animation<double>? topBarAnimation;
List<Widget> listViews = <Widget>[];
final ScrollController scrollController = ScrollController();
double topBarOpacity = 0.0;
@override
void initState() {
topBarAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn)));
addAllListData();
scrollController.addListener(() {
if (scrollController.offset >= 24) {
if (topBarOpacity != 1.0) {
setState(() {
topBarOpacity = 1.0;
});
}
} else if (scrollController.offset <= 24 &&
scrollController.offset >= 0) {
if (topBarOpacity != scrollController.offset / 24) {
setState(() {
topBarOpacity = scrollController.offset / 24;
});
}
} else if (scrollController.offset <= 0) {
if (topBarOpacity != 0.0) {
setState(() {
topBarOpacity = 0.0;
});
}
}
});
super.initState();
}
void addAllListData() {
const int count = 5;
listViews.add(
TitleView(
titleTxt: 'Your program',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 0, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
WorkoutView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
//listViews.add(
// RunningView(
// animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
// parent: widget.animationController!,
// curve:
// Interval((1 / count) * 3, 1.0, curve: Curves.fastOutSlowIn))),
// animationController: widget.animationController!,
// ),
//);
listViews.add(
TrainingMeasurementView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 5, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
//listViews.add(
// MealsListView(
// mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
// CurvedAnimation(
// parent: widget.animationController!,
// curve: Interval((1 / count) * 3, 1.0,
// curve: Curves.fastOutSlowIn))),
// mainScreenAnimationController: widget.animationController,
// ),
//);
listViews.add(
TitleView(
titleTxt: 'Recommended sports',
subTxt: 'Schedule',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 4, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
TrainingListView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 5, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController!,
),
);
// Share button
listViews.add(
GlassView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 8, 1.0,
curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!),
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return Container(
color: FitnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: <Widget>[
getMainListViewUI(),
getAppBarUI(),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
}
Widget getMainListViewUI() {
return FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ListView.builder(
controller: scrollController,
padding: EdgeInsets.only(
top: AppBar().preferredSize.height +
MediaQuery.of(context).padding.top +
24,
bottom: 62 + MediaQuery.of(context).padding.bottom,
),
itemCount: listViews.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
widget.animationController?.forward();
return listViews[index];
},
);
}
},
);
}
Widget getAppBarUI() {
return Column(
children: <Widget>[
AnimatedBuilder(
animation: widget.animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: topBarAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - topBarAnimation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(topBarOpacity),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(32.0),
),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey
.withOpacity(0.4 * topBarOpacity),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Padding(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16 - 8.0 * topBarOpacity,
bottom: 12 - 8.0 * topBarOpacity),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
' Training',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w700,
fontSize: 22 + 6 - 6 * topBarOpacity,
letterSpacing: 1.2,
color: FitnessAppTheme.darkerText,
),
),
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_left,
color: FitnessAppTheme.grey,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8),
child: Icon(
Icons.calendar_today,
color: FitnessAppTheme.grey,
size: 18,
),
),
Text(
//'26 Sep',
//'${DateTime.now().day}.${DateTime.now().month}',
'${DateTime.now().day}.${DateTime.now().month}.${DateTime.now().year}',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.darkerText,
),
),
],
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_right,
color: FitnessAppTheme.grey,
),
),
),
),
],
),
)
],
),
),
),
);
},
)
],
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_diary/meals_list_view.dart
|
import 'dart:math';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/models/meals_list_data_diary.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import 'package:planet_health/globals.dart' as globals;
import '../../main.dart';
class MealsListView extends StatefulWidget {
const MealsListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_MealsListViewState createState() => _MealsListViewState();
}
class _MealsListViewState extends State<MealsListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<MealsListDataDiary> mealsListData = MealsListDataDiary.tabIconsList;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Container(
height: 216,
width: double.infinity,
child: ListView.builder(
padding: const EdgeInsets.only(
top: 0, bottom: 0, right: 16, left: 16),
itemCount: mealsListData.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
final int count =
mealsListData.length > 10 ? 10 : mealsListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn)));
animationController?.forward();
return MealsView(
mealsListData: mealsListData[index],
animation: animation,
animationController: animationController!,
);
},
),
),
),
);
},
);
}
}
class MealsView extends StatelessWidget {
const MealsView(
{Key? key, this.mealsListData, this.animationController, this.animation})
: super(key: key);
final MealsListDataDiary? mealsListData;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
100 * (1.0 - animation!.value), 0.0, 0.0),
child: SizedBox(
width: 130,
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 32, left: 8, right: 8, bottom: 16),
child: GestureDetector(
onTap: () {
var days = [globals.day1, globals.day2];
var today = days[Random().nextInt(days.length)];
var totalKcal = 0;
var totalCo2e = 0;
for (var meal in today) {
totalKcal += meal.calories;
totalCo2e += meal.co2;
}
globals.totalCo2e = totalCo2e;
print('Gesture detector');
String dialogText = 'Your Meal: \n\n';
for (var item in today) {
dialogText += '- ' +
item.name +
' (' +
item.calories.toString() +
' kcal)\n';
}
dialogText += '\nTotal (kcal): $totalKcal';
if (totalKcal > 500) {
dialogText += '\n\nHigh Caloric Intake\n\n' +
'Recommendation:\nPlan workout';
} else {
dialogText += '\n\nBeyond Awesome!';
}
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(50))),
backgroundColor: Colors.black.withOpacity(0.3),
title: new Text(''),
content: setupAlertDialogContainer(dialogText),
);
});
},
child: Container(
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: HexColor(mealsListData!.endColor)
.withOpacity(0.6),
offset: const Offset(1.1, 4.0),
blurRadius: 8.0),
],
gradient: LinearGradient(
colors: <HexColor>[
HexColor(mealsListData!.startColor),
HexColor(mealsListData!.endColor),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: const BorderRadius.only(
bottomRight: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
topLeft: Radius.circular(8.0),
topRight: Radius.circular(54.0),
),
),
child: Padding(
padding: const EdgeInsets.only(
top: 54, left: 16, right: 16, bottom: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.titleTxt,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.meals!.join('\n'),
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
],
),
),
),
mealsListData?.kacl != 0
? Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
Text(
mealsListData!.kacl.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 24,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'kcal',
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
),
],
)
: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color:
HexColor(mealsListData!.endColor),
size: 24,
),
),
),
],
),
),
),
),
),
Positioned(
top: 0,
left: 0,
child: Container(
width: 84,
height: 84,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite.withOpacity(0.2),
shape: BoxShape.circle,
),
),
),
Positioned(
top: 0,
left: 8,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset(mealsListData!.imagePath),
),
)
],
),
),
),
);
},
);
}
// beef = globals.
Widget setupAlertDialogContainer(String dialogText) {
double _fontsz = 20;
return Container(
height: 400.0, // Change as per your requirement
width: 300.0, // Change as per your requirement
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
dialogText,
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
],
),
SizedBox(height: 10),
],
),
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_diary/my_diary_screen.dart
|
import 'package:planet_health/fitness_app/ui_view/body_measurement_diary.dart';
import 'package:planet_health/fitness_app/ui_view/stress_measurement_diary.dart';
import 'package:planet_health/fitness_app/ui_view/glass_view_diary.dart';
import 'package:planet_health/fitness_app/ui_view/heart_view.dart';
//import 'package:planet_health/fitness_app/ui_view/mediterranean_diet_view.dart';
import 'package:planet_health/fitness_app/ui_view/title_view.dart';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/my_diary/meals_list_view.dart';
import 'package:planet_health/fitness_app/my_diary/water_view.dart';
import 'package:planet_health/fitness_app/ui_view/running_view_diary.dart';
import 'package:flutter/material.dart';
class MyDiaryScreen extends StatefulWidget {
const MyDiaryScreen({Key? key, this.animationController}) : super(key: key);
final AnimationController? animationController;
@override
_MyDiaryScreenState createState() => _MyDiaryScreenState();
}
class _MyDiaryScreenState extends State<MyDiaryScreen>
with TickerProviderStateMixin {
Animation<double>? topBarAnimation;
List<Widget> listViews = <Widget>[];
final ScrollController scrollController = ScrollController();
double topBarOpacity = 0.0;
@override
void initState() {
topBarAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn)));
addAllListData();
scrollController.addListener(() {
if (scrollController.offset >= 24) {
if (topBarOpacity != 1.0) {
setState(() {
topBarOpacity = 1.0;
});
}
} else if (scrollController.offset <= 24 &&
scrollController.offset >= 0) {
if (topBarOpacity != scrollController.offset / 24) {
setState(() {
topBarOpacity = scrollController.offset / 24;
});
}
} else if (scrollController.offset <= 0) {
if (topBarOpacity != 0.0) {
setState(() {
topBarOpacity = 0.0;
});
}
}
});
super.initState();
}
void addAllListData() {
const int count = 9;
listViews.add(
TitleView(
titleTxt: 'Body Measurements',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 0, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
HeartView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 1, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
// Nutrition
listViews.add(
TitleView(
titleTxt: 'Daily nutrition',
subTxt: 'Customize',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
MealsListView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 3, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController,
),
);
// WATER START
listViews.add(
TitleView(
titleTxt: 'Water',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 6, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
WaterView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 7, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController!,
),
);
// WATER END
// BMI
listViews.add(
TitleView(
titleTxt: 'BMI calculator',
subTxt: 'Today',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 4, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
BodyMeasurementViewDiary(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 5, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
// STRESS+SLEEP
listViews.add(
TitleView(
titleTxt: 'Sleep data',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 4, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
StressMeasurementViewDiary(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 5, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
// 2x running views
listViews.add(
RunningViewDiary1(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 3, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
RunningViewDiary2(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 3, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
GlassView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 8, 1.0,
curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!),
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return Container(
color: FitnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: <Widget>[
getMainListViewUI(),
getAppBarUI(),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
}
Widget getMainListViewUI() {
return FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ListView.builder(
controller: scrollController,
padding: EdgeInsets.only(
top: AppBar().preferredSize.height +
MediaQuery.of(context).padding.top +
24,
bottom: 62 + MediaQuery.of(context).padding.bottom,
),
itemCount: listViews.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
widget.animationController?.forward();
return listViews[index];
},
);
}
},
);
}
Widget getAppBarUI() {
return Column(
children: <Widget>[
AnimatedBuilder(
animation: widget.animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: topBarAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - topBarAnimation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(topBarOpacity),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(32.0),
),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey
.withOpacity(0.4 * topBarOpacity),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Padding(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16 - 8.0 * topBarOpacity,
bottom: 12 - 8.0 * topBarOpacity),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
' My Health',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w700,
fontSize: 22 + 6 - 6 * topBarOpacity,
letterSpacing: 1.2,
color: FitnessAppTheme.darkerText,
),
),
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_left,
color: FitnessAppTheme.grey,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8),
child: Icon(
Icons.calendar_today,
color: FitnessAppTheme.grey,
size: 18,
),
),
Text(
//'${DateTime.now().day}.${DateTime.now().month}',
'${DateTime.now().day}.${DateTime.now().month}.${DateTime.now().year}',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.darkerText,
),
),
],
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_right,
color: FitnessAppTheme.grey,
),
),
),
),
],
),
)
],
),
),
),
);
},
)
],
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_diary/water_view.dart
|
import 'package:planet_health/fitness_app/ui_view/wave_view.dart';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
class WaterView extends StatefulWidget {
const WaterView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_WaterViewState createState() => _WaterViewState();
}
class _WaterViewState extends State<WaterView> with TickerProviderStateMixin {
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Padding(
padding: const EdgeInsets.only(
top: 16, left: 16, right: 16, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'1200',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 32,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'ml',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, top: 2, bottom: 14),
child: Text(
'of daily goal 2L',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.darkText,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, right: 4, top: 8, bottom: 16),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: const BorderRadius.all(
Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Last drink 11.10 AM',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 24,
height: 24,
child: Image.asset(
'assets/fitness_app/drop.png'),
),
Flexible(
child: Text(
'Drink your way to better health!',
textAlign: TextAlign.start,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
),
],
),
)
],
),
),
SizedBox(
width: 34,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
const SizedBox(
height: 28,
),
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.remove,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
],
),
),
Padding(
padding:
const EdgeInsets.only(left: 16, right: 8, top: 16),
child: Container(
width: 60,
height: 160,
decoration: BoxDecoration(
color: HexColor('#E8EDFE'),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(80.0),
bottomLeft: Radius.circular(80.0),
bottomRight: Radius.circular(80.0),
topRight: Radius.circular(80.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: const Offset(2, 2),
blurRadius: 4),
],
),
child: WaveView(
percentageValue: 60.0,
),
),
)
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/models/meals_list_data_diary.dart
|
class MealsListDataDiary {
MealsListDataDiary({
this.imagePath = '',
this.titleTxt = '',
this.startColor = '',
this.endColor = '',
this.meals,
this.kacl = 0,
});
String imagePath;
String titleTxt;
String startColor;
String endColor;
List<String>? meals;
int kacl;
static List<MealsListDataDiary> tabIconsList = <MealsListDataDiary>[
MealsListDataDiary(
imagePath: 'assets/fitness_app/breakfast.png',
titleTxt: 'Breakfast',
kacl: 525,
meals: <String>['Breads,', 'Peanut butter,', 'Apple'],
startColor: '#FA7D82',
endColor: '#FFB295',
),
MealsListDataDiary(
imagePath: 'assets/fitness_app/lunch.png',
titleTxt: 'Lunch',
kacl: 602,
meals: <String>['Salmon,', 'Mixed veggies,', 'Avocado'],
startColor: '#738AE6',
endColor: '#5C5EDD',
),
MealsListDataDiary(
imagePath: 'assets/fitness_app/snack.png',
titleTxt: 'Snack',
kacl: 0,
meals: <String>['Recommend:', '800 kcal'],
startColor: '#FE95B6',
endColor: '#FF5287',
),
MealsListDataDiary(
imagePath: 'assets/fitness_app/dinner.png',
titleTxt: 'Dinner',
kacl: 0,
meals: <String>['Recommend:', '703 kcal'],
startColor: '#6F72CA',
endColor: '#1E1466',
),
];
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/models/meals_list_data.dart
|
class MealsListData {
MealsListData({
this.imagePath = '',
this.titleTxt = '',
this.startColor = '',
this.endColor = '',
this.meals,
this.kacl = 0,
});
String imagePath;
String titleTxt;
String startColor;
String endColor;
List<String>? meals;
double kacl;
static List<MealsListData> tabIconsList = <MealsListData>[
MealsListData(
imagePath: 'assets/fitness_app/dinner.png',
titleTxt: 'Meat',
kacl: -5.3,
meals: <String>['Reduction of\nmeat is\nnecessary'],
startColor: '#FA7D82',
endColor: '#FFB295',
),
MealsListData(
imagePath: 'assets/fitness_app/apple.png',
titleTxt: 'Veggies',
kacl: -1.1,
meals: <String>['Eat more\nregional veggie\nand fruit!'],
startColor: '#5cdd5c', //#738AE6
endColor: '#5cdd6b', //#5C5EDD
),
MealsListData(
imagePath: 'assets/fitness_app/plane.png',
titleTxt: 'Flights',
kacl: -5,
meals: <String>['Avoid\ndomestic flight!'],
startColor: '#FE95B6',
endColor: '#FF5287',
),
MealsListData(
imagePath: 'assets/fitness_app/vehicle.png',
titleTxt: 'Vehicle',
kacl: -3.0,
meals: <String>['Take public\ntransportation!'],
startColor: '#bdbdc7', //#6F72CA
endColor: '#918f9c', //#1E1466
),
];
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/models/tabIcon_data.dart
|
import 'package:flutter/material.dart';
class TabIconData {
TabIconData({
this.imagePath = '',
this.index = 0,
this.selectedImagePath = '',
this.isSelected = false,
this.animationController,
});
String imagePath;
String selectedImagePath;
bool isSelected;
int index;
AnimationController? animationController;
static List<TabIconData> tabIconsList = <TabIconData>[
TabIconData(
imagePath: 'assets/fitness_app/tab_1.png',
selectedImagePath: 'assets/fitness_app/tab_1s.png',
index: 0,
isSelected: true,
animationController: null,
),
TabIconData(
imagePath: 'assets/fitness_app/tab_2.png',
selectedImagePath: 'assets/fitness_app/tab_2s.png',
index: 1,
isSelected: false,
animationController: null,
),
TabIconData(
imagePath: 'assets/fitness_app/tab_5.png',
selectedImagePath: 'assets/fitness_app/tab_5s.png',
index: 2,
isSelected: false,
animationController: null,
),
TabIconData(
imagePath: 'assets/fitness_app/tab_6.png',
selectedImagePath: 'assets/fitness_app/tab_6s.png',
index: 3,
isSelected: false,
animationController: null,
),
];
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_co2/meals_list_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/models/meals_list_data.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../../main.dart';
class MealsListView extends StatefulWidget {
const MealsListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_MealsListViewState createState() => _MealsListViewState();
}
class _MealsListViewState extends State<MealsListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<MealsListData> mealsListData = MealsListData.tabIconsList;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Container(
height: 216,
width: double.infinity,
child: ListView.builder(
padding: const EdgeInsets.only(
top: 0, bottom: 0, right: 16, left: 16),
itemCount: mealsListData.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
final int count =
mealsListData.length > 10 ? 10 : mealsListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn)));
animationController?.forward();
return MealsView(
mealsListData: mealsListData[index],
animation: animation,
animationController: animationController!,
);
},
),
),
),
);
},
);
}
}
class MealsView extends StatelessWidget {
const MealsView(
{Key? key, this.mealsListData, this.animationController, this.animation})
: super(key: key);
final MealsListData? mealsListData;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
100 * (1.0 - animation!.value), 0.0, 0.0),
child: SizedBox(
width: 130,
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 32, left: 8, right: 8, bottom: 16),
child: Container(
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: HexColor(mealsListData!.endColor)
.withOpacity(0.6),
offset: const Offset(1.1, 4.0),
blurRadius: 8.0),
],
gradient: LinearGradient(
colors: <HexColor>[
HexColor(mealsListData!.startColor),
HexColor(mealsListData!.endColor),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: const BorderRadius.only(
bottomRight: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
topLeft: Radius.circular(8.0),
topRight: Radius.circular(54.0),
),
),
child: Padding(
padding: const EdgeInsets.only(
top: 54, left: 16, right: 16, bottom: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.titleTxt,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.meals!.join('\n'),
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
],
),
),
),
mealsListData?.kacl != 0
? Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
mealsListData!.kacl.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 24,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'CO2',
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
),
],
)
: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color:
HexColor(mealsListData!.endColor),
size: 24,
),
),
),
],
),
),
),
),
Positioned(
top: 0,
left: 0,
child: Container(
width: 84,
height: 84,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite.withOpacity(0.2),
shape: BoxShape.circle,
),
),
),
Positioned(
top: 0,
left: 8,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset(mealsListData!.imagePath),
),
)
],
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_co2/my_co2_screen.dart
|
import 'package:planet_health/fitness_app/ui_view/body_measurement.dart';
import 'package:planet_health/fitness_app/ui_view/glass_view.dart';
//import 'package:planet_health/fitness_app/ui_view/heart_view.dart';
import 'package:planet_health/fitness_app/ui_view/mediterranean_diet_view.dart';
import 'package:planet_health/fitness_app/ui_view/title_view.dart';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/my_co2/meals_list_view.dart';
import 'package:planet_health/fitness_app/my_co2/water_view.dart';
import 'package:flutter/material.dart';
class MyCo2Screen extends StatefulWidget {
const MyCo2Screen({Key? key, this.animationController}) : super(key: key);
final AnimationController? animationController;
@override
_MyCo2ScreenState createState() => _MyCo2ScreenState();
}
class _MyCo2ScreenState extends State<MyCo2Screen>
with TickerProviderStateMixin {
Animation<double>? topBarAnimation;
List<Widget> listViews = <Widget>[];
final ScrollController scrollController = ScrollController();
double topBarOpacity = 0.0;
@override
void initState() {
topBarAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn)));
addAllListData();
scrollController.addListener(() {
if (scrollController.offset >= 24) {
if (topBarOpacity != 1.0) {
setState(() {
topBarOpacity = 1.0;
});
}
} else if (scrollController.offset <= 24 &&
scrollController.offset >= 0) {
if (topBarOpacity != scrollController.offset / 24) {
setState(() {
topBarOpacity = scrollController.offset / 24;
});
}
} else if (scrollController.offset <= 0) {
if (topBarOpacity != 0.0) {
setState(() {
topBarOpacity = 0.0;
});
}
}
});
super.initState();
}
void addAllListData() {
const int count = 9;
listViews.add(
TitleView(
titleTxt: 'Your sustainability',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 0, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
MediterraneanDietView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 1, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
TitleView(
titleTxt: 'Recommendations',
subTxt: 'Customize',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
MealsListView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 3, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController,
),
);
listViews.add(
TitleView(
titleTxt: 'Get educated and win!',
subTxt: 'Weekly quiz',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 4, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
BodyMeasurementView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 5, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
TitleView(
titleTxt: 'Earn Green certificate',
subTxt: 'Donate now',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 6, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
WaterView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 7, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController!,
),
);
listViews.add(
GlassView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 8, 1.0,
curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!),
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return Container(
color: FitnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: <Widget>[
getMainListViewUI(),
getAppBarUI(),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
}
Widget getMainListViewUI() {
return FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ListView.builder(
controller: scrollController,
padding: EdgeInsets.only(
top: AppBar().preferredSize.height +
MediaQuery.of(context).padding.top +
24,
bottom: 62 + MediaQuery.of(context).padding.bottom,
),
itemCount: listViews.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
widget.animationController?.forward();
return listViews[index];
},
);
}
},
);
}
Widget getAppBarUI() {
return Column(
children: <Widget>[
AnimatedBuilder(
animation: widget.animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: topBarAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - topBarAnimation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(topBarOpacity),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(32.0),
),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey
.withOpacity(0.4 * topBarOpacity),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Padding(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16 - 8.0 * topBarOpacity,
bottom: 12 - 8.0 * topBarOpacity),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
' My CO₂',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w700,
fontSize: 22 + 6 - 6 * topBarOpacity,
letterSpacing: 1.2,
color: FitnessAppTheme.darkerText,
),
),
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_left,
color: FitnessAppTheme.grey,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8),
child: Icon(
Icons.calendar_today,
color: FitnessAppTheme.grey,
size: 18,
),
),
Text(
'${DateTime.now().day}.${DateTime.now().month}.${DateTime.now().year}',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.darkerText,
),
),
],
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_right,
color: FitnessAppTheme.grey,
),
),
),
),
],
),
)
],
),
),
),
);
},
)
],
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_co2/water_view.dart
|
import 'package:planet_health/fitness_app/ui_view/wave_view.dart';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
class WaterView extends StatefulWidget {
const WaterView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_WaterViewState createState() => _WaterViewState();
}
class _WaterViewState extends State<WaterView> with TickerProviderStateMixin {
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Padding(
padding: const EdgeInsets.only(
top: 16, left: 16, right: 16, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'150',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 32,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'Gigaliter',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, top: 2, bottom: 14),
child: Text(
'donated worldwide',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.darkText,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, right: 4, top: 8, bottom: 16),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: const BorderRadius.all(
Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Deadline 30th Oct 2021',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 24,
height: 24,
child: Image.asset(
'assets/fitness_app/bell.png'),
),
Flexible(
child: Text(
'Daily 400k homeless die from thirst. Make a change!',
textAlign: TextAlign.start,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: HexColor('#F65283'),
),
),
),
],
),
),
],
),
)
],
),
),
SizedBox(
width: 34,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
const SizedBox(
height: 28,
),
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.remove,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
],
),
),
Padding(
padding:
const EdgeInsets.only(left: 16, right: 8, top: 16),
child: Container(
width: 60,
height: 160,
decoration: BoxDecoration(
color: HexColor('#E8EDFE'),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(80.0),
bottomLeft: Radius.circular(80.0),
bottomRight: Radius.circular(80.0),
topRight: Radius.circular(80.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: const Offset(2, 2),
blurRadius: 4),
],
),
child: WaveView(
percentageValue: 60.0,
),
),
)
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_covid/meals_list_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/models/meals_list_data.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../../main.dart';
class MealsListView extends StatefulWidget {
const MealsListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_MealsListViewState createState() => _MealsListViewState();
}
class _MealsListViewState extends State<MealsListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<MealsListData> mealsListData = MealsListData.tabIconsList;
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Container(
height: 216,
width: double.infinity,
child: ListView.builder(
padding: const EdgeInsets.only(
top: 0, bottom: 0, right: 16, left: 16),
itemCount: mealsListData.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
final int count =
mealsListData.length > 10 ? 10 : mealsListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn)));
animationController?.forward();
return MealsView(
mealsListData: mealsListData[index],
animation: animation,
animationController: animationController!,
);
},
),
),
),
);
},
);
}
}
class MealsView extends StatelessWidget {
const MealsView(
{Key? key, this.mealsListData, this.animationController, this.animation})
: super(key: key);
final MealsListData? mealsListData;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
100 * (1.0 - animation!.value), 0.0, 0.0),
child: SizedBox(
width: 130,
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 32, left: 8, right: 8, bottom: 16),
child: Container(
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: HexColor(mealsListData!.endColor)
.withOpacity(0.6),
offset: const Offset(1.1, 4.0),
blurRadius: 8.0),
],
gradient: LinearGradient(
colors: <HexColor>[
HexColor(mealsListData!.startColor),
HexColor(mealsListData!.endColor),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: const BorderRadius.only(
bottomRight: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
topLeft: Radius.circular(8.0),
topRight: Radius.circular(54.0),
),
),
child: Padding(
padding: const EdgeInsets.only(
top: 54, left: 16, right: 16, bottom: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.titleTxt,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mealsListData!.meals!.join('\n'),
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
],
),
),
),
mealsListData?.kacl != 0
? Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
mealsListData!.kacl.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 24,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'kcal',
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.2,
color: FitnessAppTheme.white,
),
),
),
],
)
: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color:
HexColor(mealsListData!.endColor),
size: 24,
),
),
),
],
),
),
),
),
Positioned(
top: 0,
left: 0,
child: Container(
width: 84,
height: 84,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite.withOpacity(0.2),
shape: BoxShape.circle,
),
),
),
Positioned(
top: 0,
left: 8,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset(mealsListData!.imagePath),
),
)
],
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_covid/my_covid_screen.dart
|
import 'package:planet_health/fitness_app/ui_view/area_list_view.dart';
import 'package:planet_health/fitness_app/ui_view/covid_info_view.dart';
import 'package:planet_health/fitness_app/ui_view/title_view.dart';
import 'package:planet_health/fitness_app/ui_view/covid_alert_view.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class MyCovidScreen extends StatefulWidget {
const MyCovidScreen({Key? key, this.animationController}) : super(key: key);
final AnimationController? animationController;
@override
_MyCovidScreenState createState() => _MyCovidScreenState();
}
class _MyCovidScreenState extends State<MyCovidScreen>
with TickerProviderStateMixin {
Animation<double>? topBarAnimation;
List<Widget> listViews = <Widget>[];
final ScrollController scrollController = ScrollController();
double topBarOpacity = 0.0;
@override
void initState() {
topBarAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn)));
addAllListData();
scrollController.addListener(() {
if (scrollController.offset >= 24) {
if (topBarOpacity != 1.0) {
setState(() {
topBarOpacity = 1.0;
});
}
} else if (scrollController.offset <= 24 &&
scrollController.offset >= 0) {
if (topBarOpacity != scrollController.offset / 24) {
setState(() {
topBarOpacity = scrollController.offset / 24;
});
}
} else if (scrollController.offset <= 0) {
if (topBarOpacity != 0.0) {
setState(() {
topBarOpacity = 0.0;
});
}
}
});
super.initState();
}
void addAllListData() {
const int count = 5;
listViews.add(
TitleView(
titleTxt: 'Pandemics',
subTxt: 'Details',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 0, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
WorkoutView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 2, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
RunningView(
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 3, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
TitleView(
titleTxt: 'Stay informed',
subTxt: 'more',
animation: Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: widget.animationController!,
curve:
Interval((1 / count) * 4, 1.0, curve: Curves.fastOutSlowIn))),
animationController: widget.animationController!,
),
);
listViews.add(
AreaListView(
mainScreenAnimation: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController!,
curve: Interval((1 / count) * 5, 1.0,
curve: Curves.fastOutSlowIn))),
mainScreenAnimationController: widget.animationController!,
),
);
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return Container(
color: FitnessAppTheme.background,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: <Widget>[
getMainListViewUI(),
getAppBarUI(),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
}
Widget getMainListViewUI() {
return FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ListView.builder(
controller: scrollController,
padding: EdgeInsets.only(
top: AppBar().preferredSize.height +
MediaQuery.of(context).padding.top +
24,
bottom: 62 + MediaQuery.of(context).padding.bottom,
),
itemCount: listViews.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
widget.animationController?.forward();
return listViews[index];
},
);
}
},
);
}
Widget getAppBarUI() {
return Column(
children: <Widget>[
AnimatedBuilder(
animation: widget.animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: topBarAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - topBarAnimation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(topBarOpacity),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(32.0),
),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey
.withOpacity(0.4 * topBarOpacity),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Padding(
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16 - 8.0 * topBarOpacity,
bottom: 12 - 8.0 * topBarOpacity),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
' COVID-19',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w700,
fontSize: 22 + 6 - 6 * topBarOpacity,
letterSpacing: 1.2,
color: FitnessAppTheme.darkerText,
),
),
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_left,
color: FitnessAppTheme.grey,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8),
child: Icon(
Icons.calendar_today,
color: FitnessAppTheme.grey,
size: 18,
),
),
Text(
//'26 Sep',
//'${DateTime.now().day}.${DateTime.now().month}',
'${DateTime.now().day}.${DateTime.now().month}.${DateTime.now().year}',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.darkerText,
),
),
],
),
),
SizedBox(
height: 38,
width: 38,
child: InkWell(
highlightColor: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(32.0)),
onTap: () {},
child: Center(
child: Icon(
Icons.keyboard_arrow_right,
color: FitnessAppTheme.grey,
),
),
),
),
],
),
)
],
),
),
),
);
},
)
],
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/my_covid/water_view.dart
|
import 'package:planet_health/fitness_app/ui_view/wave_view.dart';
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
class WaterView extends StatefulWidget {
const WaterView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_WaterViewState createState() => _WaterViewState();
}
class _WaterViewState extends State<WaterView> with TickerProviderStateMixin {
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 50));
return true;
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Padding(
padding: const EdgeInsets.only(
top: 16, left: 16, right: 16, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'2100',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 32,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'ml',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, top: 2, bottom: 14),
child: Text(
'of daily goal 3.5L',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.darkText,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 4, right: 4, top: 8, bottom: 16),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: const BorderRadius.all(
Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Last drink 8:26 AM',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 24,
height: 24,
child: Image.asset(
'assets/fitness_app/bell.png'),
),
Flexible(
child: Text(
'Your bottle is empty, refill it!.',
textAlign: TextAlign.start,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: HexColor('#F65283'),
),
),
),
],
),
),
],
),
)
],
),
),
SizedBox(
width: 34,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
const SizedBox(
height: 28,
),
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(4.0, 4.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Icon(
Icons.remove,
color: FitnessAppTheme.nearlyDarkBlue,
size: 24,
),
),
),
],
),
),
Padding(
padding:
const EdgeInsets.only(left: 16, right: 8, top: 16),
child: Container(
width: 60,
height: 160,
decoration: BoxDecoration(
color: HexColor('#E8EDFE'),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(80.0),
bottomLeft: Radius.circular(80.0),
bottomRight: Radius.circular(80.0),
topRight: Radius.circular(80.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: const Offset(2, 2),
blurRadius: 4),
],
),
child: WaveView(
percentageValue: 60.0,
),
),
)
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/bottom_navigation_view/bottom_bar_view.dart
|
import 'dart:math' as math;
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/fitness_app/models/tabIcon_data.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../../main.dart';
import '../models/tabIcon_data.dart';
class BottomBarView extends StatefulWidget {
const BottomBarView(
{Key? key, this.tabIconsList, this.changeIndex, this.addClick})
: super(key: key);
final Function(int index)? changeIndex;
final Function()? addClick;
final List<TabIconData>? tabIconsList;
@override
_BottomBarViewState createState() => _BottomBarViewState();
}
class _BottomBarViewState extends State<BottomBarView>
with TickerProviderStateMixin {
AnimationController? animationController;
@override
void initState() {
animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1000),
);
animationController?.forward();
super.initState();
}
@override
Widget build(BuildContext context) {
return Stack(
alignment: AlignmentDirectional.bottomCenter,
children: <Widget>[
AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return Transform(
transform: Matrix4.translationValues(0.0, 0.0, 0.0),
child: PhysicalShape(
color: FitnessAppTheme.white,
elevation: 16.0,
clipper: TabClipper(
radius: Tween<double>(begin: 0.0, end: 1.0)
.animate(CurvedAnimation(
parent: animationController!,
curve: Curves.fastOutSlowIn))
.value *
38.0),
child: Column(
children: <Widget>[
SizedBox(
height: 62,
child: Padding(
padding:
const EdgeInsets.only(left: 8, right: 8, top: 4),
child: Row(
children: <Widget>[
Expanded(
child: TabIcons(
tabIconData: widget.tabIconsList?[0],
removeAllSelect: () {
setRemoveAllSelection(
widget.tabIconsList?[0]);
widget.changeIndex!(0);
}),
),
Expanded(
child: TabIcons(
tabIconData: widget.tabIconsList?[1],
removeAllSelect: () {
setRemoveAllSelection(
widget.tabIconsList?[1]);
widget.changeIndex!(1);
}),
),
SizedBox(
width: Tween<double>(begin: 0.0, end: 1.0)
.animate(CurvedAnimation(
parent: animationController!,
curve: Curves.fastOutSlowIn))
.value *
64.0,
),
Expanded(
child: TabIcons(
tabIconData: widget.tabIconsList?[2],
removeAllSelect: () {
setRemoveAllSelection(
widget.tabIconsList?[2]);
widget.changeIndex!(2);
}),
),
Expanded(
child: TabIcons(
tabIconData: widget.tabIconsList?[3],
removeAllSelect: () {
setRemoveAllSelection(
widget.tabIconsList?[3]);
widget.changeIndex!(3);
}),
),
],
),
),
),
SizedBox(
height: MediaQuery.of(context).padding.bottom,
)
],
),
),
);
},
),
Padding(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: SizedBox(
width: 38 * 2.0,
height: 38 + 62.0,
child: Container(
alignment: Alignment.topCenter,
color: Colors.transparent,
child: SizedBox(
width: 38 * 2.0,
height: 38 * 2.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ScaleTransition(
alignment: Alignment.center,
scale: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Curves.fastOutSlowIn)),
child: Container(
// alignment: Alignment.center,s
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue,
gradient: LinearGradient(
colors: [
FitnessAppTheme.nearlyDarkBlue,
HexColor('#6A88E5'),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight),
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.4),
offset: const Offset(8.0, 16.0),
blurRadius: 16.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
splashColor: Colors.white.withOpacity(0.1),
highlightColor: Colors.transparent,
focusColor: Colors.transparent,
onTap: widget.addClick,
child: Icon(
Icons.phone,
color: FitnessAppTheme.white,
size: 32,
),
),
),
),
),
),
),
),
),
),
],
);
}
void setRemoveAllSelection(TabIconData? tabIconData) {
if (!mounted) return;
setState(() {
widget.tabIconsList?.forEach((TabIconData tab) {
tab.isSelected = false;
if (tabIconData!.index == tab.index) {
tab.isSelected = true;
}
});
});
}
}
class TabIcons extends StatefulWidget {
const TabIcons({Key? key, this.tabIconData, this.removeAllSelect})
: super(key: key);
final TabIconData? tabIconData;
final Function()? removeAllSelect;
@override
_TabIconsState createState() => _TabIconsState();
}
class _TabIconsState extends State<TabIcons> with TickerProviderStateMixin {
@override
void initState() {
widget.tabIconData?.animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 400),
)..addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.completed) {
if (!mounted) return;
widget.removeAllSelect!();
widget.tabIconData?.animationController?.reverse();
}
});
super.initState();
}
void setAnimation() {
widget.tabIconData?.animationController?.forward();
}
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 1,
child: Center(
child: InkWell(
splashColor: Colors.transparent,
focusColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
onTap: () {
if (!widget.tabIconData!.isSelected) {
setAnimation();
}
},
child: IgnorePointer(
child: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
ScaleTransition(
alignment: Alignment.center,
scale: Tween<double>(begin: 0.88, end: 1.0).animate(
CurvedAnimation(
parent: widget.tabIconData!.animationController!,
curve:
Interval(0.1, 1.0, curve: Curves.fastOutSlowIn))),
child: Image.asset(widget.tabIconData!.isSelected
? widget.tabIconData!.selectedImagePath
: widget.tabIconData!.imagePath),
),
Positioned(
top: 4,
left: 6,
right: 0,
child: ScaleTransition(
alignment: Alignment.center,
scale: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.tabIconData!.animationController!,
curve: Interval(0.2, 1.0,
curve: Curves.fastOutSlowIn))),
child: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue,
shape: BoxShape.circle,
),
),
),
),
Positioned(
top: 0,
left: 6,
bottom: 8,
child: ScaleTransition(
alignment: Alignment.center,
scale: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.tabIconData!.animationController!,
curve: Interval(0.5, 0.8,
curve: Curves.fastOutSlowIn))),
child: Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue,
shape: BoxShape.circle,
),
),
),
),
Positioned(
top: 6,
right: 8,
bottom: 0,
child: ScaleTransition(
alignment: Alignment.center,
scale: Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.tabIconData!.animationController!,
curve: Interval(0.5, 0.6,
curve: Curves.fastOutSlowIn))),
child: Container(
width: 6,
height: 6,
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue,
shape: BoxShape.circle,
),
),
),
),
],
),
),
),
),
);
}
}
class TabClipper extends CustomClipper<Path> {
TabClipper({this.radius = 38.0});
final double radius;
@override
Path getClip(Size size) {
final Path path = Path();
final double v = radius * 2;
path.lineTo(0, 0);
path.arcTo(Rect.fromLTWH(0, 0, radius, radius), degreeToRadians(180),
degreeToRadians(90), false);
path.arcTo(
Rect.fromLTWH(
((size.width / 2) - v / 2) - radius + v * 0.04, 0, radius, radius),
degreeToRadians(270),
degreeToRadians(70),
false);
path.arcTo(Rect.fromLTWH((size.width / 2) - v / 2, -v / 2, v, v),
degreeToRadians(160), degreeToRadians(-140), false);
path.arcTo(
Rect.fromLTWH((size.width - ((size.width / 2) - v / 2)) - v * 0.04, 0,
radius, radius),
degreeToRadians(200),
degreeToRadians(70),
false);
path.arcTo(Rect.fromLTWH(size.width - radius, 0, radius, radius),
degreeToRadians(270), degreeToRadians(90), false);
path.lineTo(size.width, 0);
path.lineTo(size.width, size.height);
path.lineTo(0, size.height);
path.close();
return path;
}
@override
bool shouldReclip(TabClipper oldClipper) => true;
double degreeToRadians(double degree) {
final double redian = (math.pi / 180) * degree;
return redian;
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/running_view.dart
|
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class RunningView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const RunningView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 0),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Stack(
alignment: Alignment.topLeft,
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
child: SizedBox(
height: 74,
child: AspectRatio(
aspectRatio: 1.714,
child: Image.asset(
"assets/fitness_app/back.png"),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 100,
right: 16,
top: 16,
),
child: Text(
"You're doing great!",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color:
FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 100,
bottom: 12,
top: 4,
right: 16,
),
child: Text(
"Keep it up\nand stick to your plan!",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
),
Positioned(
top: -16,
left: 0,
child: SizedBox(
width: 110,
height: 110,
child: Image.asset("assets/fitness_app/runner.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/glass_view_diary.dart
|
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class GlassView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const GlassView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 24),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16),
child: Container(
decoration: BoxDecoration(
color: HexColor("#D7E0F9"),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
// boxShadow: <BoxShadow>[
// BoxShadow(
// color: FitnessAppTheme.grey.withOpacity(0.2),
// offset: Offset(1.1, 1.1),
// blurRadius: 10.0),
// ],
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 68, bottom: 12, right: 16, top: 12),
child: Text(
'Share your health status with doctor',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.6),
),
),
),
],
),
),
),
Positioned(
top: -12,
left: 0,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset("assets/fitness_app/share.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/covid_alert_view.dart
|
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class WorkoutView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const WorkoutView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
FitnessAppTheme.nearlyDarkBlue,
HexColor("#6F56E8")
], begin: Alignment.topLeft, end: Alignment.bottomRight),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.6),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'News on COVID-19',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: const Text(
'Latest information\non COVID worldwide',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 20,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
),
SizedBox(
height: 32,
),
Padding(
padding: const EdgeInsets.only(right: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.info_rounded,
color: FitnessAppTheme.white,
size: 16,
),
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: const Text(
'More details',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
),
Expanded(
child: SizedBox(),
),
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Icon(
Icons.arrow_right,
color: HexColor("#6F56E8"),
size: 44,
),
),
)
],
),
)
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/running_view_diary.dart
|
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class RunningViewDiary1 extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const RunningViewDiary1({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 0),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Stack(
alignment: Alignment.topLeft,
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
child: SizedBox(
height: 74,
child: AspectRatio(
aspectRatio: 1.714,
child: Image.asset(
"assets/fitness_app/invisible.png"),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 60,
right: 16,
top: 16,
),
child: Text(
"Mental health",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color:
FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 60,
bottom: 12,
top: 4,
right: 16,
),
child: Text(
"Enhance your cognitive wellbeing by playing games. Exercise slow breathing. Learn how to do meditation.",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
),
Positioned(
top: -16,
left: 0,
child: SizedBox(
width: 110,
height: 110,
child: Image.asset("assets/fitness_app/mental.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
class RunningViewDiary2 extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const RunningViewDiary2({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 0),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Container(
decoration: BoxDecoration(
//color: FitnessAppTheme.white,
color: FitnessAppTheme.nearlyPink,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Stack(
alignment: Alignment.topLeft,
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
child: SizedBox(
height: 74,
child: AspectRatio(
aspectRatio: 1.714,
child: Image.asset(
"assets/fitness_app/invisible.png"),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 60,
right: 16,
top: 16,
),
child: Text(
"Woman health",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color:
FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 60,
bottom: 12,
top: 4,
right: 16,
),
child: Text(
"Track your menstrual cycle and get fertility predictions.\nGet related recommendations on food and training.",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
),
Positioned(
top: -16,
left: 0,
child: SizedBox(
width: 110,
height: 110,
child: Image.asset("assets/fitness_app/redcycle.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/area_list_view.dart
|
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class AreaListView extends StatefulWidget {
const AreaListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_AreaListViewState createState() => _AreaListViewState();
}
class _AreaListViewState extends State<AreaListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<String> areaListData = <String>[
'assets/fitness_app/covidregulations.png',
'assets/fitness_app/qrcode.png',
'assets/fitness_app/testcenters.png',
'assets/fitness_app/faq.png',
];
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: AspectRatio(
aspectRatio: 1.0,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8),
child: GridView(
padding: const EdgeInsets.only(
left: 16, right: 16, top: 16, bottom: 16),
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
children: List<Widget>.generate(
areaListData.length,
(int index) {
final int count = areaListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn),
),
);
animationController?.forward();
return AreaView(
imagepath: areaListData[index],
animation: animation,
animationController: animationController!,
);
},
),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 24.0,
crossAxisSpacing: 24.0,
childAspectRatio: 1.0,
),
),
),
),
),
);
},
);
}
}
class AreaView extends StatelessWidget {
const AreaView({
Key? key,
this.imagepath,
this.animationController,
this.animation,
}) : super(key: key);
final String? imagepath;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 50 * (1.0 - animation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
focusColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
splashColor: FitnessAppTheme.nearlyDarkBlue.withOpacity(0.2),
onTap: () {},
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Image.asset(imagepath!),
),
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/heart_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'package:planet_health/globals.dart' as globals;
import 'package:flutter_riverpod/flutter_riverpod.dart';
//class HeartView extends StatelessWidget {
class HeartView extends ConsumerWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const HeartView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final int value = ref.watch(globals.heartRateProvider).state;
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 8, right: 8, top: 4),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#87A0E5')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Resting',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/eaten.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
//'${(58 * animation!.value).toInt()}',
'${(globals.heartRateLow * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'bpm',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
),
SizedBox(
height: 8,
),
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'High',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/burned.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
//'${(177 * animation!.value).toInt()}',
'${(globals.heartRateHigh * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 8, bottom: 3),
child: Text(
'bpm',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 16),
child: Center(
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.all(
Radius.circular(100.0),
),
border: new Border.all(
width: 4,
color: FitnessAppTheme
.nearlyDarkBlue
.withOpacity(0.2)),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
//'${(77 * animation!.value).toInt()}',
'${(value * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 24,
letterSpacing: 0.0,
color: FitnessAppTheme
.nearlyDarkBlue,
),
),
Text(
'bpm',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: CustomPaint(
painter: CurvePainter(
colors: [
FitnessAppTheme.nearlyDarkBlue,
HexColor("#8A98E8"),
HexColor("#8A98E8")
],
angle: 140 +
(360 - 140) *
(1.0 - animation!.value)),
child: SizedBox(
width: 108,
height: 108,
),
),
)
],
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Body battery',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color:
HexColor('#87A0E5').withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width:
((70 / 1.2) * animation!.value),
height: 4,
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
HexColor('#87A0E5'),
HexColor('#87A0E5')
.withOpacity(0.5),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'80 %',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Respiration',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F56E98')
.withOpacity(0.1),
HexColor('#F56E98'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'14 brpm',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Stress',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(
right: 0, top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F1B440')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2.5) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F1B440')
.withOpacity(0.1),
HexColor('#F1B440'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'30',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
}
class CurvePainter extends CustomPainter {
final double? angle;
final List<Color>? colors;
CurvePainter({this.colors, this.angle = 140});
@override
void paint(Canvas canvas, Size size) {
List<Color> colorsList = [];
if (colors != null) {
colorsList = colors ?? [];
} else {
colorsList.addAll([Colors.white, Colors.white]);
}
final shdowPaint = new Paint()
..color = Colors.black.withOpacity(0.4)
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke
..strokeWidth = 14;
final shdowPaintCenter = new Offset(size.width / 2, size.height / 2);
final shdowPaintRadius =
math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.3);
shdowPaint.strokeWidth = 16;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.2);
shdowPaint.strokeWidth = 20;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.1);
shdowPaint.strokeWidth = 22;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
final rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.width);
final gradient = new SweepGradient(
startAngle: degreeToRadians(268),
endAngle: degreeToRadians(270.0 + 360),
tileMode: TileMode.repeated,
colors: colorsList,
);
final paint = new Paint()
..shader = gradient.createShader(rect)
..strokeCap = StrokeCap.round // StrokeCap.round is not recommended.
..style = PaintingStyle.stroke
..strokeWidth = 14;
final center = new Offset(size.width / 2, size.height / 2);
final radius = math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: center, radius: radius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
paint);
final gradient1 = new SweepGradient(
tileMode: TileMode.repeated,
colors: [Colors.white, Colors.white],
);
var cPaint = new Paint();
cPaint..shader = gradient1.createShader(rect);
cPaint..color = Colors.white;
cPaint..strokeWidth = 14 / 2;
canvas.save();
final centerToCircle = size.width / 2;
canvas.save();
canvas.translate(centerToCircle, centerToCircle);
canvas.rotate(degreeToRadians(angle! + 2));
canvas.save();
canvas.translate(0.0, -centerToCircle + 14 / 2);
canvas.drawCircle(new Offset(0, 0), 14 / 5, cPaint);
canvas.restore();
canvas.restore();
canvas.restore();
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
double degreeToRadians(double degree) {
var redian = (math.pi / 180) * degree;
return redian;
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/training_list_view.dart
|
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class TrainingListView extends StatefulWidget {
const TrainingListView(
{Key? key, this.mainScreenAnimationController, this.mainScreenAnimation})
: super(key: key);
final AnimationController? mainScreenAnimationController;
final Animation<double>? mainScreenAnimation;
@override
_TrainingListViewState createState() => _TrainingListViewState();
}
class _TrainingListViewState extends State<TrainingListView>
with TickerProviderStateMixin {
AnimationController? animationController;
List<String> areaListData = <String>[
'assets/fitness_app/boxing.png',
'assets/fitness_app/cycling.png',
'assets/fitness_app/area3.png',
'assets/fitness_app/othersport.png',
];
@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
super.initState();
}
@override
void dispose() {
animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: widget.mainScreenAnimationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: widget.mainScreenAnimation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 30 * (1.0 - widget.mainScreenAnimation!.value), 0.0),
child: AspectRatio(
aspectRatio: 1.0,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8),
child: GridView(
padding: const EdgeInsets.only(
left: 16, right: 16, top: 16, bottom: 16),
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
children: List<Widget>.generate(
areaListData.length,
(int index) {
final int count = areaListData.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController!,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn),
),
);
animationController?.forward();
return AreaView(
imagepath: areaListData[index],
animation: animation,
animationController: animationController!,
);
},
),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 24.0,
crossAxisSpacing: 24.0,
childAspectRatio: 1.0,
),
),
),
),
),
);
},
);
}
}
class AreaView extends StatelessWidget {
const AreaView({
Key? key,
this.imagepath,
this.animationController,
this.animation,
}) : super(key: key);
final String? imagepath;
final AnimationController? animationController;
final Animation<double>? animation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: Transform(
transform: Matrix4.translationValues(
0.0, 50 * (1.0 - animation!.value), 0.0),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: const Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
focusColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
splashColor: FitnessAppTheme.nearlyDarkBlue.withOpacity(0.2),
onTap: () {},
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Image.asset(imagepath!),
),
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/glass_view_training.dart
|
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class GlassView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const GlassView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 24),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16),
child: Container(
decoration: BoxDecoration(
color: HexColor("#D7E0F9"),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
// boxShadow: <BoxShadow>[
// BoxShadow(
// color: FitnessAppTheme.grey.withOpacity(0.2),
// offset: Offset(1.1, 1.1),
// blurRadius: 10.0),
// ],
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 68, bottom: 12, right: 16, top: 12),
child: Text(
'Share your exercise achievements!',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyDarkBlue
.withOpacity(0.6),
),
),
),
],
),
),
),
Positioned(
top: -12,
left: 0,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset("assets/fitness_app/share.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/training_measurement_card.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import 'package:planet_health/globals.dart' as globals;
import 'dart:math' as math;
class TrainingMeasurementView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const TrainingMeasurementView(
{Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 8, right: 8, top: 4),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#87A0E5')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Energy expended',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/eaten.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
//'${(1100 * animation!.value).toInt()}',
'${(globals.dailyCals * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'kcal',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
),
SizedBox(
height: 8,
),
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Distance',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/burned.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
//'${(6 * animation!.value).toInt()}',
'${(globals.dailyKm * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 8, bottom: 3),
child: Text(
'km',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 16),
child: Center(
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.all(
Radius.circular(100.0),
),
border: new Border.all(
width: 4,
color: FitnessAppTheme
.nearlyDarkBlue
.withOpacity(0.2)),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
//'${(7545 * animation!.value).toInt()}',
'${(globals.dailySteps * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 24,
letterSpacing: 0.0,
color: FitnessAppTheme
.nearlyDarkBlue,
),
),
Text(
'steps',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: CustomPaint(
painter: CurvePainter(
colors: [
FitnessAppTheme.nearlyDarkBlue,
HexColor("#8A98E8"),
HexColor("#8A98E8")
],
angle: 140 +
(360 - 140) *
(1.0 - animation!.value)),
child: SizedBox(
width: 108,
height: 108,
),
),
)
],
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Activity',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color:
HexColor('#87A0E5').withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width:
((70 / 1.2) * animation!.value),
height: 4,
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
HexColor('#87A0E5'),
HexColor('#87A0E5')
.withOpacity(0.5),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'80 min',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Speed',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F56E98')
.withOpacity(0.1),
HexColor('#F56E98'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'2 km/h',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Power',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(
right: 0, top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F1B440')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2.5) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F1B440')
.withOpacity(0.1),
HexColor('#F1B440'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'35%',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
}
class CurvePainter extends CustomPainter {
final double? angle;
final List<Color>? colors;
CurvePainter({this.colors, this.angle = 140});
@override
void paint(Canvas canvas, Size size) {
List<Color> colorsList = [];
if (colors != null) {
colorsList = colors ?? [];
} else {
colorsList.addAll([Colors.white, Colors.white]);
}
final shdowPaint = new Paint()
..color = Colors.black.withOpacity(0.4)
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke
..strokeWidth = 14;
final shdowPaintCenter = new Offset(size.width / 2, size.height / 2);
final shdowPaintRadius =
math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.3);
shdowPaint.strokeWidth = 16;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.2);
shdowPaint.strokeWidth = 20;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.1);
shdowPaint.strokeWidth = 22;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
final rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.width);
final gradient = new SweepGradient(
startAngle: degreeToRadians(268),
endAngle: degreeToRadians(270.0 + 360),
tileMode: TileMode.repeated,
colors: colorsList,
);
final paint = new Paint()
..shader = gradient.createShader(rect)
..strokeCap = StrokeCap.round // StrokeCap.round is not recommended.
..style = PaintingStyle.stroke
..strokeWidth = 14;
final center = new Offset(size.width / 2, size.height / 2);
final radius = math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: center, radius: radius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
paint);
final gradient1 = new SweepGradient(
tileMode: TileMode.repeated,
colors: [Colors.white, Colors.white],
);
var cPaint = new Paint();
cPaint..shader = gradient1.createShader(rect);
cPaint..color = Colors.white;
cPaint..strokeWidth = 14 / 2;
canvas.save();
final centerToCircle = size.width / 2;
canvas.save();
canvas.translate(centerToCircle, centerToCircle);
canvas.rotate(degreeToRadians(angle! + 2));
canvas.save();
canvas.translate(0.0, -centerToCircle + 14 / 2);
canvas.drawCircle(new Offset(0, 0), 14 / 5, cPaint);
canvas.restore();
canvas.restore();
canvas.restore();
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
double degreeToRadians(double degree) {
var redian = (math.pi / 180) * degree;
return redian;
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/workout_view.dart
|
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class WorkoutView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const WorkoutView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
FitnessAppTheme.nearlyDarkBlue,
HexColor("#6F56E8")
], begin: Alignment.topLeft, end: Alignment.bottomRight),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.6),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Next workout',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: const Text(
'Boost your workouts\nwith the energy of world-class trainers and experts. Go to demo videos and start exercising the right way. ',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 20,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
),
SizedBox(
height: 32,
),
Padding(
padding: const EdgeInsets.only(right: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.timer,
color: FitnessAppTheme.white,
size: 16,
),
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: const Text(
'68 min',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
),
Expanded(
child: SizedBox(),
),
Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyWhite,
shape: BoxShape.circle,
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.nearlyBlack
.withOpacity(0.4),
offset: Offset(8.0, 8.0),
blurRadius: 8.0),
],
),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Icon(
Icons.arrow_right,
color: HexColor("#6F56E8"),
size: 44,
),
),
)
],
),
)
],
),
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/stress_measurement_diary.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:flutter/material.dart';
class StressMeasurementViewDiary extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const StressMeasurementViewDiary(
{Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 8, top: 16),
child: Text(
'Sleep duration',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.darkText),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'6.5 hrs',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 32,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Today 8:26 AM',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
top: 4, bottom: 14),
child: Text(
'Tips for healthy sleep',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
)
],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'DEEP',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'3 hours',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'LIGHT',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'2.5 hours',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
'REM',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'1 hour',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/body_measurement.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:flutter/material.dart';
class BodyMeasurementView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const BodyMeasurementView(
{Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 8, top: 16),
child: Text(
'How to reduce packaging?',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.1,
color: FitnessAppTheme.darkText),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'-10 Mln',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 28,
color: FitnessAppTheme.nearlyGreen,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'CO2e',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyGreen,
),
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Deadline: today',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
top: 4, bottom: 14),
child: Text(
'Sponsored by Amazon',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyYellow,
),
),
),
],
)
],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'23 Million',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Participants',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'77%',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Average',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
'Leading land',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Switzerland',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/body_measurement_diary.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:flutter/material.dart';
import 'package:planet_health/globals.dart' as globals;
class BodyMeasurementViewDiary extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const BodyMeasurementViewDiary(
{Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 8, top: 16),
child: Text(
'Weight',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.darkText),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
//'70',
globals.weight.toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 32,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 8, bottom: 8),
child: Text(
'kg',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: -0.2,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.access_time,
color: FitnessAppTheme.grey
.withOpacity(0.5),
size: 16,
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
'Today 8:26 AM',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
top: 4, bottom: 14),
child: Text(
'InBody SmartScale',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
)
],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'170 cm',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Height',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'24.2 BMI',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Normal',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
'20%',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'Body fat',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/glass_view.dart
|
//import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class GlassView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const GlassView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 24),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16),
child: Container(
decoration: BoxDecoration(
color: Colors.green.shade100, //HexColor("#D7E0F9"),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
// boxShadow: <BoxShadow>[
// BoxShadow(
// color: FitnessAppTheme.grey.withOpacity(0.2),
// offset: Offset(1.1, 1.1),
// blurRadius: 10.0),
// ],
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 68, bottom: 12, right: 16, top: 12),
child: Text(
'Share your Green achievements :)',
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyGreen1
.withOpacity(0.6),
),
),
),
],
),
),
),
Positioned(
top: -12,
left: 0,
child: SizedBox(
width: 80,
height: 80,
child: Image.asset("assets/fitness_app/share1.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/covid_info_view.dart
|
import 'package:flutter/material.dart';
import '../fitness_app_theme.dart';
class RunningView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const RunningView({Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 0, bottom: 0),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.4),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Stack(
alignment: Alignment.topLeft,
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
child: SizedBox(
height: 74,
child: AspectRatio(
aspectRatio: 1.714,
child: Image.asset(
"assets/fitness_app/map.png"),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 100,
right: 16,
top: 16,
),
child: Text(
"Non-risky areas for training nearby",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color:
FitnessAppTheme.nearlyDarkBlue,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 100,
bottom: 12,
top: 4,
right: 16,
),
child: Text(
"Keep the distance\navoid crowdy places!",
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 10,
letterSpacing: 0.0,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
),
Positioned(
top: -16,
left: 0,
child: SizedBox(
width: 110,
height: 110,
child: Image.asset("assets/fitness_app/security.png"),
),
)
],
),
),
],
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/title_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:flutter/material.dart';
class TitleView extends StatelessWidget {
final String titleTxt;
final String subTxt;
final AnimationController? animationController;
final Animation<double>? animation;
const TitleView(
{Key? key,
this.titleTxt: "",
this.subTxt: "",
this.animationController,
this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Container(
child: Padding(
padding: const EdgeInsets.only(left: 24, right: 24),
child: Row(
children: <Widget>[
Expanded(
child: Text(
titleTxt,
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 18,
letterSpacing: 0.5,
color: FitnessAppTheme.lightText,
),
),
),
InkWell(
highlightColor: Colors.transparent,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: Row(
children: <Widget>[
Text(
subTxt,
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 16,
letterSpacing: 0.5,
color: FitnessAppTheme.nearlyDarkBlue,
),
),
SizedBox(
height: 38,
width: 26,
child: Icon(
Icons.arrow_forward,
color: FitnessAppTheme.darkText,
size: 18,
),
),
],
),
),
)
],
),
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/mediterranean_diet_view.dart
|
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:planet_health/main.dart';
import 'package:flutter/material.dart';
import 'package:planet_health/globals.dart' as globals;
import 'dart:math' as math;
class MediterraneanDietView extends StatelessWidget {
final AnimationController? animationController;
final Animation<double>? animation;
const MediterraneanDietView(
{Key? key, this.animationController, this.animation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController!,
builder: (BuildContext context, Widget? child) {
return FadeTransition(
opacity: animation!,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation!.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FitnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 8, right: 8, top: 4),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#87A0E5')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: GestureDetector(
onTap: () {
print('CO2e');
var dialogText = '';
if (globals.totalCo2e <
2000) {
dialogText +=
'You are living sustainably 👋';
} else {
dialogText +=
'Consider CO2 reduction!! 🚨\n see recommendations\n on this page';
}
showDialog(
context: context,
builder: (BuildContext
context) {
return new AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius
.circular(
50))),
backgroundColor:
Colors.black
.withOpacity(
0.3),
title: new Text(''),
content:
setupAlertDialogContainer(
dialogText),
);
});
},
child: Text(
'CO₂ emissions',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme
.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/cloud.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'${(globals.totalCo2e * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'kgCO2e',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
),
SizedBox(
height: 8,
),
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Water consumption',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/fitness_app/drop.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'${(14 * animation!.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FitnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 8, bottom: 3),
child: Text(
'Liter',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FitnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 16),
child: Center(
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: FitnessAppTheme.white,
borderRadius: BorderRadius.all(
Radius.circular(100.0),
),
border: new Border.all(
width: 4,
color: FitnessAppTheme.nearlyRed
.withOpacity(0.2)),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
'${(10 * animation!.value).toInt()}' +
'%',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 24,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyRed,
),
),
Text(
'higher',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FitnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 12,
letterSpacing: 0.0,
color: FitnessAppTheme.nearlyRed
.withOpacity(0.5),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: CustomPaint(
painter: CurvePainter(
colors: [
FitnessAppTheme.nearlyRed,
HexColor("#8A98E8"),
HexColor("#8A98E8")
],
angle: 140 +
(360 - 140) *
(1.0 - animation!.value)),
child: SizedBox(
width: 108,
height: 108,
),
),
)
],
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Energy',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color:
HexColor('#87A0E5').withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width:
((70 / 1.2) * animation!.value),
height: 4,
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
HexColor('#87A0E5'),
HexColor('#87A0E5')
.withOpacity(0.5),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'0.3 kWh left',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color:
FitnessAppTheme.grey.withOpacity(0.5),
),
),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Waste',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F56E98')
.withOpacity(0.1),
HexColor('#F56E98'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'0.5 kg left',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Particles',
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FitnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(
right: 0, top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color: HexColor('#F1B440')
.withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 2.5) *
animationController!.value),
height: 4,
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [
HexColor('#F1B440')
.withOpacity(0.1),
HexColor('#F1B440'),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'10 ppm left',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FitnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
],
),
)
],
),
)
],
),
),
),
),
);
},
);
}
Widget setupAlertDialogContainer(String dialogText) {
double _fontsz = 20;
return Container(
height: 200.0, // Change as per your requirement
width: 300.0, // Change as per your requirement
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
dialogText,
style: TextStyle(fontSize: _fontsz, color: Colors.white),
),
],
),
SizedBox(height: 10),
],
),
);
}
}
class CurvePainter extends CustomPainter {
final double? angle;
final List<Color>? colors;
CurvePainter({this.colors, this.angle = 140});
@override
void paint(Canvas canvas, Size size) {
List<Color> colorsList = [];
if (colors != null) {
colorsList = colors ?? [];
} else {
colorsList.addAll([Colors.white, Colors.white]);
}
final shdowPaint = new Paint()
..color = Colors.black.withOpacity(0.4)
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke
..strokeWidth = 14;
final shdowPaintCenter = new Offset(size.width / 2, size.height / 2);
final shdowPaintRadius =
math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.3);
shdowPaint.strokeWidth = 16;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.2);
shdowPaint.strokeWidth = 20;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
shdowPaint.color = Colors.grey.withOpacity(0.1);
shdowPaint.strokeWidth = 22;
canvas.drawArc(
new Rect.fromCircle(center: shdowPaintCenter, radius: shdowPaintRadius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
shdowPaint);
final rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.width);
final gradient = new SweepGradient(
startAngle: degreeToRadians(268),
endAngle: degreeToRadians(270.0 + 360),
tileMode: TileMode.repeated,
colors: colorsList,
);
final paint = new Paint()
..shader = gradient.createShader(rect)
..strokeCap = StrokeCap.round // StrokeCap.round is not recommended.
..style = PaintingStyle.stroke
..strokeWidth = 14;
final center = new Offset(size.width / 2, size.height / 2);
final radius = math.min(size.width / 2, size.height / 2) - (14 / 2);
canvas.drawArc(
new Rect.fromCircle(center: center, radius: radius),
degreeToRadians(278),
degreeToRadians(360 - (365 - angle!)),
false,
paint);
final gradient1 = new SweepGradient(
tileMode: TileMode.repeated,
colors: [Colors.white, Colors.white],
);
var cPaint = new Paint();
cPaint..shader = gradient1.createShader(rect);
cPaint..color = Colors.white;
cPaint..strokeWidth = 14 / 2;
canvas.save();
final centerToCircle = size.width / 2;
canvas.save();
canvas.translate(centerToCircle, centerToCircle);
canvas.rotate(degreeToRadians(angle! + 2));
canvas.save();
canvas.translate(0.0, -centerToCircle + 14 / 2);
canvas.drawCircle(new Offset(0, 0), 14 / 5, cPaint);
canvas.restore();
canvas.restore();
canvas.restore();
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
double degreeToRadians(double degree) {
var redian = (math.pi / 180) * degree;
return redian;
}
}
| 0
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app
|
mirrored_repositories/hack_zurich/planet_health/lib/fitness_app/ui_view/wave_view.dart
|
import 'dart:math' as math;
import 'package:planet_health/fitness_app/fitness_app_theme.dart';
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math.dart' as vector;
class WaveView extends StatefulWidget {
final double percentageValue;
const WaveView({Key? key, this.percentageValue = 100.0}) : super(key: key);
@override
_WaveViewState createState() => _WaveViewState();
}
class _WaveViewState extends State<WaveView> with TickerProviderStateMixin {
AnimationController? animationController;
AnimationController? waveAnimationController;
Offset bottleOffset1 = Offset(0, 0);
List<Offset> animList1 = [];
Offset bottleOffset2 = Offset(60, 0);
List<Offset> animList2 = [];
@override
void initState() {
animationController = AnimationController(
duration: Duration(milliseconds: 2000), vsync: this);
waveAnimationController = AnimationController(
duration: Duration(milliseconds: 2000), vsync: this);
animationController!
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
animationController?.reverse();
} else if (status == AnimationStatus.dismissed) {
animationController?.forward();
}
});
waveAnimationController!.addListener(() {
animList1.clear();
for (int i = -2 - bottleOffset1.dx.toInt(); i <= 60 + 2; i++) {
animList1.add(
new Offset(
i.toDouble() + bottleOffset1.dx.toInt(),
math.sin((waveAnimationController!.value * 360 - i) %
360 *
vector.degrees2Radians) *
4 +
(((100 - widget.percentageValue) * 160 / 100)),
),
);
}
animList2.clear();
for (int i = -2 - bottleOffset2.dx.toInt(); i <= 60 + 2; i++) {
animList2.add(
new Offset(
i.toDouble() + bottleOffset2.dx.toInt(),
math.sin((waveAnimationController!.value * 360 - i) %
360 *
vector.degrees2Radians) *
4 +
(((100 - widget.percentageValue) * 160 / 100)),
),
);
}
});
waveAnimationController?.repeat();
animationController?.forward();
super.initState();
}
@override
void dispose() {
animationController?.dispose();
waveAnimationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: new AnimatedBuilder(
animation: new CurvedAnimation(
parent: animationController!,
curve: Curves.easeInOut,
),
builder: (context, child) => new Stack(
children: <Widget>[
new ClipPath(
child: new Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue.withOpacity(0.5),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(80.0),
bottomLeft: Radius.circular(80.0),
bottomRight: Radius.circular(80.0),
topRight: Radius.circular(80.0)),
gradient: LinearGradient(
colors: [
FitnessAppTheme.nearlyDarkBlue.withOpacity(0.2),
FitnessAppTheme.nearlyDarkBlue.withOpacity(0.5)
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
),
clipper: new WaveClipper(animationController!.value, animList1),
),
new ClipPath(
child: new Container(
decoration: BoxDecoration(
color: FitnessAppTheme.nearlyDarkBlue,
gradient: LinearGradient(
colors: [
FitnessAppTheme.nearlyDarkBlue.withOpacity(0.4),
FitnessAppTheme.nearlyDarkBlue
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(80.0),
bottomLeft: Radius.circular(80.0),
bottomRight: Radius.circular(80.0),
topRight: Radius.circular(80.0)),
),
),
clipper: new WaveClipper(animationController!.value, animList2),
),
Padding(
padding: const EdgeInsets.only(top: 48),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.percentageValue.round().toString(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 24,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Text(
'%',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FitnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.0,
color: FitnessAppTheme.white,
),
),
),
],
),
),
),
Positioned(
top: 0,
left: 6,
bottom: 8,
child: new ScaleTransition(
alignment: Alignment.center,
scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animationController!,
curve: Interval(0.0, 1.0, curve: Curves.fastOutSlowIn))),
child: Container(
width: 2,
height: 2,
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(0.4),
shape: BoxShape.circle,
),
),
),
),
Positioned(
left: 24,
right: 0,
bottom: 16,
child: new ScaleTransition(
alignment: Alignment.center,
scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animationController!,
curve: Interval(0.4, 1.0, curve: Curves.fastOutSlowIn))),
child: Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(0.4),
shape: BoxShape.circle,
),
),
),
),
Positioned(
left: 0,
right: 24,
bottom: 32,
child: new ScaleTransition(
alignment: Alignment.center,
scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animationController!,
curve: Interval(0.6, 0.8, curve: Curves.fastOutSlowIn))),
child: Container(
width: 3,
height: 3,
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(0.4),
shape: BoxShape.circle,
),
),
),
),
Positioned(
top: 0,
right: 20,
bottom: 0,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 16 * (1.0 - animationController!.value), 0.0),
child: Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: FitnessAppTheme.white.withOpacity(
animationController!.status == AnimationStatus.reverse
? 0.0
: 0.4),
shape: BoxShape.circle,
),
),
),
),
Column(
children: <Widget>[
AspectRatio(
aspectRatio: 1,
child: Image.asset("assets/fitness_app/bottle.png"),
),
],
)
],
),
),
);
}
}
class WaveClipper extends CustomClipper<Path> {
final double animation;
List<Offset> waveList1 = [];
WaveClipper(this.animation, this.waveList1);
@override
Path getClip(Size size) {
Path path = new Path();
path.addPolygon(waveList1, false);
path.lineTo(size.width, size.height);
path.lineTo(0.0, size.height);
path.close();
return path;
}
@override
bool shouldReclip(WaveClipper oldClipper) =>
animation != oldClipper.animation;
}
| 0
|
mirrored_repositories/hack_zurich/planet_health
|
mirrored_repositories/hack_zurich/planet_health/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:planet_health/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/aqua_workout_lite
|
mirrored_repositories/aqua_workout_lite/lib/core.dart
|
export 'pages/xcore.dart';
export 'routes/app_pages.dart';
export 'shared/xcore.dart';
| 0
|
mirrored_repositories/aqua_workout_lite
|
mirrored_repositories/aqua_workout_lite/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/route_manager.dart';
import 'core.dart';
void main() {
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(statusBarBrightness: Brightness.dark));
/// Make sure you add this line here, so the plugin can access the native side
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: "Aqua Workout App",
themeMode: ThemeMode.dark,
theme: ThemeData.dark().copyWith(
primaryColor: Colors.blue,
hintColor: Colors.white,
textTheme: const TextTheme(subtitle1: TextStyle(color: Colors.white)),
),
debugShowCheckedModeBanner: false,
defaultTransition: Transition.cupertino,
opaqueRoute: Get.isOpaqueRouteDefault,
popGesture: Get.isPopGestureEnable,
transitionDuration: const Duration(milliseconds: 230),
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
);
}
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib
|
mirrored_repositories/aqua_workout_lite/lib/shared/xcore.dart
|
export 'styles/colors.dart';
export 'widgets/option_widget.dart';
| 0
|
mirrored_repositories/aqua_workout_lite/lib/shared
|
mirrored_repositories/aqua_workout_lite/lib/shared/widgets/option_widget.dart
|
import 'package:aqua_workout_lite/core.dart';
import 'package:flutter/material.dart';
class OptionWidget extends StatelessWidget {
final String state, detail;
final bool enable;
final Function() onTap;
const OptionWidget({
Key key,
this.onTap,
@required this.state,
@required this.detail,
@required this.enable,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Stack(
children: [
Container(
height: 180,
width: 150,
decoration: BoxDecoration(
color: kSecondColor,
borderRadius: BorderRadius.circular(15),
boxShadow: const [
BoxShadow(
offset: Offset(3, 3),
blurRadius: 8,
spreadRadius: -8,
)
]),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 30),
Text(
state,
style: const TextStyle(
color: kFirstColor,
fontWeight: FontWeight.bold,
fontSize: 25),
),
const SizedBox(height: 10),
Text(
detail,
style: const TextStyle(
color: Colors.white,
fontSize: 13,
fontWeight: FontWeight.w500),
)
],
),
),
),
Positioned(
top: 15,
right: 20,
child: Container(
height: 35,
width: 35,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFF373850),
),
child: enable
? const Center(
child: Icon(
Icons.done,
color: kFirstColor,
),
)
: const SizedBox(),
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib/shared
|
mirrored_repositories/aqua_workout_lite/lib/shared/styles/colors.dart
|
import 'package:flutter/material.dart';
const kFirstColor = Color(0xFF00aaff);
const kSecondColor = Color(0xFF232441);
const kThirdColor = Color(0xFF131429);
const kAppBarBackgroundColor = Color(0xFF252638);
| 0
|
mirrored_repositories/aqua_workout_lite/lib
|
mirrored_repositories/aqua_workout_lite/lib/routes/app_routes.dart
|
// ignore_for_file: constant_identifier_names
part of 'app_pages.dart';
abstract class Routes {
// Main Menu Route
static const WELCOME = '/welcome';
static const ABOUT = '/about-you';
static const LOGIN = '/login';
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib
|
mirrored_repositories/aqua_workout_lite/lib/routes/app_pages.dart
|
// ignore_for_file: constant_identifier_names
import 'package:get/get.dart';
import '../core.dart';
part 'app_routes.dart';
class AppPages {
static const INITIAL = Routes.WELCOME;
static final routes = [
GetPage(
name: Routes.WELCOME,
page: () => const WelcomeView(),
),
GetPage(
name: Routes.ABOUT,
page: () => const AboutView(),
),
GetPage(
name: Routes.LOGIN,
page: () => const LoginView(),
),
];
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib
|
mirrored_repositories/aqua_workout_lite/lib/pages/xcore.dart
|
// Started
export 'started/welcome_view.dart';
export 'started/about_view.dart';
export 'started/login_view.dart';
| 0
|
mirrored_repositories/aqua_workout_lite/lib/pages
|
mirrored_repositories/aqua_workout_lite/lib/pages/started/welcome_view.dart
|
import 'package:aqua_workout_lite/core.dart';
import 'package:aqua_workout_lite/routes/app_pages.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class WelcomeView extends StatelessWidget {
const WelcomeView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kThirdColor,
body: Stack(
children: [
backgroundImage(),
Container(
width: Get.width,
height: Get.height,
color: kThirdColor.withOpacity(0.7),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
child: Column(
children: [
const SizedBox(height: 30),
RichText(
text: const TextSpan(
text: 'HARD\t',
style: TextStyle(
fontFamily: "Bebas", fontSize: 30, letterSpacing: 5),
children: <TextSpan>[
TextSpan(
text: 'ELEMENT',
style: TextStyle(color: kFirstColor),
)
],
),
),
const Spacer(),
Align(
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
"Welcome",
style: TextStyle(
fontSize: 40,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 17),
Text(
"Train and live the new experience of \nexercising at home",
style: TextStyle(color: Colors.white),
)
],
),
),
const SizedBox(height: 30),
TextButton(
onPressed: () => Get.toNamed(Routes.ABOUT),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: kFirstColor,
),
height: 50,
width: Get.width * 0.7,
child: const Center(
child: Text(
"Try Now",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
),
const SizedBox(height: 10),
TextButton(
onPressed: () => Get.toNamed(Routes.LOGIN),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: Colors.transparent,
border: Border.all(width: 2, color: Colors.white),
),
height: 50,
width: Get.width * 0.7,
child: const Center(
child: Text(
"Login",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
),
const SizedBox(height: 27),
],
),
),
),
],
),
);
}
Container backgroundImage() {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/black/9.jpg"),
fit: BoxFit.cover,
),
),
);
}
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib/pages
|
mirrored_repositories/aqua_workout_lite/lib/pages/started/about_view.dart
|
import 'package:aqua_workout_lite/core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class AboutView extends StatelessWidget {
const AboutView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kThirdColor,
body: Stack(
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/black/16.jpg"),
fit: BoxFit.cover,
),
),
),
Container(
width: Get.size.width,
height: Get.size.height,
color: kThirdColor.withOpacity(0.7),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
child: Column(
children: [
const SizedBox(height: 30),
RichText(
text: const TextSpan(
text: 'HARD\t',
style: TextStyle(
fontFamily: "Bebas", fontSize: 30, letterSpacing: 5),
children: <TextSpan>[
TextSpan(
text: 'ELEMENT',
style: TextStyle(color: kFirstColor),
)
],
),
),
const Spacer(),
Align(
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
"About You",
style: TextStyle(
fontSize: 40,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 5),
Text(
"We want to know more about you, follow the next \nsteps to complete the information",
style: TextStyle(color: Colors.white),
)
],
),
),
const SizedBox(height: 30),
ValueBuilder<int>(
initialValue: 0,
builder: (value, updateFn) => Row(
children: [
OptionWidget(
state: "I'm\nBeginner",
detail: "I have trained several times",
enable: value == 0 ? true : false,
onTap: () => updateFn(0),
),
const SizedBox(width: 20),
OptionWidget(
state: "I'm\nExpert",
detail: "I have trained more times",
enable: value == 1 ? true : false,
onTap: () => updateFn(1),
),
],
),
),
const SizedBox(height: 30),
buildFooter(),
],
),
),
),
],
),
);
}
Widget buildFooter() {
return Row(
children: [
TextButton(
onPressed: () => Get.back(),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
),
child: const Center(
child: Text(
"Back",
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
),
),
),
const Spacer(),
TextButton(
onPressed: () {},
child: Container(
height: 40,
width: 130,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: kFirstColor,
),
child: const Center(
child: Text(
"Next",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
),
),
],
);
}
}
| 0
|
mirrored_repositories/aqua_workout_lite/lib/pages
|
mirrored_repositories/aqua_workout_lite/lib/pages/started/login_view.dart
|
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:aqua_workout_lite/core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class LoginView extends StatelessWidget {
const LoginView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kThirdColor,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
backgroundImage(),
titleSubtitle(),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
formLogin(),
SizedBox(height: 15),
forgetButton(),
SizedBox(height: 15),
Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextButton(
onPressed: () {},
child: Container(
height: 50,
width: Get.width * 0.7,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: kFirstColor,
),
child: Center(
child: Text(
"Login",
style: TextStyle(
color: Colors.white, fontSize: 20),
),
),
),
),
TextButton(
onPressed: () {},
child: Container(
height: 50,
width: Get.width * 0.7,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: kThirdColor,
border:
Border.all(width: 1, color: kFirstColor)),
child: Center(
child: Text(
"Sign Up",
style: TextStyle(
color: Colors.white, fontSize: 20),
),
),
),
),
],
),
)
],
),
)
],
),
),
);
}
Align forgetButton() {
return Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {},
child: Text(
"Forgot your password?",
style: TextStyle(color: Colors.white, fontSize: 18),
),
),
);
}
Column formLogin() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Email",
style: TextStyle(color: Color(0xFF707070), fontSize: 18),
),
TextField(
decoration: InputDecoration(
hintText: "faisalramdan.id@gmail.com",
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF707070),
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF707070),
),
),
),
),
SizedBox(height: 20),
Text(
"Password",
style: TextStyle(color: Color(0xFF707070), fontSize: 18),
),
TextField(
obscureText: true,
decoration: InputDecoration(
hintText: "*******",
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF707070),
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF707070),
),
),
),
),
],
);
}
Container titleSubtitle() {
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
kThirdColor,
Colors.transparent,
]),
),
height: Get.height * 0.55,
width: Get.width,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
child: Column(
children: [
const SizedBox(height: 30),
RichText(
text: const TextSpan(
text: 'HARD\t',
style: TextStyle(
fontFamily: "Bebas",
fontSize: 30,
letterSpacing: 5,
),
children: [
TextSpan(
text: 'ELEMENT',
style: TextStyle(
color: kFirstColor,
),
)
]),
),
const Spacer(),
Align(
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
"Sign In",
style: TextStyle(
fontSize: 40,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10),
Text(
"Train and live the new experience of \nexercising"
" at home",
style: TextStyle(fontSize: 20),
),
],
),
),
],
),
),
);
}
Container backgroundImage() {
return Container(
height: Get.height * 0.55,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/black/12.jpg"),
fit: BoxFit.cover,
),
),
);
}
}
| 0
|
mirrored_repositories/aqua_workout_lite
|
mirrored_repositories/aqua_workout_lite/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:aqua_workout_lite/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.