repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/Flutter-Calculator
mirrored_repositories/Flutter-Calculator/lib/main.dart
import 'package:flutter/material.dart'; import 'package:math_expressions/math_expressions.dart'; void main(){ runApp(MyCalculator()); } class MyCalculator extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Calculator', theme: ThemeData(primarySwatch: Colors.blue), home: SimpleCalculator(), ); } } class SimpleCalculator extends StatefulWidget { @override _SimpleCalculatorState createState() => _SimpleCalculatorState(); } class _SimpleCalculatorState extends State<SimpleCalculator>{ String equation="0",result="0",expression="",temp=""; double eqnFontSize=38, resFontSize=48; buttonPressed(buttonText){ setState(() { if(buttonText == "C"){ equation="0"; result="0"; } else if(buttonText == "DEL"){ equation=equation.substring(0,equation.length-1); if(equation=="") equation="0"; } else if(buttonText == "ANS") { equation+=temp; } else if(buttonText == "="){ expression=equation; expression=expression.replaceAll("×", "*"); expression=expression.replaceAll("÷", "/"); try{ Parser P = new Parser(); Expression exp = P.parse(expression); ContextModel cm =ContextModel(); result = '${exp.evaluate(EvaluationType.REAL, cm)}'; temp=result; } catch(e){ result="Error"; } } else{ if(equation=="0") equation=buttonText; else equation=equation+buttonText; } }); } Widget buildButton(String buttonText,double buttonHeight,Color buttonColor){ return Container( height:MediaQuery.of(context).size.height*0.1*buttonHeight, color: buttonColor, child: SizedBox( width: 5, height: 5, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), side: BorderSide(color: Colors.white,width: 1, style: BorderStyle.solid), ), padding: EdgeInsets.all(0), onPressed: ()=> buttonPressed(buttonText), child: Text( buttonText, style: TextStyle( fontSize: 30.0, fontWeight: FontWeight.normal, color: Colors.white ), ), ), ), ); } @override Widget build(BuildContext context){ return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title : Text('Calculator',style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold, color: Colors.white, ) ) ), body: Column( children: <Widget>[ Container( alignment: Alignment.centerRight, padding: EdgeInsets.fromLTRB(10,20,10,0), child: Text(equation,style: TextStyle(fontSize: eqnFontSize),), ), Container( alignment: Alignment.centerRight, padding: EdgeInsets.fromLTRB(10,30,10,0), child: Text(result,style: TextStyle(fontSize: resFontSize),), ), Expanded( child: Divider(), ), Row( //mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( color: Colors.white, width:MediaQuery.of(context).size.width*0.80, child: Table( children:[ TableRow( children:[ buildButton("C", 1.2, Colors.green), buildButton("DEL", 1.2, Colors.red), buildButton("ANS", 1.2, Colors.indigo), ] ), TableRow( children:[ buildButton("7", 1.2, Colors.blue), buildButton("8", 1.2, Colors.blue), buildButton("9", 1.2, Colors.blue), ] ), TableRow( children:[ buildButton("4", 1.2, Colors.blue), buildButton("5", 1.2, Colors.blue), buildButton("6", 1.2, Colors.blue), ] ), TableRow( children:[ buildButton("1", 1.2, Colors.blue), buildButton("2", 1.2, Colors.blue), buildButton("3", 1.2, Colors.blue), ] ), TableRow( children:[ buildButton(".", 1.2, Colors.blue), buildButton("0", 1.2, Colors.blue), buildButton("00", 1.2, Colors.blue), ] ), ] ), ), Container( width:MediaQuery.of(context).size.width*0.20, child: Table( children: [ TableRow( children: [ buildButton("÷", 1, Colors.indigo), ] ), TableRow( children: [ buildButton("×", 1, Colors.indigo), ] ), TableRow( children: [ buildButton("+", 1, Colors.indigo), ] ), TableRow( children: [ buildButton("-", 1, Colors.indigo), ] ), TableRow( children: [ buildButton("=", 2, Colors.green), ] ), ], ), ) ], ) ], ), ); } }
0
mirrored_repositories/Flutter-Calculator
mirrored_repositories/Flutter-Calculator/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:shametha_calculator/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyCalculator()); // 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/Birthday-reminder-sqflite
mirrored_repositories/Birthday-reminder-sqflite/lib/themes.dart
import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; class Themes { // light theme static final light = ThemeData( backgroundColor: white, primaryColor: primaryClr, brightness: Brightness.light, ); // dark theme static final dark = ThemeData( backgroundColor: darkgreyClr, primaryColor: darkgreyClr, brightness: Brightness.dark, ); } TextStyle get subHeadingStyle { return (GoogleFonts.lato( textStyle: TextStyle( fontSize: 18.sp, color: Get.isDarkMode ? Colors.grey[400] : Colors.grey, fontWeight: FontWeight.w500, ), )); } TextStyle get headingStyle { return (GoogleFonts.lato( textStyle: TextStyle( fontSize: 24.sp, color: Get.isDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.bold, ), )); } TextStyle get textHeadingStyle { return (GoogleFonts.lato( textStyle: TextStyle( fontSize: 14.sp, color: Get.isDarkMode ? Colors.white : Colors.black, fontWeight: FontWeight.w500, ), )); } TextStyle get textInputStyle { return (GoogleFonts.lato( textStyle: TextStyle( fontSize: 16.sp, color: Get.isDarkMode ? Colors.grey[100] : Colors.grey[800], fontWeight: FontWeight.w500, ), )); } TextStyle get hintStyle { return (GoogleFonts.lato( textStyle: TextStyle( fontSize: 14.sp, color: Get.isDarkMode ? Colors.grey[400] : Colors.grey[600], fontWeight: FontWeight.w500, ), )); }
0
mirrored_repositories/Birthday-reminder-sqflite
mirrored_repositories/Birthday-reminder-sqflite/lib/main.dart
import 'package:example_todo_sqflite/db/db_helper.dart'; import 'package:example_todo_sqflite/services/notification_services.dart'; import 'package:example_todo_sqflite/services/theme_services.dart'; import 'package:example_todo_sqflite/themes.dart'; import 'package:example_todo_sqflite/ui/home_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get_navigation/src/root/get_material_app.dart'; import 'package:get_storage/get_storage.dart'; import 'package:hive/hive.dart'; import 'package:hive_flutter/hive_flutter.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await DBHelper.initDb(); await GetStorage.init(); await Hive.initFlutter(); await Hive.openBox('themedata'); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(360, 690), minTextAdapt: true, splitScreenMode: true, builder: (context, child) { return ValueListenableBuilder<Box>( valueListenable: Hive.box('themedata').listenable(), builder: (context, box, widget) { var darkMode = box.get('darkmode', defaultValue: false); return GetMaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: Themes.light, darkTheme: Themes.dark, themeMode: darkMode ? ThemeMode.dark : ThemeMode.light, home: HomePage( box: box, darkMode: darkMode, ), ); } ); }); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/controllers/add_task_controller.dart
import 'package:example_todo_sqflite/db/db_helper.dart'; import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:get/get.dart'; class TaskController extends GetxController { @override void onReady() { super.onReady(); } // inserting the object to the database var taskList = <UserTask>[].obs; Future<int> addTask({UserTask? task}) async { return await DBHelper.insert(task); } // reading the object from the database void getTask() async { print("read function is called"); List<Map<String, dynamic?>>? tasks = await DBHelper.query(); taskList.assignAll(tasks!.map((e) => UserTask.fromJson(e)).toList()); } // deleting the task using the specific id Future<void> delete({required UserTask task}) async { var id = await DBHelper.delete(task: task); print(id); getTask(); } // updating the task in the database by id Future<void> updateTask(int id) async { var value = await DBHelper.update(id); print(value); getTask(); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/db/db_helper.dart
import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sqflite/sqflite.dart'; class DBHelper { static Database? _db; static final int _version = 1; static final String _tableName = "tasks"; static Future<void> initDb() async { if (_db != null) { return; } try { String _path = await getDatabasesPath() + "tasks.db"; _db = await openDatabase(_path, version: _version, onCreate: (db, version) async { print("creating a new one"); return await db.execute( 'CREATE TABLE $_tableName (id INTEGER PRIMARY KEY AUTOINCREMENT, title STRING, note TEXT,date STRING, start_time STRING,end_time STRING,remind INTEGER,repeat STRING,color INTEGER,is_completed INTEGER)'); }); } catch (e) { print(e); } } // insert Method static Future<int> insert(UserTask? task) async { print("insert function is called"); return await _db?.insert(_tableName, task!.toJson()) ?? 1; } // read Method static Future<List<Map<String, Object?>>?> query() async { print("read function is called"); return await _db?.query(_tableName); } // delete Method static Future<int?> delete({required UserTask task}) async { print("delete function is called"); return await _db?.delete(_tableName, where: 'id=?', whereArgs: [task.id]); } // update Method static Future<int> update(int id) async { print("update function is running"); return await _db!.rawUpdate(''' UPDATE $_tableName SET is_completed=? where id =? ''', [1, id]); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/models/task_model.dart
class UserTask { int? id; String? title; String? note; int? isCompleted; String? date; String? startTime; String? endTime; int? remind; int? color; String? repeat; UserTask( { this.id, this.title, this.note, this.isCompleted, this.date, this.startTime, this.endTime, this.remind, this.color, this.repeat, } ); UserTask.fromJson(Map<String, dynamic> json) { id = json['id']; title = json['title']; note = json['note']; isCompleted = json['is_completed']; date = json['date']; startTime = json['start_time']; endTime = json['end_time']; remind = json['remind']; color = json['color']; repeat = json['repeat']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = Map<String, dynamic>(); data["id"] = id; data["title"] = title; data["note"] = note; data['is_completed'] = isCompleted; data["date"] = date; data["start_time"] = startTime; data["end_time"] = endTime; data["remind"] = remind; data["color"] = color; data["repeat"] = repeat; return data; } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/home_page.dart
import 'package:date_picker_timeline/date_picker_timeline.dart'; import 'package:example_todo_sqflite/controllers/add_task_controller.dart'; import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:example_todo_sqflite/services/theme_services.dart'; import 'package:example_todo_sqflite/themes.dart'; import 'package:example_todo_sqflite/ui/add_task_page.dart'; import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:example_todo_sqflite/ui/widgets/button_dart.dart'; import 'package:example_todo_sqflite/ui/widgets/task_tile_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hive/hive.dart'; import 'package:intl/intl.dart'; import '../services/notification_services.dart'; class HomePage extends StatefulWidget { final box; final darkMode; const HomePage({Key? key, required this.box, required this.darkMode}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { TaskController _taskController = Get.put(TaskController()); var _selectedDate = DateTime.now(); late NotificationServices notifyHelper; @override void initState() { notifyHelper = NotificationServices(); // notifyHelper.selectNotification('payload'); notifyHelper.initializeNotification(); notifyHelper.requestIOSPermissions(); _taskController.getTask(); // TODO: implement initState super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: _appBar(), body: Container( child: Column( children: [ // appbartask bar _appTaskBar(), // Date Picker TimeLines _appDateBar(), SizedBox(height: 22.h), // list of the object user tasks _showUserTasks(), ], ), ), ); } _showUserTasks() { return Expanded(child: Obx( () { return ListView.builder( physics: BouncingScrollPhysics(), shrinkWrap: true, itemCount: _taskController.taskList.length, itemBuilder: (context, index) { print( "list view builder has ${_taskController.taskList.length} items."); UserTask task = _taskController.taskList[index]; print(task.toJson()); if (task.repeat == 'Daily') { DateTime date = DateFormat.jm().parse(task.startTime.toString()); var myTime = DateFormat('HH:mm').format(date); print(myTime); notifyHelper.scheduledNotification( int.parse(myTime.split(":")[0]), int.parse(myTime.split(":")[1]), task, ); return AnimationConfiguration.staggeredList( position: index, child: SlideAnimation( child: FadeInAnimation( child: Row( children: [ GestureDetector( onTap: () { _showBottomSheet(context, task); }, child: TaskTile(task), ), ], ), ), ), ); } if (task.date == DateFormat.yMd().format(_selectedDate)) { return AnimationConfiguration.staggeredList( position: index, child: SlideAnimation( child: FadeInAnimation( child: Row( children: [ GestureDetector( onTap: () { _showBottomSheet(context, task); }, child: TaskTile(task), ), ], ), ), ), ); } else { return Container(); } }, ); }, )); } _showBottomSheet( BuildContext context, UserTask task, ) { Get.bottomSheet(BottomSheet( onClosing: () {}, builder: (context) { return Container( padding: EdgeInsets.symmetric(horizontal: 12.w), height: task.isCompleted == 0 ? 210.h : 170.h, decoration: BoxDecoration( color: Get.isDarkMode ? darkgreyClr : Colors.white, ), child: Column( children: [ // top heading line Container( margin: EdgeInsets.only(top: 1.0.r), width: 120.w, height: 4.h, decoration: BoxDecoration( color: Colors.grey[400], borderRadius: BorderRadius.circular(14.r), ), ), // custom Button SizedBox(height: task.isCompleted == 0 ? 54.h : 42.h), task.isCompleted == 1 ? Container() : _customButton( clr: bluishClr, ontap: () { _taskController.updateTask(task.id!); Get.back(); }, lable: 'Task Completed', ), SizedBox(height: 8.h), _customButton( clr: pickClr, ontap: () { _taskController.delete(task: task); _taskController.getTask(); Get.back(); }, lable: 'Delete Task', ), SizedBox(height: 8.h), _customButton( clr: Colors.transparent, ontap: () { Get.back(); }, lable: 'Close', isClose: true, ), ], ), ); }, )); } _customButton({ required Color clr, required VoidCallback ontap, required String lable, bool isClose = false, }) { return GestureDetector( onTap: () { ontap(); }, child: Container( width: double.maxFinite, height: 40.h, decoration: BoxDecoration( color: clr, borderRadius: BorderRadius.circular(30.r), border: Border.all( width: 2, color: isClose ? Get.isDarkMode ? Colors.grey[600]! : Colors.grey[300]! : clr, ), ), child: Center( child: isClose ? Text( lable, style: textHeadingStyle, ) : Text( lable, style: textHeadingStyle.copyWith(color: Colors.white), )), ), ); } Container _appDateBar() { return Container( margin: EdgeInsets.only(left: 20.w, top: 20.h), child: DatePicker( DateTime.now(), height: 100.h, width: 80.w, initialSelectedDate: DateTime.now(), selectedTextColor: Colors.white, selectionColor: bluishClr, dateTextStyle: GoogleFonts.lato( textStyle: TextStyle( fontSize: 20.sp, fontWeight: FontWeight.w500, color: Colors.grey, ), ), dayTextStyle: GoogleFonts.lato( textStyle: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.w500, color: Colors.grey, ), ), monthTextStyle: GoogleFonts.lato( textStyle: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.w500, color: Colors.grey, ), ), onDateChange: (date) { setState(() { _selectedDate = date; }); }, ), ); } Container _appTaskBar() { return Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // appTaskBar Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Text( DateFormat.yMMMMd().format( DateTime.now(), ), style: subHeadingStyle, ), Text( "Today", style: headingStyle, ), ], ), // add-task-button MyButton( lable: "+ Add Task", ontap: () async { await Get.to(AddTaskBar()); _taskController.getTask(); }, ), ], ), ); } AppBar _appBar() { return AppBar( elevation: 0, backgroundColor: Theme.of(context).backgroundColor, leading: Switch( value: widget.darkMode, onChanged: (value) { widget.box.put('darkmode', value); }, ), // await notifyHelper.scheduledNotification(); actions: [ IconButton( onPressed: () { Get.snackbar("Message", "HI! 😎"); }, icon: CircleAvatar( backgroundImage: AssetImage("images/profile.jpg"), ), ), ], ); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/add_task_page.dart
import 'package:example_todo_sqflite/controllers/add_task_controller.dart'; import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:example_todo_sqflite/themes.dart'; import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:example_todo_sqflite/ui/widgets/button_dart.dart'; import 'package:example_todo_sqflite/ui/widgets/text_field_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; class AddTaskBar extends StatefulWidget { const AddTaskBar({Key? key}) : super(key: key); @override State<AddTaskBar> createState() => _AddTaskBarState(); } class _AddTaskBarState extends State<AddTaskBar> { TaskController _taskController = Get.put(TaskController()); TextEditingController _userTitle = TextEditingController(); TextEditingController _userNote = TextEditingController(); DateTime? _selectedDate = DateTime.now(); String _startTime = DateFormat('hh:mm a').format(DateTime.now()).toString(); String _endTime = "9:29 AM"; int _selectRemind = 5; List<int> remindList = [ 5, 10, 15, 20, ]; String _selectRepeat = "None"; List<String> repeatList = [ "None", "Daily", "Weekly", "Monthly", ]; int _selectedIndex = 0; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: _appBar(), body: Container( padding: EdgeInsets.only(left: 18.w, right: 18.w, top: 10.h), child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Add Task", style: headingStyle, ), MyTextField( lable: "Title", hintText: "Enter the title", controller: _userTitle, ), MyTextField( lable: "Note", hintText: "Enter the note", controller: _userNote, ), MyTextField( lable: "Note", hintText: DateFormat.yMd().format(_selectedDate!), widget: IconButton( onPressed: () async { _getUserDate(context); }, icon: Icon( Icons.calendar_today_outlined, color: Get.isDarkMode ? Colors.grey[100] : Colors.grey[600], ), ), ), // start time and the end time Row( children: [ Expanded( child: MyTextField( hintText: _startTime, lable: "Start Time", widget: IconButton( icon: Icon(Icons.access_time_rounded), onPressed: () { _getUserTIme(isStarttime: true); }, ), ), ), SizedBox(width: 6.w), Expanded( child: MyTextField( hintText: _endTime, lable: "End Time", widget: IconButton( icon: Icon(Icons.access_time_rounded), onPressed: () { _getUserTIme(isStarttime: false); }, ), ), ), ], ), // remind the user MyTextField( hintText: "$_selectRemind minutes early", lable: "Remind", widget: DropdownButton( style: textHeadingStyle, iconSize: 32.sp, elevation: 4, underline: Container(height: 0.0), items: remindList.map<DropdownMenuItem<String>>((int value) { return DropdownMenuItem<String>( value: value.toString(), child: Text(value.toString()), ); }).toList(), icon: Icon(Icons.keyboard_arrow_down, color: Colors.grey), onChanged: (String? value) => setState(() { _selectRemind = int.parse(value!); })), ), // remind repeat MyTextField( hintText: _selectRepeat, lable: "Repeat", widget: DropdownButton( style: textHeadingStyle, iconSize: 32.sp, elevation: 4, underline: Container(height: 0.0), items: repeatList .map<DropdownMenuItem<String>>((String value) { return DropdownMenuItem<String>( value: value.toString(), child: Text( value, style: TextStyle(color: Colors.grey), ), ); }).toList(), icon: Icon(Icons.keyboard_arrow_down, color: Colors.grey), onChanged: (String? value) => setState(() { _selectRepeat = value!; })), ), // select bottom color SizedBox(height: 18.h), Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ _colorPallete(), MyButton( lable: "Create Task", ontap: () { _validator(); }), ], ), SizedBox(height: 16.h), ], ), ), ), ); } Column _colorPallete() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Color", style: textHeadingStyle, ), SizedBox(height: 8.h), Wrap( children: List<Widget>.generate( 3, (index) => GestureDetector( onTap: () { setState(() { _selectedIndex = index; }); }, child: Padding( padding: EdgeInsets.only(right: 4.w), child: CircleAvatar( child: _selectedIndex == index ? Icon( Icons.done, color: Colors.white, size: 14.sp, ) : Container(), backgroundColor: index == 0 ? bluishClr : index == 1 ? yellowClr : pickClr, radius: 14.r, ), ), )), ), ], ); } _validator() { if (_userTitle.text.isEmpty && _userNote.text.isEmpty) { Get.snackbar( "Message", "All the fields are required.", icon: Icon( Icons.warning_amber_outlined, color: Colors.amber, ), ); } else if (_userTitle.text.isEmpty || _userNote.text.isEmpty) { Get.snackbar( "Message", "All the fields are requird.", icon: Icon(Icons.warning_amber_outlined), ); } else { _addToDatabase(); Get.back(); } } _addToDatabase() async { var valueId = await _taskController.addTask( task: UserTask( title: _userTitle.text, note: _userNote.text, date: DateFormat.yMd().format(_selectedDate!), startTime: _startTime, endTime: _endTime, remind: _selectRemind, repeat: _selectRepeat, color: _selectedIndex, isCompleted: 0, ), ); print("My id is $valueId"); } _getUserDate(BuildContext context) async { DateTime? _datePicker = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(2015), lastDate: DateTime(2302), ); if (_datePicker != null) { setState(() { _selectedDate = _datePicker; }); } else { print("Value is null date is not pick by the user successfully."); } } _getUserTIme({required bool isStarttime}) async { var userPickTime = await _showTimePicker(); String _formatedTime = userPickTime.format(context); if (userPickTime == null) { print("Time is not valid time cancelled"); } else if (isStarttime) { setState(() { _startTime = _formatedTime; }); } else if (isStarttime == false) { setState(() { _endTime = _formatedTime; }); } } _showTimePicker() { return showTimePicker( initialEntryMode: TimePickerEntryMode.input, context: context, initialTime: TimeOfDay( hour: int.parse(_startTime.split(":")[0]), minute: int.parse(_startTime.split(":")[1].split(" ")[0]), ), ); } AppBar _appBar() { return AppBar( elevation: 0, backgroundColor: Theme.of(context).backgroundColor, leading: IconButton( onPressed: () { Get.back(); }, icon: Icon( Icons.arrow_back_ios, color: Get.isDarkMode ? Colors.white : Colors.black, ), ), actions: [ IconButton( onPressed: () {}, icon: Icon( Icons.person, color: Get.isDarkMode ? Colors.white : Colors.grey, ), ), ], ); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/notified_page.dart
import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; class NotifiedPage extends StatelessWidget { final String lable; const NotifiedPage({Key? key, required this.lable}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: _appBar(context, lable), body: Container( margin: EdgeInsets.symmetric(horizontal: 20.w), child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 400.h, width: double.maxFinite, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14.r), color: Get.isDarkMode ? Colors.black : Colors.grey[600], ), child: Center( child: Text( lable.split("|")[1], style: TextStyle( color: Get.isDarkMode ? Colors.white : Colors.black, fontSize: 22.sp, fontWeight: FontWeight.w500, fontFamily: "cursive", ), ), ), ), ]), ), ); } AppBar _appBar(BuildContext context, String label) { return AppBar( centerTitle: true, elevation: 0, backgroundColor: Theme.of(context).backgroundColor, leading: IconButton( onPressed: () async { Get.back(); }, icon: Icon( Get.isDarkMode ? Icons.arrow_back_ios : Icons.arrow_back_ios, color: Get.isDarkMode ? Colors.grey[300] : Colors.grey[600], ), ), title: Center( child: Text( lable.split("|")[0].toString(), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 18.sp, ), ), ), ); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/constants.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; const Color bluishClr = Color(0xff4e5ae8); const Color yellowClr = Color(0xffffb746); const Color pickClr = Color(0xffff4667); const Color white = Color(0xffF2F2F2); const Color primaryClr = bluishClr; const Color darkgreyClr = Color(0xff121212); const Color darkHeaderClr = Color(0xff424242);
0
mirrored_repositories/Birthday-reminder-sqflite/lib/ui
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/widgets/text_field_widget.dart
import 'package:example_todo_sqflite/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; class MyTextField extends StatelessWidget { final String hintText; final String lable; final TextEditingController? controller; final Widget? widget; MyTextField( {Key? key, required this.hintText, required this.lable, this.controller, this.widget}) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: 10.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( lable, style: textHeadingStyle, ), SizedBox(height: 6.h), Container( padding: EdgeInsets.only(left: 14.w, right: 14.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12.r), border: Border.all( color: Colors.grey[500]!, width: 1.0, ), ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: TextFormField( readOnly: widget == null ? false : true, cursorColor: Get.isDarkMode ? Colors.grey[100] : Colors.grey[800], autofocus: false, autocorrect: true, controller: controller, style: textInputStyle, decoration: InputDecoration( enabledBorder: InputBorder(context), border: InputBorder(context), hintStyle: hintStyle, hintText: hintText, focusedBorder: InputBorder(context), ), ), ), widget == null ? Container( height: 0.0, ) : Container( child: widget, ), ], ), ), ], ), ); } UnderlineInputBorder InputBorder(BuildContext context) { return UnderlineInputBorder( borderRadius: BorderRadius.circular(12.r), borderSide: BorderSide( color: Theme.of(context).backgroundColor, ), ); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib/ui
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/widgets/task_tile_widget.dart
import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class TaskTile extends StatelessWidget { final UserTask? task; TaskTile(this.task); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 20), width: MediaQuery.of(context).size.width, margin: EdgeInsets.only(bottom: 12), child: Container( padding: EdgeInsets.all(16), // width: SizeConfig.screenWidth * 0.78, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), color: _getBGClr(task?.color ?? 0), ), child: Row(children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( task?.title ?? "", style: GoogleFonts.lato( textStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white), ), ), SizedBox( height: 12, ), Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( Icons.access_time_rounded, color: Colors.grey[200], size: 18, ), SizedBox(width: 4), Text( "${task!.startTime} - ${task!.endTime}", style: GoogleFonts.lato( textStyle: TextStyle(fontSize: 13, color: Colors.grey[100]), ), ), ], ), SizedBox(height: 12), Text( task?.note ?? "", style: GoogleFonts.lato( textStyle: TextStyle(fontSize: 15, color: Colors.grey[100]), ), ), ], ), ), Container( margin: EdgeInsets.symmetric(horizontal: 10), height: 60, width: 0.5, color: Colors.grey[200]!.withOpacity(0.7), ), RotatedBox( quarterTurns: 3, child: Text( task!.isCompleted == 1 ? "COMPLETED" : "TODO", style: GoogleFonts.lato( textStyle: TextStyle( fontSize: 10, fontWeight: FontWeight.bold, color: Colors.white), ), ), ), ]), ), ); } _getBGClr(int no) { switch (no) { case 0: return bluishClr; case 1: return pickClr; case 2: return yellowClr; default: return bluishClr; } } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib/ui
mirrored_repositories/Birthday-reminder-sqflite/lib/ui/widgets/button_dart.dart
import 'package:example_todo_sqflite/ui/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class MyButton extends StatelessWidget { final String lable; final Function()? ontap; const MyButton({Key? key, required this.lable, this.ontap}) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: ontap, child: Container( width: 120.w, height: 45.h, decoration: BoxDecoration( color: bluishClr, borderRadius: BorderRadius.circular(14.r), ), child: Center( child: Text( lable, textAlign: TextAlign.center, style: TextStyle( fontSize: 18.sp, color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/services/theme_services.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; class ThemeServices { final _box = GetStorage(); final _key = "isDarkMode"; bool _loadThemeFromStorage() => _box.read(_key) ?? false; _saveThemeInStorage(bool isDarkMode) => _box.write(_key, isDarkMode); ThemeMode get theme => _loadThemeFromStorage() ? ThemeMode.dark : ThemeMode.light; void updateTheme() { Get.changeThemeMode( _loadThemeFromStorage() ? ThemeMode.dark : ThemeMode.light); _saveThemeInStorage(!_loadThemeFromStorage()); } }
0
mirrored_repositories/Birthday-reminder-sqflite/lib
mirrored_repositories/Birthday-reminder-sqflite/lib/services/notification_services.dart
import 'package:example_todo_sqflite/models/task_model.dart'; import 'package:example_todo_sqflite/ui/notified_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_native_timezone/flutter_native_timezone.dart'; import 'package:get/get.dart'; import 'package:timezone/data/latest_all.dart' as tz; import 'package:timezone/timezone.dart' as tz; class NotificationServices { FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); // initializeNotification() async { _configureLocalTimeZone(); //tz.initializeTimeZones(); final IOSInitializationSettings initializationSettingsIOS = IOSInitializationSettings( requestSoundPermission: false, requestBadgePermission: false, requestAlertPermission: false, onDidReceiveLocalNotification: onDidReceiveLocalNotification); final AndroidInitializationSettings androidInitializationSettingsIOS = AndroidInitializationSettings('@mipmap/ic_launcher'); // var initializationSettingsAndroid = // AndroidInitializationSettings('mipmap/ic_launcher'); final InitializationSettings initializationSettings = InitializationSettings( iOS: initializationSettingsIOS, android: androidInitializationSettingsIOS, ); await flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: selectNotification); } displayNotification({required String title, required String body}) async { print("Diplay Notificatoin..."); // ignore: prefer_const_constructors var androidPlatformChannelSpecifics = AndroidNotificationDetails( 'your channel id', 'your channel name', importance: Importance.max, priority: Priority.high); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); var platformChannelSpecifics = NotificationDetails( android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( 0, title, body, platformChannelSpecifics, payload: title, ); } // Future<void> scheduledNotification() async { // print("Scheduled Notificatin is trigger"); // await flutterLocalNotificationsPlugin.zonedSchedule( // 0, // 'scheduled title', // 'scheduled body', // // _currentTime(hours, min), // tz.TZDateTime.now(tz.local).add(Duration(seconds: 3)), // const NotificationDetails( // android: AndroidNotificationDetails( // 'your channel id', 'your channel name', // channelDescription: 'your channel description')), // androidAllowWhileIdle: true, // uiLocalNotificationDateInterpretation: // UILocalNotificationDateInterpretation.absoluteTime, // matchDateTimeComponents: DateTimeComponents.time, // ); // print("Scheduled Notificatin is trigger ending "); // } Future<void> scheduledNotification(int hours, int min, UserTask task) async { print("Scheduled Notificatin is trigger"); await flutterLocalNotificationsPlugin.zonedSchedule( task.id!.toInt(), task.title, task.note, _currentTime(hours, min), // tz.TZDateTime.now(tz.local).add(Duration(seconds: min)), const NotificationDetails( android: AndroidNotificationDetails( 'your channel id', 'your channel name', channelDescription: 'your channel description')), androidAllowWhileIdle: true, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, matchDateTimeComponents: DateTimeComponents.time, payload: "${task.title}|${task.note}"); print("Scheduled Notificatin is trigger ending "); } tz.TZDateTime _currentTime(int hour, int min) { print("_cutternt time funciotn is ruunning "); final tz.TZDateTime now = tz.TZDateTime.now(tz.local); tz.TZDateTime scheduledDate = tz.TZDateTime(tz.local, now.year, now.month, now.day, hour, min); if (scheduledDate.isBefore(now)) { print("schedule data condition "); scheduledDate = scheduledDate.add(const Duration(days: 1)); } print("_cutternt time funciotn is ending "); return scheduledDate; } Future<void> _configureLocalTimeZone() async { tz.initializeTimeZones(); final String currentTimeZone = await FlutterNativeTimezone.getLocalTimezone(); print("My current time zone is $currentTimeZone"); tz.setLocalLocation(tz.getLocation(currentTimeZone)); } void requestIOSPermissions() { flutterLocalNotificationsPlugin .resolvePlatformSpecificImplementation< IOSFlutterLocalNotificationsPlugin>() ?.requestPermissions( alert: true, badge: true, sound: true, ); } Future selectNotification(String? payload) async { if (payload != null) { print('notification payload: $payload'); } else { print("Notification Done"); } if (payload == "Message") { print("Nothing to navigate "); } else { Get.to(() => NotifiedPage(lable: payload!)); } } Future onDidReceiveLocalNotification( int? id, String? title, String? body, String? payload) async { // display a dialog with the notification details, tap ok to go to another page Get.dialog(Text("Welcome to the Flutter.")); } }
0
mirrored_repositories/Birthday-reminder-sqflite
mirrored_repositories/Birthday-reminder-sqflite/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 in the flutter_test package. 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:example_todo_sqflite/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
mirrored_repositories/flutter-apnea-app
mirrored_repositories/flutter-apnea-app/lib/db_helper.dart
import 'package:sqflite/sqflite.dart' as sql; import 'package:path/path.dart' as path; import 'package:sqflite/sqflite.dart'; class DBHelper { static const versionNumber = 1; static const createQueries = [ ''' CREATE TABLE breath_hold_histories( uniqueKey CHAR(5) PRIMARY KEY, datetime VARCHAR(20) NOT NULL, firstContraction VARCHAR(5), duration VARCHAR(5) NOT NULL );''', ''' CREATE TABLE training_table_entry( trainingTableKey CHAR(8) NOT NULL, rowIndex INT NOT NULL, holdTime VARCHAR(5) NOT NULL, breatheTime VARCHAR(5) NOT NULL, PRIMARY KEY(trainingTableKey, rowIndex) );''', ''' CREATE TABLE training_table( uniqueKey CHAR(8) PRIMARY KEY, name VARCHAR(50) NOT NULL, description VARCHAR(100) );''', ''' CREATE TABLE training_histories( uniqueKey CHAR(8) PRIMARY KEY, name VARCHAR(50) NOT NULL, description VARCHAR(100) NOT NULL, datetime VARCHAR(20) NOT NULL );''', ''' CREATE TABLE contractions( trainingHistoryKey CHAR(8) NOT NULL, rowIndex INT NOT NULL, time VARCHAR(5) NOT NULL, PRIMARY KEY(trainingHistoryKey, rowIndex) );''' ]; static Future<Database> database() async { final dbPath = await sql.getDatabasesPath(); return sql.openDatabase( path.join(dbPath, 'apnea.db'), onCreate: (db, version) async { for (int i = 0; i < createQueries.length; i++) { await db.execute(createQueries[i]); } }, version: versionNumber, ); } static Future<void> insert(String table, Map<String, dynamic> data) async { final db = await DBHelper.database(); db.insert( table, data, conflictAlgorithm: sql.ConflictAlgorithm.replace, ); } static Future<void> delete( String table, String identifier, String key) async { final db = await DBHelper.database(); db.delete(table, where: '$identifier = ?', whereArgs: [key]); } static Future<List<Map<String, dynamic>>> getData(String table) async { final db = await DBHelper.database(); return db.query(table); } static Future<List<Map>> getTableEntries(String tableKey) async { final db = await DBHelper.database(); return db.rawQuery( 'SELECT * FROM training_table_entry WHERE trainingTableKey = ? ORDER BY rowIndex ASC', [tableKey]); } static Future<List<Map>> getContractions(String historyKey) async { final db = await DBHelper.database(); return db.rawQuery( 'SELECT * FROM contractions WHERE trainingHistoryKey = ? ORDER BY rowIndex ASC', [historyKey]); } }
0
mirrored_repositories/flutter-apnea-app
mirrored_repositories/flutter-apnea-app/lib/main.dart
import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:firebase_admob/firebase_admob.dart'; import './screens/training_screen.dart'; import './screens/breath_hold_test_screen.dart'; import './screens/settings_screen.dart'; import './screens/breath_hold_test_history_screen.dart'; import './screens/customize_tables_screen.dart'; import './screens/training_table_detail_screen.dart'; import './screens/training_history_details_screen.dart'; import './screens/training_history_screen.dart'; import './providers/breath_hold_history_provider.dart'; import './providers/training_history_provider.dart'; import './providers/training_table_provider.dart'; void main() => runApp(MyApp()); MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( keywords: <String>['Apnea', 'Diving', 'Free Diving'], childDirected: false, testDevices: <String>[], ); BannerAd banner = BannerAd( adUnitId: Platform.isAndroid ? "ca-app-pub-3679599074148025/6323498522" : "ca-app-pub-3679599074148025/2986888747", size: AdSize.smartBanner, targetingInfo: targetingInfo, listener: (event) => print('BannerAd event is $event'), ); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); FirebaseAdMob.instance.initialize( appId: Platform.isAndroid ? "ca-app-pub-3679599074148025~5201988542" : "ca-app-pub-3679599074148025~7611447897", ); banner ..load() ..show(anchorType: AnchorType.bottom); return MultiProvider( providers: [ ChangeNotifierProvider.value( value: BreathHoldHistoryProvider(), ), ChangeNotifierProvider.value( value: TrainingHistoryProvider(), ), ChangeNotifierProvider.value( value: TrainingTableProvider(), ), ], child: MaterialApp( title: 'Apnea', theme: ThemeData( fontFamily: 'Libre Baskerville', primaryColor: Colors.white, appBarTheme: AppBarTheme( color: Colors.white60, elevation: 10, textTheme: TextTheme().copyWith( title: TextStyle( color: Theme.of(context).textTheme.button.color, fontFamily: 'Exo', fontSize: 22, ), ), ), ), home: TrainingScreen(), routes: { TrainingScreen.routeName: (ctx) => TrainingScreen(), BreathHoldTestScreen.routeName: (ctx) => BreathHoldTestScreen(), SettingsScreen.routeName: (ctx) => SettingsScreen(), BreathHoldTestHistoryScreen.routeName: (ctx) => BreathHoldTestHistoryScreen(), CustomizeTableScreen.routeName: (ctx) => CustomizeTableScreen(), TrainingTableDetailScreen.routeName: (ctx) => TrainingTableDetailScreen(), TrainingHistoryDetailsScreen.routeName: (ctx) => TrainingHistoryDetailsScreen(), TrainingHistoryScreen.routeName: (ctx) => TrainingHistoryScreen(), }, ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/widgets/inspire_button.dart
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:audioplayers/audio_cache.dart'; class InspireButton extends StatelessWidget { static const _clipCount = 9; final Random random = Random(DateTime.now().millisecondsSinceEpoch); final AudioCache audioCache = AudioCache(prefix: 'audio/inspire/'); @override Widget build(BuildContext context) { return IconButton( icon: Image.asset( 'assets/icons/inspire.png', color: Theme.of(context).iconTheme.color, ), onPressed: () => audioCache.play("${random.nextInt(_clipCount) + 1}.wav"), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/widgets/drawer_widget.dart
import 'package:flutter/material.dart'; import '../screens/breath_hold_test_screen.dart'; import '../screens/training_screen.dart'; import '../screens/settings_screen.dart'; class DrawerWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer( child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ AppBar( automaticallyImplyLeading: false, ), Divider(), DrawerItem( title: 'Apnea Training', icon: Image.asset( 'assets/icons/lungs.png', color: Theme.of(context).iconTheme.color, scale: 20.0, ), targetRoute: TrainingScreen.routeName, ), DrawerItem( title: 'Breath Hold Test', icon: Image.asset( 'assets/icons/breath_holding.png', color: Theme.of(context).iconTheme.color, scale: 20.0, ), targetRoute: BreathHoldTestScreen.routeName, ), DrawerItem( title: 'Settings', icon: Image.asset( 'assets/icons/settings.png', color: Theme.of(context).iconTheme.color, scale: 20.0, ), targetRoute: SettingsScreen.routeName, ), ], ), ), ); } } class DrawerItem extends StatelessWidget { final String title; final Widget icon; final String targetRoute; DrawerItem({ @required this.title, @required this.icon, @required this.targetRoute, }); @override Widget build(BuildContext context) { return ListTile( title: Text( title, style: TextStyle(fontSize: 18), ), leading: icon, onTap: () => Navigator.of(context).pushReplacementNamed(targetRoute), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/widgets/progress_bar.dart
import 'package:flutter/material.dart'; import 'package:flutter_animation_progress_bar/flutter_animation_progress_bar.dart'; class ProgressBar extends StatelessWidget { final double percentage; ProgressBar(this.percentage); @override Widget build(BuildContext context) { return Container( width: 300, child: FAProgressBar( currentValue: (100 * percentage).floor(), maxValue: 100, direction: Axis.horizontal, size: 10, progressColor: Theme.of(context).textTheme.title.color, backgroundColor: Colors.black12, ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/widgets/timer_view_widget.dart
import 'package:flutter/material.dart'; import '../models/minute_second.dart'; class TimerViewWidget extends StatelessWidget { final MinuteSecond currTime; TimerViewWidget(this.currTime); @override Widget build(BuildContext context) { return Container( width: 180, height: 80, child: Card( elevation: 5, shape: RoundedRectangleBorder( side: BorderSide( color: Theme.of(context).textTheme.button.color, width: 5, ), borderRadius: BorderRadius.circular(15), ), child: Center( child: Text( currTime == null ? '0:00' : currTime.toString(), textAlign: TextAlign.center, style: TextStyle( fontSize: 40, fontFamily: 'Exo', ), ), ), ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/widgets/control_button.dart
import 'package:flutter/material.dart'; class ControlButton extends StatelessWidget { ControlButton(this._iconPath, this._onPressed); final Function _onPressed; final String _iconPath; @override Widget build(BuildContext context) { return Container( height: 70, padding: const EdgeInsets.all(8.0), child: RaisedButton( shape: CircleBorder( side: BorderSide( width: 2, color: Theme.of(context).textTheme.button.color, ), ), color: Colors.white, child: Image.asset( _iconPath, scale: 15, color: Theme.of(context).iconTheme.color, ), onPressed: _onPressed, ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/models/minute_second.dart
import 'package:flutter/foundation.dart'; class MinuteSecond { int minute; int second; MinuteSecond({ @required this.minute, @required this.second, }); MinuteSecond.fromString(String str) { if (str == "null") { this.minute = -1; this.second = -1; return; } final List<String> splitted = str.split(':'); this.minute = int.parse(splitted[0]); this.second = int.parse(splitted[1]); } MinuteSecond.fromDuration(Duration duration) { final seconds = duration.inSeconds; this.minute = (seconds / Duration.secondsPerMinute).floor(); this.second = seconds % Duration.secondsPerMinute; } Duration toDuration() { return Duration(minutes: minute, seconds: second); } String toString() { return '$minute:' + '$second'.padLeft(2, '0'); } bool isNull() { return this.minute == -1 && this.second == -1; } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/models/breath_hold_history_data.dart
import 'package:flutter/material.dart'; import './minute_second.dart'; class BreathHoldHistoryData { final String key; final MinuteSecond holdDuration; final MinuteSecond firstContraction; final DateTime testDateTime; BreathHoldHistoryData({ @required this.key, @required this.holdDuration, @required this.firstContraction, @required this.testDateTime, }); }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/models/training_table.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import './minute_second.dart'; class TrainingTableEntry { final int index; final MinuteSecond holdTime; final MinuteSecond breatheTime; TrainingTableEntry({ @required this.index, @required this.holdTime, @required this.breatheTime, }); } class TrainingTable { String key; String name; String description; List<TrainingTableEntry> table; TrainingTable({ this.key = '', this.name = '', this.description = '', this.table, }); }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/models/training_history_data.dart
import 'package:flutter/material.dart'; import './training_table.dart'; import './minute_second.dart'; class TrainingHistoryData { final String key; final DateTime trainingDateTime; final String name; final String description; final List<TrainingTableEntry> table; final List<MinuteSecond> contractions; TrainingHistoryData({ @required this.key, @required this.table, @required this.contractions, @required this.trainingDateTime, @required this.description, @required this.name, }); }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/training_table_detail_screen.dart
import 'package:apnea/models/minute_second.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/training_table_provider.dart'; import '../models/training_table.dart'; class TrainingTableDetailScreen extends StatefulWidget { static const routeName = '/training-table-detail'; static const durationSelections = [ '0:30', '1:00', '1:30', '2:00', '2:30', '3:00', '3:30', '4:00', '4:30', '5:00', ]; @override _TrainingTableDetailScreenState createState() => _TrainingTableDetailScreenState(); } class _TrainingTableDetailScreenState extends State<TrainingTableDetailScreen> { static const _trainingTableRange = [3, 4, 5, 6]; final _form = GlobalKey<FormState>(); int _totalTableRows = 4; TrainingTable _editedForm; var _isInit = true; @override void didChangeDependencies() { if (_isInit) { final tableKey = ModalRoute.of(context).settings.arguments as String; if (tableKey != null) { _editedForm = Provider.of<TrainingTableProvider>(context, listen: false) .getTable(tableKey); } else { _editedForm = TrainingTable( key: UniqueKey().toString(), name: '', description: '', table: [ TrainingTableEntry( index: 0, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ), TrainingTableEntry( index: 1, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ), TrainingTableEntry( index: 2, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ) ], ); } _totalTableRows = _editedForm.table.length; } _isInit = false; super.didChangeDependencies(); } void _saveForm() { final isValid = _form.currentState.validate(); if (!isValid) return; _form.currentState.save(); // if (_editedForm.key != null) { // Provider.of<TrainingTableProvider>(context, listen: false) // .updateTable(_editedForm.key, _editedForm); // } else { // Provider.of<TrainingTableProvider>(context, listen: false) // .addTable(_editedForm); // } Provider.of<TrainingTableProvider>(context, listen: false) .addTable(_editedForm) .then((val) => Navigator.of(context).pop()); } void _tableChanged(List<List<String>> tableContent) { List<TrainingTableEntry> newTable = []; for (int i = 0; i < _totalTableRows; i++) { newTable.add( TrainingTableEntry( index: i, holdTime: MinuteSecond.fromString(tableContent[i][0]), breatheTime: MinuteSecond.fromString(tableContent[i][1]), ), ); } _editedForm.table = newTable; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(''), leading: IconButton( icon: Image.asset( 'assets/icons/back.png', color: Theme.of(context).iconTheme.color, ), color: Theme.of(context).errorColor, onPressed: () { showDialog( context: context, builder: (ctx) { return AlertDialog( title: const Text( 'Alert', style: TextStyle(fontWeight: FontWeight.w700), ), content: const Text('Exit without saving?'), actions: <Widget>[ FlatButton( child: Text( 'Continue Editing', style: TextStyle( color: Theme.of(context).textTheme.button.color, ), ), onPressed: () { Navigator.of(context).pop(); }, ), FlatButton( child: Text( 'Sure', style: TextStyle( color: Theme.of(context).errorColor, ), ), onPressed: () { Navigator.of(context).pop(); Navigator.of(context).pop(); }, ), ], ); }, ); }, ), actions: <Widget>[ IconButton( icon: Image.asset( 'assets/icons/check.png', color: Theme.of(context).iconTheme.color, ), onPressed: _saveForm, ), ], automaticallyImplyLeading: false, ), body: Form( key: _form, child: SingleChildScrollView( child: Column( children: <Widget>[ SizedBox(height: 30), Padding( padding: const EdgeInsets.symmetric( horizontal: 50.0, ), child: TextFormField( initialValue: _editedForm.name, maxLength: 30, maxLengthEnforced: true, decoration: InputDecoration( labelText: 'Training Session Name', ), textInputAction: TextInputAction.next, validator: (value) { if (value.isEmpty) { return 'Please enter a name.'; } return null; }, onSaved: (value) { _editedForm.name = value; }), ), SizedBox(height: 30), Padding( padding: const EdgeInsets.symmetric( horizontal: 50.0, ), child: TextFormField( initialValue: _editedForm.description, decoration: InputDecoration( labelText: 'Description', ), maxLines: 3, maxLength: 75, maxLengthEnforced: true, onSaved: (value) { _editedForm.description = value; }, ), ), SizedBox(height: 25), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const Text('Total Rounds: '), DropdownButton( value: _totalTableRows, items: _trainingTableRange.map((i) { return DropdownMenuItem(value: i, child: Text('$i')); }).toList(), onChanged: (val) { setState(() { _totalTableRows = val; _tableChanged([ ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ]); }); }, underline: DropdownButtonUnderline(), ), ], ), SizedBox(height: 25), TrainingTableInputWidget( _totalTableRows, _tableChanged, _editedForm.table, ), SizedBox(height: 100), ], ), ), ), ); } } class TrainingTableInputWidget extends StatefulWidget { final int _totalTableRows; final Function _dropdownChanged; final List<TrainingTableEntry> _existingTableRows; TrainingTableInputWidget( this._totalTableRows, this._dropdownChanged, this._existingTableRows); @override _TrainingTableInputWidgetState createState() => _TrainingTableInputWidgetState(); } class _TrainingTableInputWidgetState extends State<TrainingTableInputWidget> { List<List<String>> _tableContents = [ ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ['1:00', '1:00'], ]; @override void initState() { super.initState(); for (int i = 0; i < widget._existingTableRows.length; i++) { _tableContents[i][0] = widget._existingTableRows[i].holdTime.toString(); _tableContents[i][1] = widget._existingTableRows[i].breatheTime.toString(); } } void _onSelectionChanged(int index, int col, String value) { setState(() => _tableContents[index][col] = value); widget._dropdownChanged(_tableContents); } TableRow _buildTableRow(int index) { return TableRow( children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Text( '${index + 1}', textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ), DurationDropDownMenu( index, 0, _tableContents[index][0], _onSelectionChanged, ), DurationDropDownMenu( index, 1, _tableContents[index][1], _onSelectionChanged, ), ], ); } Widget _buildTableText(String text) { return Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( text, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ); } @override Widget build(BuildContext context) { return Container( width: 300, child: Table( defaultVerticalAlignment: TableCellVerticalAlignment.top, columnWidths: {0: FractionColumnWidth(0.1)}, children: <TableRow>[ TableRow( decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1))), children: <Widget>[ _buildTableText('#'), _buildTableText('Hold'), _buildTableText('Breathe'), ], ), ...List<TableRow>.generate( widget._totalTableRows, (i) { return _buildTableRow(i); }, ), ], ), ); } } class DurationDropDownMenu extends StatelessWidget { final int _index; final int _col; final String _selected; final Function _onSelectionChanged; DurationDropDownMenu( this._index, this._col, this._selected, this._onSelectionChanged, ); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: DropdownButton( value: _selected, items: TrainingTableDetailScreen.durationSelections.map((val) { return DropdownMenuItem(child: Text(val), value: val); }).toList(), onChanged: (val) => _onSelectionChanged(_index, _col, val), underline: DropdownButtonUnderline(), ), ); } } class DropdownButtonUnderline extends StatelessWidget { @override Widget build(BuildContext context) { return Container( height: 1.0, decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Theme.of(context).textTheme.title.color, width: 1.0, ), ), ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/training_history_details_screen.dart
import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../models/training_table.dart'; import '../providers/training_history_provider.dart'; class TrainingHistoryDetailsScreen extends StatelessWidget { static const routeName = '/training-history-details'; @override Widget build(BuildContext context) { final historyKey = ModalRoute.of(context).settings.arguments as String; final history = Provider.of<TrainingHistoryProvider>(context, listen: false) .getHistory(historyKey); final noDescription = (history.description == ""); final noContractions = history.contractions.isEmpty; return Scaffold( appBar: AppBar( title: Text(history.name), leading: IconButton( icon: Image.asset( 'assets/icons/back.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () => Navigator.of(context).pop(), ), ), body: Container( width: double.infinity, padding: const EdgeInsets.all(20.0), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text(DateFormat('yyyy-MM-dd HH:mm') .format(history.trainingDateTime)), SizedBox(height: 30), if (!noDescription) const Text( 'Training Description:', style: TextStyle( fontWeight: FontWeight.w700, fontSize: 20, ), ), if (!noDescription) SizedBox(height: 20), if (!noDescription) Text(history.description), if (!noDescription) SizedBox(height: 30), if (!noContractions) const Text( 'Diaphragm Contractions:', style: TextStyle( fontWeight: FontWeight.w700, fontSize: 20, ), ), if (!noContractions) SizedBox(height: 20), if (!noContractions) ...List<Column>.generate(history.contractions.length, (i) { return Column( children: <Widget>[ Text( '${i + 1}. Starts at: ${history.contractions[i].toString()}', ), SizedBox(height: 10), ], ); }).toList(), SizedBox(height: 30), TableWidget(table: history.table), ], ), ), ), ); } } class TableWidget extends StatelessWidget { final List<TrainingTableEntry> table; TableWidget({this.table}); TableRow _buildTableRow(String index, String holdTime, String breathTime, {bool isTitle = false, BuildContext context}) { return TableRow( decoration: isTitle ? BoxDecoration( border: Border( bottom: BorderSide( width: 1, color: Theme.of(context).textTheme.body1.color))) : BoxDecoration(), children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( index, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( holdTime, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( breathTime, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ), ], ); } @override Widget build(BuildContext context) { return Container( width: 300, height: 300, child: Table( defaultVerticalAlignment: TableCellVerticalAlignment.top, columnWidths: { 0: FractionColumnWidth(0.15), }, children: <TableRow>[ _buildTableRow('#', 'Hold', 'Breathe', isTitle: true, context: context), ...List<TableRow>.generate(table.length, (i) { return _buildTableRow( '${i + 1}', table[i].holdTime.toString(), table[i].breatheTime.toString(), context: context, ); }).toList(), ], ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/breath_hold_test_screen.dart
import 'dart:async'; import 'package:apnea/widgets/inspire_button.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/breath_hold_history_provider.dart'; import '../models/minute_second.dart'; import '../models/breath_hold_history_data.dart'; import '../widgets/control_button.dart'; import '../widgets/timer_view_widget.dart'; import '../widgets/drawer_widget.dart'; import './breath_hold_test_history_screen.dart'; class BreathHoldTestScreen extends StatefulWidget { static const routeName = '/breath-hold-test'; static const instructions = ''' Instructions: 1. Lay on your comfy bed! 2. Breathe slowly for 2 minutes! 3. Take a DEEP breath in and exhale the hell out of it! 4. Take an extremely DEEEEP breath in and HOLD! 5. Press the play button! 6. Tap the Lungs button when you feel diaphragm contractions! Congrats on that by the way! 7. If you can't hold the beast in anymore, press the stop button, exhale and adjust your breath for a couple of minutes! The app creator won't be held responsible if you suffocate and die! So take care of your own health conditions!'''; @override _BreathHoldTestScreenState createState() => _BreathHoldTestScreenState(); } class _BreathHoldTestScreenState extends State<BreathHoldTestScreen> { static const _timerDelay = Duration(microseconds: 1); Timer _timer; MinuteSecond _contractionTime; MinuteSecond _currTime; Stopwatch _stopwatch = Stopwatch(); void _startWatch() { _stopwatch.start(); } void _completeSession() { _stopwatch ..stop() ..reset(); showDialog( context: context, builder: (ctx) { return AlertDialog( title: const Text( 'Complete!', style: const TextStyle(fontWeight: FontWeight.w700), ), content: const Text('Save this session?'), actions: <Widget>[ FlatButton( child: Text( 'Don\'t Save', style: TextStyle( color: Theme.of(context).errorColor, ), ), onPressed: () { Navigator.of(context).pop(); }, ), FlatButton( child: Text( 'Save', style: TextStyle( color: Theme.of(context).textTheme.button.color, ), ), onPressed: () { final history = BreathHoldHistoryData( key: UniqueKey().toString(), firstContraction: _contractionTime, holdDuration: _currTime, testDateTime: DateTime.now(), ); Provider.of<BreathHoldHistoryProvider>(context) .addHistory(history) .then((_) { Navigator.of(context).pop(); }); }, ), ], ); }, ).then((_) { setState(() { _currTime = null; _contractionTime = null; }); }); } void _recordContractionTime() { _contractionTime = _currTime; } void _update() { if (_stopwatch.isRunning) { setState(() => _currTime = MinuteSecond.fromDuration(_stopwatch.elapsed)); } } @override void initState() { super.initState(); _timer = Timer.periodic(_timerDelay, (Timer t) => _update()); } @override void dispose() { _timer.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Breath Hold Test'), actions: _stopwatch.isRunning ? [] : <Widget>[ IconButton( icon: Image.asset( 'assets/icons/history.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () { Navigator.of(context) .pushNamed(BreathHoldTestHistoryScreen.routeName); }, ), ], ), drawer: _stopwatch.isRunning ? null : DrawerWidget(), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ SizedBox(height: 20), Text( _stopwatch.isRunning ? 'Hold' : 'Prepare', textAlign: TextAlign.center, style: TextStyle(fontSize: 30), ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ IconButton( icon: Image.asset( 'assets/icons/lungs.png', color: Theme.of(context).iconTheme.color, ), onPressed: _contractionTime == null && _stopwatch.isRunning ? _recordContractionTime : null, ), SizedBox(width: 30), Container( width: 70, height: 70, decoration: BoxDecoration( border: Border.all( color: Theme.of(context).textTheme.title.color, width: 3, ), borderRadius: BorderRadius.all(Radius.circular(50)), ), child: CircleAvatar( backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: Image.asset( _stopwatch.isRunning ? 'assets/images/hold.png' : 'assets/images/prepare.png', color: Theme.of(context).textTheme.title.color, ), ), ), SizedBox(width: 30), InspireButton(), ], ), SizedBox(height: 10), TimerViewWidget(_currTime), Padding( padding: const EdgeInsets.only(top: 10), child: _contractionTime == null ? Container() : Text( 'Contraction started at ${_contractionTime.toString()}.', ), ), SizedBox(height: 10), _stopwatch.isRunning ? ControlButton('assets/icons/check.png', _completeSession) : ControlButton('assets/icons/play.png', _startWatch), SizedBox(height: 20), Container( width: 300, height: 300, child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), side: BorderSide( width: 2, color: Theme.of(context).textTheme.title.color, ), ), child: SingleChildScrollView( padding: const EdgeInsets.all(15), child: Text( BreathHoldTestScreen.instructions, style: const TextStyle( fontFamily: 'Delius Unicase', fontWeight: FontWeight.w700, fontSize: 15), ), ), ), ), SizedBox(height: 30), ], ), ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/training_screen.dart
import 'dart:async'; import 'package:audioplayers/audio_cache.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../models/training_table.dart'; import '../models/minute_second.dart'; import '../models/training_history_data.dart'; import '../widgets/control_button.dart'; import '../widgets/progress_bar.dart'; import '../widgets/timer_view_widget.dart'; import '../widgets/drawer_widget.dart'; import './customize_tables_screen.dart'; import './training_history_screen.dart'; import '../providers/training_table_provider.dart'; import '../providers/training_history_provider.dart'; import '../widgets/inspire_button.dart'; class TrainingScreen extends StatefulWidget { static const routeName = '/training'; final AudioCache audioCache = AudioCache(prefix: 'audio/'); @override _TrainingScreenState createState() => _TrainingScreenState(); } class _TrainingScreenState extends State<TrainingScreen> { static const _timerDelay = Duration(microseconds: 1); static const _prepareTime = Duration(seconds: 5); TrainingTable _currTable = TrainingTableProvider.defaultTable; int _currRow = -1; int _currCol = 1; Timer _timer; Stopwatch _stopwatch = Stopwatch(); Duration _stopwatchGoal; MinuteSecond _timeLeft; Future<void> fetchFuture; bool _paused = false; MinuteSecond _contractionTime; List<MinuteSecond> _allContractionTimes; void _startTimer() { widget.audioCache.play('prepare.wav'); _currRow = -1; _currCol = 1; _allContractionTimes = []; _stopwatchGoal = _prepareTime; _stopwatch.start(); } void _pauseTimer() { widget.audioCache.play('paused.wav'); _paused = true; _stopwatch.stop(); } void _resumeTimer() { widget.audioCache.play('resumed.wav'); _paused = false; _stopwatch.start(); } void _configureStopwatchAndStart() { final MinuteSecond goal = _currCol == 0 ? _currTable.table[_currRow].holdTime : _currTable.table[_currRow].breatheTime; widget.audioCache.play(_currCol == 0 ? 'hold.wav' : 'breathe.wav'); _stopwatchGoal = Duration(minutes: goal.minute, seconds: goal.second); _stopwatch.start(); } void _recordContractionTime() { _contractionTime = MinuteSecond.fromDuration(_stopwatchGoal - _timeLeft.toDuration()); _allContractionTimes.add(_contractionTime); } void _stopwatchCompleted() { if (_currCol == 0) { setState(() { ++_currCol; _contractionTime = null; _configureStopwatchAndStart(); }); } else if (_currRow + 1 < _currTable.table.length) { setState(() { _currCol = 0; ++_currRow; _configureStopwatchAndStart(); }); } else { _terminateSession(); widget.audioCache.play('session_complete.wav'); showDialog( context: context, builder: (ctx) { return AlertDialog( title: const Text( 'Good Job!', style: TextStyle(fontWeight: FontWeight.w700), ), content: const Text('The session has completed!'), actions: <Widget>[ FlatButton( child: Text( 'OK!', style: TextStyle( color: Theme.of(context).textTheme.button.color, ), ), onPressed: () { final history = TrainingHistoryData( key: UniqueKey().toString(), name: _currTable.name, description: _currTable.description, table: _currTable.table, trainingDateTime: DateTime.now(), contractions: _allContractionTimes, ); Provider.of<TrainingHistoryProvider>(context, listen: false) .addHistory(history) .then((_) => Navigator.of(context).pop()); }, ) ], ); }, ); } } void _terminateSession() { _stopwatch ..stop() ..reset(); setState(() { _timeLeft = null; _currRow = -1; _contractionTime = null; }); } void _update() { if (_stopwatch.isRunning) { if (_stopwatch.elapsed > _stopwatchGoal) { _stopwatch ..stop() ..reset(); setState(() => _timeLeft = MinuteSecond(minute: 0, second: 0)); _stopwatchCompleted(); } else { setState(() { _timeLeft = MinuteSecond.fromDuration(_stopwatchGoal - _stopwatch.elapsed); }); } } } @override void initState() { super.initState(); // Load audio. widget.audioCache.loadAll([ 'prepare.wav', 'breathe.wav', 'hold.wav', 'paused.wav', 'resumed.wav', 'session_complete.wav', ]); fetchFuture = Provider.of<TrainingTableProvider>(context, listen: false) .fetchAndSetTable(); _timer = Timer.periodic(_timerDelay, (Timer t) => _update()); } @override void dispose() { _timer.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Container( alignment: Alignment.center, child: const Text( 'Apnea Training', textAlign: TextAlign.center, ), ), actions: (_paused || _stopwatch.isRunning) ? [] : <Widget>[ IconButton( icon: Image.asset('assets/icons/settings.png', color: Theme.of(context).primaryIconTheme.color), onPressed: () { Navigator.of(context) .pushNamed(CustomizeTableScreen.routeName); }, ), IconButton( icon: Image.asset('assets/icons/history.png', color: Theme.of(context).primaryIconTheme.color), onPressed: () { Navigator.of(context) .pushNamed(TrainingHistoryScreen.routeName); }, ), ], ), drawer: (_paused || _stopwatch.isRunning) ? null : DrawerWidget(), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SizedBox(height: 20), Text( _paused ? 'Paused' : (_currRow < 0 ? 'Prepare' : (_currCol == 0 ? 'Hold' : 'Breathe')), textAlign: TextAlign.center, style: TextStyle(fontSize: 30), ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ IconButton( icon: Image.asset( 'assets/icons/lungs.png', color: Theme.of(context).iconTheme.color, ), onPressed: !_paused && (_contractionTime == null) && _currRow >= 0 && _currCol == 0 && _stopwatch.isRunning ? _recordContractionTime : null, ), SizedBox(width: 30), Container( width: 70, height: 70, decoration: BoxDecoration( border: Border.all( color: Theme.of(context).textTheme.title.color, width: 3, ), borderRadius: BorderRadius.all(Radius.circular(50)), ), child: CircleAvatar( backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: Image.asset( !_stopwatch.isRunning || _currRow == -1 ? 'assets/images/prepare.png' : (_currCol == 0 ? 'assets/images/hold.png' : 'assets/images/breathe.png'), color: Theme.of(context).textTheme.title.color, ), ), ), SizedBox(width: 30), InspireButton(), ], ), SizedBox(height: 10), TimerViewWidget(_timeLeft), Padding( padding: const EdgeInsets.only(top: 10), child: _contractionTime == null ? Container() : Text( 'Contraction started at ${_contractionTime.toString()}.', ), ), SizedBox(height: 10), _timeLeft == null ? ProgressBar(1.0) : ProgressBar(_timeLeft.toDuration().inMilliseconds / _stopwatchGoal.inMilliseconds), SizedBox(height: 20), _stopwatch.isRunning ? Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ControlButton('assets/icons/pause.png', _pauseTimer), ControlButton('assets/icons/stop.png', _terminateSession), ], ) : ControlButton('assets/icons/play.png', _paused ? _resumeTimer : _startTimer), FutureBuilder( future: fetchFuture, builder: (ctx, snapshot) => snapshot.connectionState == ConnectionState.waiting ? Center(child: CircularProgressIndicator()) : Consumer<TrainingTableProvider>( builder: (ctx, provider, ch) { _currTable = provider.getTable(_currTable.key); return (_paused || _stopwatch.isRunning) ? SizedBox(height: 15) : DropdownButton( value: _currTable.key, underline: Container( height: 1.0, decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Theme.of(context) .textTheme .title .color, width: 1.2, ), ), ), ), items: List<DropdownMenuItem>.generate( provider.tables.length, (i) { final table = provider.tables[i]; return DropdownMenuItem( child: Text(table.name), value: table.key, ); }, ).toList(), onChanged: (val) { setState(() => _currTable = provider.getTable(val)); }, ); }, ), ), SizedBox(height: 20), TrainingTableWidget(_currTable, _currRow, _currCol), SizedBox(height: 80), ], ), ), ); } } class TrainingTableWidget extends StatelessWidget { final TrainingTable _currTable; final int _currRow; final int _currCol; TrainingTableWidget(this._currTable, this._currRow, this._currCol); TableRow _buildTableRow(String index, String holdTime, String breatheTime, {bool isTitle = false, BuildContext context}) { return TableRow( decoration: isTitle ? BoxDecoration( border: Border( bottom: BorderSide( width: 1, color: Theme.of(context).textTheme.body1.color))) : BoxDecoration(), children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( index, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( holdTime, textAlign: TextAlign.center, style: TextStyle( fontSize: 20, color: (!isTitle && _currRow >= 0 && _currRow == int.parse(index) - 1 && _currCol == 0) ? Colors.lightBlue : Theme.of(context).textTheme.title.color, ), ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 3.0), child: Text( breatheTime, textAlign: TextAlign.center, style: TextStyle( fontSize: 20, color: (!isTitle && _currRow >= 0 && _currRow == int.parse(index) - 1 && _currCol == 1) ? Colors.lightBlue : Theme.of(context).textTheme.title.color, ), ), ), ], ); } @override Widget build(BuildContext context) { return Container( width: 300, height: 300, child: Table( defaultVerticalAlignment: TableCellVerticalAlignment.top, columnWidths: { 0: FractionColumnWidth(0.15), }, children: <TableRow>[ _buildTableRow('#', 'Hold', 'Breathe', isTitle: true, context: context), ...List<TableRow>.generate( _currTable.table.length, (i) { return _buildTableRow( '${i + 1}', _currTable.table[i].holdTime.toString(), _currTable.table[i].breatheTime.toString(), context: context, ); }, ).toList(), ], ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/breath_hold_test_history_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl.dart'; import '../providers/breath_hold_history_provider.dart'; class BreathHoldTestHistoryScreen extends StatelessWidget { static const routeName = '/breath-hold-test-history'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Image.asset( 'assets/icons/back.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () => Navigator.of(context).pop(), ), title: const Text('Breath Hold History'), ), body: FutureBuilder( future: Provider.of<BreathHoldHistoryProvider>(context, listen: false) .fetchAndSetHistory(), builder: (ctx, snapshot) => snapshot.connectionState == ConnectionState.waiting ? Center(child: CircularProgressIndicator()) : Consumer<BreathHoldHistoryProvider>( builder: (ctx, provider, ch) { return Padding( padding: const EdgeInsets.only(top: 15, bottom: 80), child: ListView( children: List<Column>.generate( provider.historiesLength, (i) { final history = provider.histories[i]; return Column( children: <Widget>[ Dismissible( key: Key(history.key), background: Container( color: Theme.of(context).errorColor, child: Image.asset( 'assets/icons/delete.png', scale: 20, ), alignment: Alignment.centerRight, padding: const EdgeInsets.only(right: 20), ), direction: DismissDirection.endToStart, confirmDismiss: (direction) { return showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text( 'Alert', style: TextStyle( fontWeight: FontWeight.w700), ), content: const Text( 'Sure you want to delete this?'), actions: <Widget>[ FlatButton( child: Text('Don\'t Delete', style: TextStyle( color: Theme.of(context) .textTheme .button .color)), onPressed: () => Navigator.of(ctx).pop(false), ), FlatButton( child: Text('Sure', style: TextStyle( color: Theme.of(context) .errorColor)), onPressed: () => Navigator.of(ctx).pop(true), ), ], ), ); }, onDismissed: (direction) => provider.deleteHistory(history.key), child: ListTile( key: Key(history.key), title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( DateFormat('yyyy-MM-dd HH:mm') .format(history.testDateTime), style: const TextStyle( fontFamily: 'Exo', fontSize: 18, ), ), if (!history.firstContraction.isNull()) const SizedBox(height: 10), if (!history.firstContraction.isNull()) Text( 'Diaphragm contraction started at ${history.firstContraction.toString()}.'), const SizedBox(height: 10), Text( 'Breath held for ${history.holdDuration.toString()}.', style: const TextStyle(fontSize: 18), ), ], ), ), ), Divider(), ], ); }, ), ), ); }, ), ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/customize_tables_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import './training_table_detail_screen.dart'; import '../providers/training_table_provider.dart'; class CustomizeTableScreen extends StatelessWidget { static const routeName = '/customize-table'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Image.asset( 'assets/icons/back.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () { Navigator.of(context).pop(); }, ), title: const Text('Training Tables'), actions: <Widget>[ IconButton( icon: Image.asset( 'assets/icons/add.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () { Navigator.of(context) .pushNamed(TrainingTableDetailScreen.routeName); }, ), ], ), body: FutureBuilder( future: Provider.of<TrainingTableProvider>(context, listen: false) .fetchAndSetTable(), builder: (ctx, snapshot) => snapshot.connectionState == ConnectionState.waiting ? Center( child: CircularProgressIndicator(), ) : Consumer<TrainingTableProvider>( builder: (ctx, provider, ch) { return Padding( padding: const EdgeInsets.only(top: 15, bottom: 80), child: ListView( children: List<Column>.generate(provider.tablesLength, (i) { final table = provider.tables[i]; return table == TrainingTableProvider.defaultTable ? Column() : Column( children: <Widget>[ Dismissible( key: Key(table.key), background: Container( color: Theme.of(context).errorColor, child: Image.asset( 'assets/icons/delete.png', scale: 20, ), alignment: Alignment.centerRight, padding: const EdgeInsets.only(right: 20), ), direction: DismissDirection.endToStart, confirmDismiss: (direction) { return showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text('Alert', style: TextStyle( fontWeight: FontWeight.w700)), content: const Text( 'Sure you want to delete this?'), actions: <Widget>[ FlatButton( child: Text('Don\'t Delete', style: TextStyle( color: Theme.of(context) .textTheme .button .color)), onPressed: () => Navigator.of(ctx).pop(false), ), FlatButton( child: Text('Sure', style: TextStyle( color: Theme.of(context) .errorColor)), onPressed: () => Navigator.of(ctx).pop(true), ), ], ), ); }, onDismissed: (direction) => provider.deleteTable(table.key), child: ListTile( key: Key(table.key), title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( table.name, style: const TextStyle( fontFamily: 'Exo', fontSize: 18, ), ), const SizedBox(height: 5), Text( table.description, style: const TextStyle(fontSize: 14), ) ], ), onTap: () { Navigator.of(context).pushNamed( TrainingTableDetailScreen.routeName, arguments: table.key, ); }, ), ), Divider(), ], ); }), ), ); }, ), ), ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/settings_screen.dart
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import '../widgets/drawer_widget.dart'; class SettingsScreen extends StatelessWidget { static const routeName = '/settings-screen'; Future<void> _launchURL(String url) async { if (await canLaunch(url)) { await launch(url); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Settings'), ), drawer: DrawerWidget(), body: ListView( children: <Widget>[ const SizedBox(height: 10), SettingsListTile( title: 'Support Website', tapAction: () => _launchURL('http://shinerightstudio.com/apnea-app'), ), ListTile( title: const Text( 'Version: 1.0', textAlign: TextAlign.center, style: TextStyle(color: Colors.grey), ), ), ], ), ); } } class SettingsListTile extends StatelessWidget { final String title; final Widget trailing; final Function tapAction; SettingsListTile({@required this.title, this.trailing, this.tapAction}); @override Widget build(BuildContext context) { return Column( children: <Widget>[ ListTile( title: Text(title, style: TextStyle(fontSize: 18)), trailing: trailing, onTap: tapAction, ), Divider(), ], ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/screens/training_history_screen.dart
import 'package:provider/provider.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../providers/training_history_provider.dart'; import './training_history_details_screen.dart'; class TrainingHistoryScreen extends StatelessWidget { static const routeName = '/training-history'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Image.asset( 'assets/icons/back.png', color: Theme.of(context).primaryIconTheme.color, ), onPressed: () => Navigator.of(context).pop(), ), title: const Text('Training History'), ), body: FutureBuilder( future: Provider.of<TrainingHistoryProvider>(context, listen: false) .fetchAndSetHistories(), builder: (ctx, snapshot) => snapshot.connectionState == ConnectionState.waiting ? Center( child: CircularProgressIndicator(), ) : Consumer<TrainingHistoryProvider>( builder: (ctx, provider, ch) { return Padding( padding: const EdgeInsets.only(top: 15), child: ListView( children: List<Column>.generate(provider.historiesLength, (i) { final history = provider.histories[i]; return Column( children: <Widget>[ Dismissible( key: Key(history.key), background: Container( color: Theme.of(context).errorColor, child: Image.asset( 'assets/icons/delete.png', scale: 20, ), alignment: Alignment.centerRight, padding: const EdgeInsets.only(right: 20), ), direction: DismissDirection.endToStart, confirmDismiss: (direction) { return showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text( 'Alert', style: TextStyle( fontWeight: FontWeight.w700), ), content: const Text( 'Sure you want to delete this?'), actions: <Widget>[ FlatButton( child: Text('Don\'t Delete', style: TextStyle( color: Theme.of(context) .textTheme .button .color)), onPressed: () => Navigator.of(ctx).pop(false), ), FlatButton( child: Text('Sure', style: TextStyle( color: Theme.of(context) .errorColor)), onPressed: () => Navigator.of(ctx).pop(true), ), ], ), ); }, onDismissed: (direction) => provider.deleteHistory(history.key), child: ListTile( key: Key(history.key), title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( history.name, style: const TextStyle( fontFamily: 'Exo', fontSize: 18, ), ), const SizedBox(height: 5), Text( DateFormat('yyyy-MM-dd HH:mm') .format(history.trainingDateTime), style: const TextStyle(fontSize: 14), ) ], ), onTap: () { Navigator.of(context).pushNamed( TrainingHistoryDetailsScreen.routeName, arguments: history.key, ); }, ), ), Divider(), ], ); }), ), ); }, ), ), ); } } class TrainingHistoryTile extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: <Widget>[ ListTile( title: Text('temp'), onTap: () { Navigator.of(context) .pushNamed(TrainingHistoryDetailsScreen.routeName); }, ), Divider(), ], ); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/providers/breath_hold_history_provider.dart
import 'package:apnea/models/minute_second.dart'; import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import '../db_helper.dart'; import '../models/breath_hold_history_data.dart'; class BreathHoldHistoryProvider with ChangeNotifier { List<BreathHoldHistoryData> _histories = []; List<BreathHoldHistoryData> get histories { return [..._histories]; } int get historiesLength { return _histories.length; } Future<void> addHistory(BreathHoldHistoryData data) async { await DBHelper.insert('breath_hold_histories', { 'uniqueKey': data.key, 'datetime': DateFormat('yyyy-MM-dd HH:mm').format(data.testDateTime), 'firstContraction': data.firstContraction.toString(), 'duration': data.holdDuration.toString() }); } Future<void> fetchAndSetHistory() async { List<BreathHoldHistoryData> newHistories = []; final historyList = await DBHelper.getData('breath_hold_histories'); for (int i = 0; i < historyList.length; i++) { BreathHoldHistoryData currHistory = BreathHoldHistoryData( key: historyList[i]['uniqueKey'], testDateTime: DateFormat('yyyy-MM-dd HH:mm').parse(historyList[i]['datetime']), firstContraction: MinuteSecond.fromString(historyList[i]['firstContraction']), holdDuration: MinuteSecond.fromString(historyList[i]['duration']), ); newHistories.add(currHistory); } newHistories .sort((lhs, rhs) => lhs.testDateTime.compareTo(rhs.testDateTime)); _histories = newHistories; notifyListeners(); } Future<void> deleteHistory(String key) async { await DBHelper.delete('breath_hold_histories', 'uniqueKey', key); _histories.removeWhere((history) => history.key == key); notifyListeners(); } BreathHoldHistoryData getHistory(String key) { return _histories.firstWhere((h) => h.key == key); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/providers/training_history_provider.dart
import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import '../db_helper.dart'; import '../models/training_history_data.dart'; import '../models/minute_second.dart'; import '../models/training_table.dart'; class TrainingHistoryProvider with ChangeNotifier { List<TrainingHistoryData> _histories = []; List<TrainingHistoryData> get histories { return [..._histories]; } int get historiesLength { return _histories.length; } Future<void> addHistory(TrainingHistoryData history) async { await DBHelper.insert('training_histories', { 'uniqueKey': history.key, 'name': history.name, 'description': history.description, 'datetime': DateFormat('yyyy-MM-dd HH:mm').format(history.trainingDateTime), }); print(history.contractions.length); for (int i = 0; i < history.contractions.length; i++) { await DBHelper.insert('contractions', { 'trainingHistoryKey': history.key, 'rowIndex': i, 'time': history.contractions[i].toString(), }); } for (int i = 0; i < history.table.length; i++) { await DBHelper.insert('training_table_entry', { 'trainingTableKey': history.key, 'rowIndex': i, 'holdTime': history.table[i].holdTime.toString(), 'breatheTime': history.table[i].breatheTime.toString(), }); } } Future<void> fetchAndSetHistories() async { var newHistories = <TrainingHistoryData>[]; final historyList = await DBHelper.getData('training_histories'); for (int i = 0; i < historyList.length; i++) { var currHistory = TrainingHistoryData( key: historyList[i]['uniqueKey'], name: historyList[i]['name'], description: historyList[i]['description'], trainingDateTime: DateFormat('yyyy-MM-dd HH:mm').parse(historyList[i]['datetime']), table: [], contractions: [], ); final entryList = await DBHelper.getTableEntries(currHistory.key); for (int row = 0; row < entryList.length; row++) { final holdTime = MinuteSecond.fromString(entryList[row]['holdTime']); final breatheTime = MinuteSecond.fromString(entryList[row]['breatheTime']); currHistory.table.add(TrainingTableEntry( index: row, holdTime: holdTime, breatheTime: breatheTime, )); } final contractionList = await DBHelper.getContractions(currHistory.key); for (int row = 0; row < contractionList.length; row++) { currHistory.contractions .add(MinuteSecond.fromString(contractionList[row]['time'])); } newHistories.add(currHistory); } newHistories.sort( (lhs, rhs) => lhs.trainingDateTime.compareTo(rhs.trainingDateTime)); _histories = newHistories; notifyListeners(); } void deleteHistory(String key) async { await DBHelper.delete('training_table_entry', 'trainingTableKey', key); await DBHelper.delete('history_table', 'uniqueKey', key); _histories.removeWhere((history) => history.key == key); notifyListeners(); } TrainingHistoryData getHistory(String key) { return _histories.firstWhere((h) => h.key == key, orElse: () => null); } }
0
mirrored_repositories/flutter-apnea-app/lib
mirrored_repositories/flutter-apnea-app/lib/providers/training_table_provider.dart
import 'package:flutter/material.dart'; import '../models/minute_second.dart'; import '../db_helper.dart'; import '../models/training_table.dart'; class TrainingTableProvider with ChangeNotifier { static final defaultTable = TrainingTable( key: '#[00000]', name: ' Default Training', description: '', table: <TrainingTableEntry>[ TrainingTableEntry( index: 0, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ), TrainingTableEntry( index: 1, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ), TrainingTableEntry( index: 2, holdTime: MinuteSecond.fromString('1:00'), breatheTime: MinuteSecond.fromString('1:00'), ), ], ); List<TrainingTable> _tables = [defaultTable]; List<TrainingTable> get tables { return [..._tables]; } int get tablesLength { return _tables.length; } Future<void> addTable(TrainingTable table) async { await DBHelper.insert('training_table', { 'uniqueKey': table.key, 'name': table.name, 'description': table.description, }); for (int i = 0; i < table.table.length; i++) { await DBHelper.insert('training_table_entry', { 'trainingTableKey': table.key, 'rowIndex': i, 'holdTime': table.table[i].holdTime.toString(), 'breatheTime': table.table[i].breatheTime.toString(), }); } } Future<void> fetchAndSetTable() async { var newTables = [defaultTable]; final tableList = await DBHelper.getData('training_table'); for (int i = 0; i < tableList.length; i++) { TrainingTable currTable = TrainingTable( key: tableList[i]['uniqueKey'], name: tableList[i]['name'], description: tableList[i]['description'], table: [], ); final entryList = await DBHelper.getTableEntries(currTable.key); for (int row = 0; row < entryList.length; row++) { final holdTime = MinuteSecond.fromString(entryList[row]['holdTime']); final breatheTime = MinuteSecond.fromString(entryList[row]['breatheTime']); currTable.table.add( TrainingTableEntry( index: row, holdTime: holdTime, breatheTime: breatheTime, ), ); } newTables.add(currTable); } newTables.sort((lhs, rhs) => lhs.name.compareTo(rhs.name)); _tables = newTables; notifyListeners(); } void deleteTable(String key) async { await DBHelper.delete('training_table_entry', 'trainingTableKey', key); await DBHelper.delete('training_table', 'uniqueKey', key); _tables.removeWhere((table) => table.key == key); notifyListeners(); } // void updateTable(String key, TrainingTable table) { // final tableIndex = _tables.indexWhere((t) => t.key == key); // _tables[tableIndex] = table; // notifyListeners(); // } TrainingTable getTable(String key) { return _tables.firstWhere((t) => t.key == key, orElse: () => null); } }
0
mirrored_repositories/flutter-apnea-app
mirrored_repositories/flutter-apnea-app/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:apnea/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/freebox
mirrored_repositories/freebox/lib/main_prod.dart
import 'package:flutter/material.dart'; import 'package:freebox/configs/app_config.dart'; import 'package:provider/provider.dart'; import 'widgets/my_app.dart'; void main() => runApp( Provider( create: (_) => AppConfig.prod(), child: MyApp(), ), );
0
mirrored_repositories/freebox
mirrored_repositories/freebox/lib/main_dev.dart
import 'package:flutter/material.dart'; import 'package:freebox/widgets/my_app.dart'; import 'package:provider/provider.dart'; import 'configs/app_config.dart'; void main() => runApp( Provider( create: (_) => AppConfig.dev(), child: MyApp(), ), );
0
mirrored_repositories/freebox
mirrored_repositories/freebox/lib/localizations.dart
// GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: prefer_final_fields, public_member_api_docs, prefer_single_quotes, omit_local_variable_types, unnecessary_this import 'dart:async'; import 'package:flutter/material.dart'; /// A class generated by flappy_translator package containing localized strings class AppLocalizations { static String get appTitle => _getText('appTitle'); static String get onboardingWelcomeHeadline => _getText('onboardingWelcomeHeadline'); static String get onboardingPageOneDescription => _getText('onboardingPageOneDescription'); static String get onboardingPageTwoDescription => _getText('onboardingPageTwoDescription'); static String get onboardingPageTwoButtonLabel => _getText('onboardingPageTwoButtonLabel'); static String get bottomNavigationBarFreeboxes => _getText('bottomNavigationBarFreeboxes'); static String get bottomNavigationBarMap => _getText('bottomNavigationBarMap'); static Map<String, String> _localizedValues; static Map<String, String> _enValues = { 'appTitle': 'My awesome application', 'onboardingWelcomeHeadline': 'Welcome to Freebox', 'onboardingPageOneDescription': 'In this app you can upload the content of your freebox and share it with others.', 'onboardingPageTwoDescription': 'You can also search for freebox locations close to where you currently are.', 'onboardingPageTwoButtonLabel': 'Get Started!', 'bottomNavigationBarFreeboxes': 'Freeboxes', 'bottomNavigationBarMap': 'Map', }; static Map<String, String> _deValues = { 'appTitle': 'Meine tolle App', 'onboardingWelcomeHeadline': 'Welcome to Freebox', 'onboardingPageOneDescription': 'In this app you can upload the content of your freebox for free ans share it with others.', 'onboardingPageTwoDescription': 'You can also search for freebox locations close to where you currently are. ', 'onboardingPageTwoButtonLabel': 'Los geht\'s!', 'bottomNavigationBarFreeboxes': 'Freeboxes', 'bottomNavigationBarMap': 'Karte', }; static Map<String, Map<String, String>> _allValues = { 'en': _enValues, 'de': _deValues, }; AppLocalizations(Locale locale) { _locale = locale; _localizedValues = null; } static Locale _locale; static String _getText(String key) { return _localizedValues[key] ?? '** $key not found'; } static Locale get currentLocale => _locale; static String get currentLanguage => _locale.languageCode; static Future<AppLocalizations> load(Locale locale) async { final translations = AppLocalizations(locale); _localizedValues = _allValues[locale.toString()]; return translations; } } class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> { const AppLocalizationsDelegate(); static final Set<Locale> supportedLocals = { Locale('en'), Locale('de'), }; @override bool isSupported(Locale locale) => supportedLocals.contains(locale); @override Future<AppLocalizations> load(Locale locale) => AppLocalizations.load(locale); @override bool shouldReload(AppLocalizationsDelegate old) => false; }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/widgets/my_app.dart
import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:freebox/configs/app_colors.dart'; import 'package:freebox/configs/route_names.dart'; import 'package:freebox/localizations.dart'; import 'package:freebox/modules/analytics/analytics.dart'; import 'package:freebox/modules/backend_service/bacend_service.dart'; import 'package:freebox/modules/onboarding/widgets/onboarding.dart'; import 'package:freebox/modules/user_settings/user_settings.dart'; import 'package:freebox/widgets/custom_circular_progress_indicator.dart'; import 'package:freebox/widgets/main_screen.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hive/hive.dart'; import 'package:path_provider/path_provider.dart' as path_provider; import 'package:provider/provider.dart'; class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Future<void> _initializeAppFuture; final ISettingsDatabase _settingsDatabase = SettingsDatabase(); final IBackendService _backendService = BackendService(); @override void initState() { super.initState(); _initializeAppFuture = _initializeApp(); } Future<void> _initializeApp() async { final appDocumentDir = await path_provider.getApplicationDocumentsDirectory(); Hive.init(appDocumentDir.path); await _settingsDatabase.initialize(); await _backendService.initialize(); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: FutureBuilder( future: _initializeAppFuture, builder: (_, snapshot) { switch (snapshot.connectionState) { case ConnectionState.active: case ConnectionState.waiting: return Center( child: CustomCircularProgressIndicator(), ); default: return MultiProvider( providers: [ Provider<ISettingsDatabase>.value( value: _settingsDatabase, ), Provider<IBackendService>.value( value: _backendService, ), ], child: _MyApp( hasSeenOnboarding: _settingsDatabase.userSeenOnboarding, ), ); } }), ), ); } } class _MyApp extends StatelessWidget { final bool hasSeenOnboarding; const _MyApp({ Key key, @required this.hasSeenOnboarding, }) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( accentColor: AppColors.green, primaryColor: AppColors.blue, fontFamily: GoogleFonts.poppins().fontFamily, textTheme: TextTheme( headline1: TextStyle( color: AppColors.green, fontSize: 30, fontWeight: FontWeight.bold, ), bodyText1: TextStyle( color: AppColors.blue, fontSize: 18, fontWeight: FontWeight.w500, ), ), elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( minimumSize: MaterialStateProperty.all(Size(200, 40)), ), ), ), localizationsDelegates: [ const AppLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: AppLocalizationsDelegate.supportedLocals, navigatorObservers: [ AnalyticsService.observer, ], routes: { RouteNames.mainScreen: (_) => MainScreen(), }, home: hasSeenOnboarding ? MainScreen() : Onboarding(), ); } }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/widgets/main_screen.dart
import 'package:flutter/material.dart'; import 'package:freebox/localizations.dart'; import 'package:freebox/widgets/freebox_screen.dart'; import 'package:freebox/widgets/map_screen.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; class MainScreen extends StatefulWidget { MainScreen({Key key}) : super(key: key); @override _MainScreenState createState() => _MainScreenState(); } class _MainScreenState extends State<MainScreen> { int selectedIndex = 0; static const List<Widget> screens = <Widget>[ FreeboxScreen(), MapScreen(), ]; @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavigationBar( selectedItemColor: Theme.of(context).accentColor, unselectedItemColor: Theme.of(context).accentColor, currentIndex: selectedIndex, onTap: (index) => setState(() { selectedIndex = index; }), showSelectedLabels: true, items: <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon( MdiIcons.packageVariantClosed, color: Theme.of(context).accentColor, ), label: AppLocalizations.bottomNavigationBarFreeboxes, ), BottomNavigationBarItem( icon: Icon( MdiIcons.mapSearchOutline, color: Theme.of(context).accentColor, ), label: AppLocalizations.bottomNavigationBarMap, ), ], ), body: SafeArea( child: screens[selectedIndex], ), ); } }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/widgets/freebox_screen.dart
import 'package:flutter/material.dart'; import 'package:freebox/modules/backend_service/bacend_service.dart'; import 'package:freebox/modules/backend_service/src/models/freebox.dart'; import 'package:provider/provider.dart'; class FreeboxScreen extends StatelessWidget { const FreeboxScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { return StreamBuilder( stream: context.watch<IBackendService>().freeboxStream(), builder: (context, AsyncSnapshot<List<Freebox>> snapshot) { if (snapshot.data != null) { return ListView.builder( itemBuilder: (context, index) => ListTile( leading: Image.network(snapshot.data[index].imageUrl), title: Text(snapshot.data[index].description), ), itemCount: snapshot.data.length, ); } else { return Container(); } }, ); } }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/widgets/custom_circular_progress_indicator.dart
import 'package:flutter/material.dart'; import 'package:freebox/configs/app_colors.dart'; class CustomCircularProgressIndicator extends StatelessWidget { const CustomCircularProgressIndicator({Key key}) : super(key: key); @override Widget build(BuildContext context) { return CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(AppColors.blue), ); } }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/widgets/map_screen.dart
import 'package:flutter/material.dart'; class MapScreen extends StatelessWidget { const MapScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { return Center( child: Text('Map Screen'), ); } }
0
mirrored_repositories/freebox/lib/modules
mirrored_repositories/freebox/lib/modules/analytics/analytics.dart
library analytics; export 'src/models/base_analytics_event.dart'; export 'src/services/analytics_service.dart';
0
mirrored_repositories/freebox/lib/modules/analytics/src
mirrored_repositories/freebox/lib/modules/analytics/src/models/base_analytics_event.dart
import 'package:meta/meta.dart'; abstract class BaseAnalyticsEvent { final String name; final Map<String, dynamic> parameters; BaseAnalyticsEvent({ @required this.name, this.parameters = const <String, dynamic>{}, }); }
0
mirrored_repositories/freebox/lib/modules/analytics/src
mirrored_repositories/freebox/lib/modules/analytics/src/services/analytics_service.dart
import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:flutter/widgets.dart'; import '../models/base_analytics_event.dart'; abstract class AnalyticsService { static final _analytics = FirebaseAnalytics(); static final _observer = FirebaseAnalyticsObserver(analytics: _analytics); static NavigatorObserver get observer => _observer; static Future<void> trackEvent(BaseAnalyticsEvent event) async => await _analytics.logEvent(name: event.name, parameters: event.parameters); static Future<void> userseenOnboarding() async => await _analytics.logTutorialComplete(); }
0
mirrored_repositories/freebox/lib/modules/onboarding
mirrored_repositories/freebox/lib/modules/onboarding/widgets/onboarding.dart
import 'package:flutter/material.dart'; import 'package:freebox/configs/app_colors.dart'; import 'package:freebox/configs/asset_paths.dart'; import 'package:freebox/configs/route_names.dart'; import 'package:freebox/localizations.dart'; import 'package:freebox/modules/analytics/analytics.dart'; import 'package:freebox/modules/user_settings/user_settings.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:provider/provider.dart'; class Onboarding extends StatefulWidget { Onboarding({Key key}) : super(key: key); @override _OnboardingState createState() => _OnboardingState(); } class _OnboardingState extends State<Onboarding> { PageController _pageController; double _pageOffset = 0; @override void initState() { super.initState(); _pageController = PageController(viewportFraction: 0.9); _pageController.addListener(() { setState(() => _pageOffset = _pageController.page); }); } @override void dispose() { _pageController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: LayoutBuilder( builder: (context, constraints) { return PageView( controller: _pageController, children: [ OnboardingPage( constraints: constraints, assetPath: AssetPaths.onboardingImagePageOne, headline: AppLocalizations.onboardingWelcomeHeadline, description: AppLocalizations.onboardingPageOneDescription, isPageTwo: false, offset: _pageOffset, ), OnboardingPage( constraints: constraints, assetPath: AssetPaths.onboardingImagePageTwo, headline: AppLocalizations.onboardingWelcomeHeadline, description: AppLocalizations.onboardingPageTwoDescription, isPageTwo: true, offset: _pageOffset - 1, ), ], ); }, ), ), ); } } class OnboardingPage extends StatelessWidget { final double offset; final BoxConstraints constraints; final String headline; final String description; final String assetPath; final bool isPageTwo; const OnboardingPage({ Key key, @required this.constraints, @required this.assetPath, @required this.offset, this.headline, this.description, this.isPageTwo = false, }) : super(key: key); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 16, ), child: headline != null ? Text( headline, textAlign: TextAlign.center, style: Theme.of(context).textTheme.headline1, ) : Container(), ), Padding( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 8, ), child: Center( child: OnboardingCard( assetPath: assetPath, constraints: constraints, offset: offset, ), ), ), Padding( padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 16, ), child: description != null ? Container( width: constraints.maxWidth * 0.8, child: Text( description, textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodyText1, ), ) : Container(), ), if (isPageTwo) Padding( padding: const EdgeInsets.only(top: 20.0), child: Center( child: ElevatedButton( onPressed: () { AnalyticsService.userseenOnboarding(); context.read<ISettingsDatabase>().userSeenOnboarding = true; Navigator.pushNamed(context, RouteNames.mainScreen); }, style: ButtonStyle( shape: MaterialStateProperty.resolveWith( (states) => RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)), ), backgroundColor: MaterialStateProperty.resolveWith( (states) => Theme.of(context).accentColor, ), ), child: Text(AppLocalizations.onboardingPageTwoButtonLabel, style: TextStyle( color: AppColors.white, )), ), ), ), if (!isPageTwo) Expanded( child: Padding( padding: const EdgeInsets.only(bottom: 20.0), child: AnimatedGestureIcon(), ), ), ], ); } } class OnboardingCard extends StatelessWidget { final String assetPath; final BoxConstraints constraints; final double offset; const OnboardingCard({ Key key, @required this.assetPath, @required this.constraints, @required this.offset, }) : super(key: key); @override Widget build(BuildContext context) { return Card( elevation: 8, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32), ), child: ClipRRect( borderRadius: BorderRadius.circular(32), child: Image.asset( assetPath, height: constraints.maxHeight * 0.4, width: constraints.maxWidth * 0.7, fit: BoxFit.cover, alignment: Alignment(-offset.abs(), 1), ), ), ); } } class AnimatedGestureIcon extends StatefulWidget { AnimatedGestureIcon({Key key}) : super(key: key); @override _AnimatedGestureIconState createState() => _AnimatedGestureIconState(); } class _AnimatedGestureIconState extends State<AnimatedGestureIcon> with SingleTickerProviderStateMixin { static const _animationBegin = 0.5; static const _animationEnd = 2.0; AnimationController _controller; @override void initState() { super.initState(); _controller = AnimationController(vsync: this, duration: const Duration(seconds: 2)); _controller.forward(); _controller.repeat(reverse: true); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { Animation animation = Tween<double>(begin: _animationBegin, end: _animationEnd).animate(_controller); return AnimatedBuilder( animation: animation, child: Icon( MdiIcons.gestureSwipeHorizontal, size: 70, color: Theme.of(context).accentColor, ), builder: (_, child) => Transform.translate( offset: Offset(100 * animation.value, 0), child: child, ), ); } }
0
mirrored_repositories/freebox/lib/modules
mirrored_repositories/freebox/lib/modules/user_settings/user_settings.dart
library user_settings; export 'src/services/i_settings_database.dart'; export 'src/services/settings_database.dart';
0
mirrored_repositories/freebox/lib/modules/user_settings/src
mirrored_repositories/freebox/lib/modules/user_settings/src/services/settings_database.dart
import 'package:hive/hive.dart'; import 'i_settings_database.dart'; class SettingsDatabase extends ISettingsDatabase { static const _boxName = 'settings'; Box<dynamic> _box; @override Future<void> initialize() async { _box = await Hive.openBox(_boxName); } @override set userSeenOnboarding(value) => _box.put(_Keys.userSeenOnboarding, value); @override bool get userSeenOnboarding => _box.get(_Keys.userSeenOnboarding, defaultValue: _Defaults.userSeenOnboarding); } class _Keys { static const userSeenOnboarding = 'userSeenOnboarding'; } class _Defaults { static const userSeenOnboarding = false; }
0
mirrored_repositories/freebox/lib/modules/user_settings/src
mirrored_repositories/freebox/lib/modules/user_settings/src/services/i_settings_database.dart
abstract class ISettingsDatabase { set userSeenOnboarding(bool value); bool get userSeenOnboarding; Future<void> initialize(); }
0
mirrored_repositories/freebox/lib/modules
mirrored_repositories/freebox/lib/modules/backend_service/bacend_service.dart
library backend_service; export 'src/services/i_backend_service.dart'; export 'src/services/backend_service.dart';
0
mirrored_repositories/freebox/lib/modules/backend_service/src
mirrored_repositories/freebox/lib/modules/backend_service/src/models/freebox.dart
import 'package:meta/meta.dart'; class Freebox { final String id; final String description; final String address; final String imageUrl; Freebox({ @required this.id, @required this.description, @required this.address, @required this.imageUrl, }); factory Freebox.fromJson(Map<String, dynamic> json) => Freebox( id: json['id'], description: json['description'], address: json['address'], imageUrl: json['imageUrl'], ); Map<String, dynamic> toJson() => { 'id': id, 'description': description, 'address': address, 'imageUrl': imageUrl, }; @override String toString() => toJson().toString(); }
0
mirrored_repositories/freebox/lib/modules/backend_service/src
mirrored_repositories/freebox/lib/modules/backend_service/src/services/i_auth_service.dart
import 'package:meta/meta.dart'; abstract class IAuthService { @protected Future<void> signInAnonymously(); }
0
mirrored_repositories/freebox/lib/modules/backend_service/src
mirrored_repositories/freebox/lib/modules/backend_service/src/services/backend_service.dart
import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; import 'package:uuid/uuid.dart'; import '../models/freebox.dart'; import 'i_auth_service.dart'; import 'i_backend_service.dart'; class BackendService implements IBackendService, IAuthService { static const _freeboxCollectionPath = 'freeboxes'; @override Future<void> initialize() async { await Firebase.initializeApp(); await signInAnonymously(); } @override Future<void> signInAnonymously() async { try { await FirebaseAuth.instance.signInAnonymously(); } on PlatformException catch (e) { print(e); } } @override Stream<List<Freebox>> freeboxStream() { final stream = FirebaseFirestore.instance.collection(_freeboxCollectionPath).snapshots(); return stream.map((snapshot) => snapshot.docs.map((doc) => Freebox.fromJson(doc.data())).toList()); } @override Future<bool> publishFreebox({ @required File image, @required String description, @required String address, }) async { if (image != null && description != null && address != null) { final id = Uuid().v1(); final storageReference = FirebaseStorage.instance.ref().child(id); final uploadTask = storageReference.putFile( image, StorageMetadata( contentType: 'image/jpg', //TODO what about png? ), ); final result = await uploadTask.onComplete; if (result.error == null) { final url = await result.ref.getDownloadURL(); final freebox = Freebox( id: id, description: description, address: address, imageUrl: url, ); final documentReference = FirebaseFirestore.instance.collection(_freeboxCollectionPath).doc(id); await FirebaseFirestore.instance.runTransaction((transaction) async { await transaction.set( documentReference, freebox.toJson(), ); }); return true; } } return false; } }
0
mirrored_repositories/freebox/lib/modules/backend_service/src
mirrored_repositories/freebox/lib/modules/backend_service/src/services/i_backend_service.dart
import 'dart:io'; import 'package:meta/meta.dart'; import '../models/freebox.dart'; abstract class IBackendService { Future<void> initialize(); Stream<List<Freebox>> freeboxStream(); Future<bool> publishFreebox({ @required File image, @required String description, @required String address, }); }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/enums/build_environment.dart
enum BuildEnvironment { dev, prod, }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/configs/asset_paths.dart
class AssetPaths { static const onboardingImagePageOne = 'assets/images/onboarding/onboarding_page_one.jpg'; static const onboardingImagePageTwo = 'assets/images/onboarding/onboarding_page_two.jpg'; }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/configs/app_colors.dart
import 'dart:ui'; import 'package:flutter/material.dart'; class AppColors { static const navyBlue = Color(0xff141d56); static const white = Colors.white; static const blue = Color(0xff47b7cb); static const black = Colors.black; static const green = Color(0xff38CAC8); }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/configs/app_config.dart
import 'package:freebox/enums/build_environment.dart'; class AppConfig { final BuildEnvironment buildEnvironment; const AppConfig.dev() : buildEnvironment = BuildEnvironment.dev; const AppConfig.prod() : buildEnvironment = BuildEnvironment.prod; }
0
mirrored_repositories/freebox/lib
mirrored_repositories/freebox/lib/configs/route_names.dart
class RouteNames { static const mainScreen = 'mainScreen'; }
0
mirrored_repositories/freebox/test
mirrored_repositories/freebox/test/configs/app_config_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:freebox/configs/app_config.dart'; import 'package:freebox/enums/build_environment.dart'; void main() { test('AppConfig.dev has BuildEnvironment,dev', () { final appConfig = AppConfig.dev(); expect(appConfig.buildEnvironment, BuildEnvironment.dev); }); test('AppConfig.prod has BuildEnvironment,prod', () { final appConfig = AppConfig.prod(); expect(appConfig.buildEnvironment, BuildEnvironment.prod); }); }
0
mirrored_repositories/ToDo_list_flutter
mirrored_repositories/ToDo_list_flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:todo_list/screens/home.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.transparent, ), ); return MaterialApp( debugShowCheckedModeBanner: false, title: 'Material App', home: Home(), ); } }
0
mirrored_repositories/ToDo_list_flutter/lib
mirrored_repositories/ToDo_list_flutter/lib/constants/colors.dart
import 'package:flutter/material.dart'; const Color tdRed = Color(0xFFDA4040); const Color tdBlue = Color(0xFF5F52EE); const Color tdBlack = Color(0xFF3A3A3A); const Color tdGrey = Color(0xFF717171); const Color tdBGColor = Color(0xFFEEEFF5);
0
mirrored_repositories/ToDo_list_flutter/lib
mirrored_repositories/ToDo_list_flutter/lib/widgets/todo_item.dart
import 'package:flutter/material.dart'; import 'package:todo_list/constants/colors.dart'; import 'package:todo_list/model/todos.dart'; class ToDoItem extends StatelessWidget { final ToDo todo; final onToDoChanged; final OnDeleteItem; const ToDoItem( {Key? key, required this.todo, required this.onToDoChanged, required this.OnDeleteItem}) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.only(bottom: 20), child: ListTile( onTap: () { // print('Haz click en el item'); onToDoChanged(todo); }, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5), tileColor: Colors.white, leading: Icon( todo.isDone ? Icons.check_box : Icons.check_box_outline_blank, color: tdBlue, ), title: Text( todo.todoText!, style: TextStyle( color: tdBlack, fontSize: 16, decoration: todo.isDone ? TextDecoration.lineThrough : null, ), ), trailing: Container( padding: const EdgeInsets.all(0), margin: const EdgeInsets.symmetric(vertical: 12), height: 35, width: 35, decoration: BoxDecoration( color: tdRed, borderRadius: BorderRadius.circular(5), ), child: IconButton( iconSize: 18, onPressed: () { // print('Haz click en el boton de borrar'); OnDeleteItem(todo.id!); }, icon: const Icon( Icons.delete, color: Colors.white, ), )))); } }
0
mirrored_repositories/ToDo_list_flutter/lib
mirrored_repositories/ToDo_list_flutter/lib/model/todos.dart
class ToDo { String? id; String? todoText; bool isDone; ToDo({ required this.id, required this.todoText, this.isDone = false, }); static List<ToDo> todoList() { return [ ToDo(id: '01', todoText: 'Tarea de programación Movil', isDone: true), ToDo(id: '02', todoText: 'Conversar con Maria', isDone: false), ToDo( id: '03', todoText: 'Ensayo de desarrollo emprendedores', isDone: true), ToDo( id: '04', todoText: 'Llamada en Teams', ), ToDo( id: '05', todoText: 'Trabajar en mobile apps por 2 horas', ), ToDo( id: '06', todoText: 'Llamar a mi mamá', ), ToDo( id: '07', todoText: 'Revisar Emails', ), ToDo( id: '08', todoText: 'Revisar el calendario', ), ToDo( id: '09', todoText: 'hacer la tarea de programación', ), ToDo( id: '10', todoText: 'desarrollar la app de tareas', ), ToDo( id: '11', todoText: 'Desayunar', ), ToDo( id: '12', todoText: 'Comprar comida', ), ToDo( id: '13', todoText: 'Ducharme', ), ToDo( id: '14', todoText: 'comprar mochila', ), ToDo( id: '15', todoText: 'limpiar la casa', ), ToDo( id: '16', todoText: 'Ir al supermercado', ), ToDo( id: '17', todoText: 'Salir a correr', ), ToDo( id: '18', todoText: 'ver la serie de netflix', ), ]; } }
0
mirrored_repositories/ToDo_list_flutter/lib
mirrored_repositories/ToDo_list_flutter/lib/screens/home.dart
import 'package:flutter/material.dart'; import 'package:todo_list/constants/colors.dart'; import 'package:todo_list/model/todos.dart'; import 'package:todo_list/widgets/todo_item.dart'; class Home extends StatefulWidget { Home({Key? key}) : super(key: key); @override State<Home> createState() => _HomeState(); } class _HomeState extends State<Home> { final todoList = ToDo.todoList(); List<ToDo> foundToDo = []; final todoController = TextEditingController(); @override void initState() { foundToDo = todoList; super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: tdBGColor, appBar: _buildAppBar(), body: Stack( children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 15), child: Column(children: [ searchBox(), Expanded( child: ListView( children: [ Container( margin: const EdgeInsets.only(top: 50, bottom: 20), child: const Text( 'All ToDos', style: TextStyle( fontSize: 30, fontWeight: FontWeight.w500, color: tdBlack, ), ), ), for (ToDo todo in foundToDo) ToDoItem( todo: todo, onToDoChanged: _handleToDoChange, OnDeleteItem: _deleteToDoItem, ), ], ), ) ]), ), Align( alignment: Alignment.bottomCenter, child: Row( children: [ Expanded( child: Container( margin: const EdgeInsets.only( bottom: 20, right: 20, left: 20, ), padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 5), decoration: BoxDecoration( color: Colors.white, boxShadow: const [ BoxShadow( color: Colors.grey, blurRadius: 10.0, offset: Offset(0, 0), spreadRadius: 0.0, ) ], borderRadius: BorderRadius.circular(10), ), child: TextField( controller: todoController, decoration: const InputDecoration( hintText: 'Add a new todo', hintStyle: TextStyle(color: tdGrey), border: InputBorder.none, ), ), ), ), Container( margin: const EdgeInsets.only(bottom: 20, right: 20), decoration: BoxDecoration( color: tdBlue, borderRadius: BorderRadius.circular(10), ), child: ElevatedButton( onPressed: () { _addToDoItem(todoController.text); }, style: ElevatedButton.styleFrom( backgroundColor: tdBlue, padding: const EdgeInsets.all(10), ), child: const Text( '+', style: TextStyle( fontSize: 30, color: Colors.white, ), )), ) ], ), ) ], )); } void _handleToDoChange(ToDo todo) { setState(() { todo.isDone = !todo.isDone; }); } void _deleteToDoItem(String id) { setState(() { todoList.removeWhere((item) => item.id == id); }); } void _addToDoItem(String toDo) { setState(() { todoList.add(ToDo( id: DateTime.now().millisecondsSinceEpoch.toString(), todoText: toDo, )); }); todoController.clear(); } void _runFilter(String enteredKeyword) { List<ToDo> results = []; if (enteredKeyword.isEmpty) { results = todoList; } else { results = todoList .where((item) => item.todoText! .toLowerCase() .contains(enteredKeyword.toLowerCase())) .toList(); } setState(() { foundToDo = results; }); } Widget searchBox() { return Container( padding: const EdgeInsets.symmetric(horizontal: 15), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), ), child: TextField( onChanged: (value) => _runFilter(value), decoration: const InputDecoration( contentPadding: EdgeInsets.all(0), prefixIcon: Icon( Icons.search, color: tdBlack, size: 20, ), prefixIconConstraints: BoxConstraints( maxHeight: 20, minWidth: 25, ), border: InputBorder.none, hintText: 'Search', hintStyle: TextStyle(color: tdGrey), ), ), ); } AppBar _buildAppBar() { return AppBar( elevation: 0, backgroundColor: tdBGColor, title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Icon(Icons.menu, color: Colors.black, size: 30), SizedBox( height: 40, width: 40, child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Image.asset('assets/images/avatar.jpg'), ), ) ], ), ); } }
0
mirrored_repositories/ToDo_list_flutter
mirrored_repositories/ToDo_list_flutter/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 in the flutter_test package. 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:todo_list/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
mirrored_repositories/personal-expense-app
mirrored_repositories/personal-expense-app/lib/main.dart
import 'dart:io'; import 'package:flutter/material.dart'; //import 'package:flutter/services.dart'; import './widgets/new_transaction.dart'; import './widgets/transaction_list.dart'; import './widgets/chart.dart'; import './models/transaction.dart'; void main() { //WidgetsFlutterBinding.ensureInitialized(); // this is for specifying the type of orientation that we want. There will be nothing other than this //SystemChrome.setPreferredOrientations( // [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Personal Expenses', theme: ThemeData( primarySwatch: Colors.indigo, accentColor: Colors.amber, fontFamily: 'Quicksand', textTheme: ThemeData.light().textTheme.copyWith( title: TextStyle( fontFamily: 'OpenSans', fontWeight: FontWeight.bold, fontSize: 18, ), button: TextStyle(color: Colors.white), ), appBarTheme: AppBarTheme( textTheme: ThemeData.light().textTheme.copyWith( title: TextStyle( fontFamily: 'OpenSans', fontSize: 20, fontWeight: FontWeight.bold, ), ), )), home: MyHomePage(), debugShowCheckedModeBanner: false, ); } } class MyHomePage extends StatefulWidget { // String titleInput; // String amountInput; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver { final List<Transaction> _userTransactions = [ //Transaction( // id: 't1', // title: 'New Shoes', // amount: 69.99, // date: DateTime.now(), //), //Transaction( // id: 't2', // title: 'Weekly Groceries', // amount: 16.53, // date: DateTime.now(), //), ]; @override void didChangeAppLifeCycleState(AppLifecycleState state) { print(state); } @override void initState() { WidgetsBinding.instance.addObserver(this); super.initState(); } @override dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } bool _showChart = false; List<Transaction> get _recentTransactions { return _userTransactions.where((tx) { return tx.date.isAfter( DateTime.now().subtract( Duration(days: 7), ), ); }).toList(); } void _addNewTransaction(String txTitle, double txAmount, DateTime txDate) { final newTx = Transaction( title: txTitle, amount: txAmount, date: txDate, id: DateTime.now().toString(), ); setState(() { _userTransactions.add(newTx); }); } void _startAddNewTransaction(BuildContext ctx) { showModalBottomSheet( context: ctx, builder: (_) { return GestureDetector( onTap: () {}, child: NewTransaction(_addNewTransaction), behavior: HitTestBehavior.opaque, ); }, ); } void _deleteTransaction(String id) { setState(() { _userTransactions.removeWhere((tx) => tx.id == id); }); } PreferredSizeWidget _buildAppBar() { return AppBar( title: Text( 'Personal Expenses', ), actions: <Widget>[ IconButton( icon: Icon(Icons.add), onPressed: () => _startAddNewTransaction(context), ), ], ); } @override Widget build(BuildContext context) { final _isLandscape = MediaQuery.of(context).orientation == Orientation.landscape; final _appBar = _buildAppBar(); final _txListWidget = Container( height: (MediaQuery.of(context).size.height - _appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.7, child: TransactionList(_userTransactions, _deleteTransaction), ); return Scaffold( appBar: _appBar, body: SafeArea( child: SingleChildScrollView( child: Column( // mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ if (_isLandscape) Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("Show Chart"), Switch.adaptive( activeColor: Theme.of(context).accentColor, value: _showChart, onChanged: (val) { setState(() { _showChart = val; }); }, ), ], ), if (!_isLandscape) Container( height: (MediaQuery.of(context).size.height - _appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.2, child: Chart(_recentTransactions), ), if (!_isLandscape) _txListWidget, if (_isLandscape) _showChart ? Container( height: (MediaQuery.of(context).size.height - _appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.7, child: Chart(_recentTransactions), ) : _txListWidget, ], ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: Platform.isIOS ? Container() : FloatingActionButton( child: Icon(Icons.add), onPressed: () => _startAddNewTransaction(context), ), ); } }
0
mirrored_repositories/personal-expense-app/lib
mirrored_repositories/personal-expense-app/lib/widgets/new_transaction.dart
import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:intl/intl.dart'; class NewTransaction extends StatefulWidget { final Function addTx; NewTransaction(this.addTx); @override _NewTransactionState createState() => _NewTransactionState(); } class _NewTransactionState extends State<NewTransaction> { final _titleController = TextEditingController(); final _amountController = TextEditingController(); DateTime _selectedDate; void _submitData() { if (_amountController.text.isEmpty) { return; } final enteredTitle = _titleController.text; final enteredAmount = double.parse(_amountController.text); final enteredDate = _selectedDate; if (enteredTitle.isEmpty || enteredAmount <= 0 || enteredDate == null) { return; } widget.addTx( enteredTitle, enteredAmount, enteredDate, ); Navigator.of(context).pop(); } void _showDate() { showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(2021), lastDate: DateTime.now(), ).then((selectedDate) { if (selectedDate == null) { return; } setState(() { _selectedDate = selectedDate; }); }); } @override Widget build(BuildContext context) { return SingleChildScrollView( child: Card( elevation: 5, child: Container( padding: EdgeInsets.only( top: 10, left: 10, right: 10, bottom: MediaQuery.of(context).viewInsets.bottom + 10, ), child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ TextField( decoration: InputDecoration(labelText: 'Title'), controller: _titleController, onSubmitted: (_) => _submitData(), // onChanged: (val) { // titleInput = val; // }, ), TextField( decoration: InputDecoration(labelText: 'Amount'), controller: _amountController, keyboardType: TextInputType.number, onSubmitted: (_) => _submitData(), // onChanged: (val) => amountInput = val, ), Container( height: 70, child: Row( children: <Widget>[ Expanded( child: Text( _selectedDate == null ? 'No Date chosen' : 'Picked Date: ${DateFormat.yMd().format(_selectedDate)}', ), ), FlatButton( textColor: Theme.of(context).primaryColor, onPressed: _showDate, child: Text( 'Choose Date', style: TextStyle(fontWeight: FontWeight.bold), ), ) ], ), ), RaisedButton( child: Text('Add Transaction'), onPressed: _submitData, color: Theme.of(context).primaryColor, textColor: Theme.of(context).textTheme.button.color, ), ], ), ), ), ); } }
0
mirrored_repositories/personal-expense-app/lib
mirrored_repositories/personal-expense-app/lib/widgets/transaction_list.dart
import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../models/transaction.dart'; class TransactionList extends StatelessWidget { final List<Transaction> transactions; final Function delTransaction; TransactionList(this.transactions, this.delTransaction); @override Widget build(BuildContext context) { return transactions.isEmpty ? LayoutBuilder(builder: (context, constraints) { return Column( children: <Widget>[ Text( 'No transactions added yet!', style: Theme.of(context).textTheme.title, ), SizedBox( height: 20, ), Container( height: constraints.maxHeight * 0.6, child: Image.asset( 'assets/images/waiting.png', fit: BoxFit.cover, )), ], ); }) : ListView.builder( itemBuilder: (ctx, index) { return Card( elevation: 5, child: ListTile( leading: CircleAvatar( child: Padding( padding: const EdgeInsets.all(6.0), child: FittedBox( child: Text( transactions[index].amount.toString(), ), ), ), ), title: Text( transactions[index].title, style: Theme.of(context).textTheme.title, ), subtitle: Text( DateFormat.yMMMd().format(transactions[index].date), ), trailing: IconButton( onPressed: () => delTransaction(transactions[index].id), icon: const Icon( Icons.delete, color: Colors.red, ), ), ), ); }, itemCount: transactions.length, ); } }
0
mirrored_repositories/personal-expense-app/lib
mirrored_repositories/personal-expense-app/lib/widgets/chart.dart
import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import './chart_bar.dart'; import '../models/transaction.dart'; class Chart extends StatelessWidget { final List<Transaction> recentTransactions; Chart(this.recentTransactions); List<Map<String, Object>> get groupedTransactionValues { return List.generate(7, (index) { final weekDay = DateTime.now().subtract( Duration(days: index), ); var totalSum = 0.0; for (var i = 0; i < recentTransactions.length; i++) { if (recentTransactions[i].date.day == weekDay.day && recentTransactions[i].date.month == weekDay.month && recentTransactions[i].date.year == weekDay.year) { totalSum += recentTransactions[i].amount; } } return { 'day': DateFormat.E().format(weekDay).substring(0, 1), 'amount': totalSum, }; }).reversed.toList(); } double get totalSpending { return groupedTransactionValues.fold(0.0, (sum, item) { return sum + item['amount']; }); } @override Widget build(BuildContext context) { return Card( elevation: 6, margin: EdgeInsets.all(20), child: Padding( padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: groupedTransactionValues.map((data) { return Flexible( fit: FlexFit.tight, child: ChartBar( data['day'], data['amount'], totalSpending == 0.0 ? 0.0 : (data['amount'] as double) / totalSpending, ), ); }).toList(), ), ), ); } }
0
mirrored_repositories/personal-expense-app/lib
mirrored_repositories/personal-expense-app/lib/widgets/chart_bar.dart
import 'package:flutter/material.dart'; class ChartBar extends StatelessWidget { final String label; final double spendingAmount; final double spendingPctOfTotal; ChartBar(this.label, this.spendingAmount, this.spendingPctOfTotal); @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, contraints) { return Column( children: <Widget>[ Container( height: contraints.maxHeight * 0.15, child: FittedBox( child: Text( '\$${spendingAmount.toStringAsFixed(0)}', style: TextStyle(fontSize: 20), ), ), ), SizedBox( height: contraints.maxHeight * 0.05, ), Container( height: contraints.maxHeight * 0.6, width: 10, child: Stack( alignment: AlignmentDirectional.bottomStart, children: <Widget>[ Container( decoration: BoxDecoration( border: Border.all(color: Colors.grey, width: 1.0), color: Color.fromRGBO(220, 220, 220, 1), borderRadius: BorderRadius.circular(10), ), ), FractionallySizedBox( heightFactor: spendingPctOfTotal, child: Container( decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.circular(10), ), ), ), ], ), ), SizedBox( height: contraints.maxHeight * 0.05, ), Container( height: contraints.maxHeight * 0.15, child: FittedBox( child: Text(label), ), ), ], ); }); } }
0
mirrored_repositories/personal-expense-app/lib
mirrored_repositories/personal-expense-app/lib/models/transaction.dart
import 'package:flutter/foundation.dart'; class Transaction { final String id; final String title; final double amount; final DateTime date; Transaction({ @required this.id, @required this.title, @required this.amount, @required this.date, }); }
0
mirrored_repositories/personal-expense-app
mirrored_repositories/personal-expense-app/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:personal_expense_app/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/Apps-Flutter/contadorpessoas
mirrored_repositories/Apps-Flutter/contadorpessoas/lib/main.dart
import 'package:flutter/material.dart'; void main() { //chamamos uma funcao runApp que passa o widget MaterialApp runApp(MaterialApp( // no MaterialApp passamos os parametros do construtor que sao opcionais // em Flutter nao apenas os componentes sao widget a tela completas tambem title: "Contador de Pessoas", home: Home() )); } class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { int _people = 0; String _infoText = "Pode Entrar!"; void _changePeople(int delta){ setState(() { _people += delta; if(_people < 0){ _infoText = "Mundo invertido?"; } else if (_people <= 10){ _infoText = "Pode Entrar"; ; } else { _infoText = "Lotado"; } }); } @override Widget build(BuildContext context) { return Stack( children: <Widget>[ Image.asset( "images/restaurant.jpg", fit: BoxFit.cover, height: 1000.0, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "Pessoas: $_people", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: EdgeInsets.all(10.0), child: FlatButton( child: Text( "+1", style: TextStyle(fontSize: 40.0, color: Colors.white), ), onPressed: () { _changePeople(1); }, ), ), Padding( padding: EdgeInsets.all(10.0), child: FlatButton( child: Text( "-1", style: TextStyle(fontSize: 40.0, color: Colors.white), ), onPressed: () { _changePeople(-1); }, ), ), ], ), Text( _infoText, style: TextStyle( color: Colors.white, fontStyle: FontStyle.italic, fontSize: 30.0), ) ], ) ], ); } }
0
mirrored_repositories/Apps-Flutter/calculadoraimc
mirrored_repositories/Apps-Flutter/calculadoraimc/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( home: Home(), )); } class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { TextEditingController weightController = TextEditingController(); TextEditingController heightController = TextEditingController(); GlobalKey<FormState> _formKey = GlobalKey<FormState>(); String _infoText = "Informe seus dados!"; void _resetFields() { weightController.text = ""; heightController.text = ""; setState(() { _infoText = "Informe seus dados!"; }); } void _calculate() { setState(() { double weight = double.parse(weightController.text); double height = double.parse(heightController.text) / 100; double imc = weight / (height * height); if (imc < 18.6) { _infoText = "Abaixo do Peso (${imc.toStringAsPrecision(4)})"; } else if (imc >= 18.6 && imc < 24.9) { _infoText = "Peso Ideal (${imc.toStringAsPrecision(4)})"; } else if (imc >= 24.9 && imc < 29.9) { _infoText = "Levemente Acima do Peso (${imc.toStringAsPrecision(4)})"; } else if (imc >= 29.9 && imc < 34.9) { _infoText = "Obesidade Grau I (${imc.toStringAsPrecision(4)})"; } else if (imc >= 34.9 && imc < 39.9) { _infoText = "Obesidade Grau II (${imc.toStringAsPrecision(4)})"; } else if (imc >= 40) { _infoText = "Obesidade Grau III (${imc.toStringAsPrecision(4)})"; } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Calculadora de IMC"), centerTitle: true, backgroundColor: Colors.green, actions: <Widget>[ IconButton( icon: Icon(Icons.refresh), onPressed: _resetFields, ) ], ), backgroundColor: Colors.white, body: SingleChildScrollView( padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), child: Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Icon(Icons.person_outline, size: 120.0, color: Colors.green), TextFormField( keyboardType: TextInputType.number, decoration: InputDecoration( labelText: "Peso (kg)", labelStyle: TextStyle(color: Colors.green)), textAlign: TextAlign.center, style: TextStyle(color: Colors.green, fontSize: 25.0), controller: weightController, validator: (value) { if (value.isEmpty) { return "Insira seu Peso!"; } }, ), TextFormField( keyboardType: TextInputType.number, decoration: InputDecoration( labelText: "Altura (cm)", labelStyle: TextStyle(color: Colors.green)), textAlign: TextAlign.center, style: TextStyle(color: Colors.green, fontSize: 25.0), controller: heightController, validator: (value) { if (value.isEmpty) { return "Insira sua Altura!"; } }, ), Padding( padding: EdgeInsets.only(top: 10.0, bottom: 10.0), child: Container( height: 50.0, child: RaisedButton( onPressed: () { if (_formKey.currentState.validate()) { _calculate(); } }, child: Text( "Calcular", style: TextStyle(color: Colors.white, fontSize: 25.0), ), color: Colors.green, ), ), ), Text( _infoText, textAlign: TextAlign.center, style: TextStyle(color: Colors.green, fontSize: 25.0), ) ], ), ), ), ); } }
0
mirrored_repositories/Express-Booking-App
mirrored_repositories/Express-Booking-App/lib/app_icon.dart
import 'package:flutter/material.dart'; class AppIcon extends StatelessWidget { double font_size; Color font_color; AppIcon(this.font_size, this.font_color); @override Widget build(BuildContext context) { return Text( 'EB', style: TextStyle( color: font_color, fontFamily: "Red Seven", fontSize: font_size, letterSpacing: 2 ), textAlign: TextAlign.center, ); } }
0
mirrored_repositories/Express-Booking-App
mirrored_repositories/Express-Booking-App/lib/main.dart
import 'package:express_booking_app/landing/landing.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Express Booking App', theme: ThemeData( primaryColor: Colors.white ), home: Landing(), debugShowCheckedModeBanner: false, ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/landing/landing_icon_list.dart
import 'package:express_booking_app/app_icon.dart'; import 'package:express_booking_app/landing/landing_icon.dart'; import 'package:flutter/material.dart'; class LandingIconsList extends StatelessWidget { final icon1 = Icons.account_balance; final icon2 = Icons.directions_car; final icon3 = Icons.directions_bus; final icon4 = Icons.flight_takeoff; final icon5 = Icons.movie; final icon6 = Icons.tram; @override Widget build(BuildContext context) { final row1 = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ LandingIcon(icon1), LandingIcon(icon2) ], ); final row2 = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ LandingIcon(icon3), AppIcon(14, Colors.white), LandingIcon(icon4) ], ); final row3 = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ LandingIcon(icon5), LandingIcon(icon6) ], ); return Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ row1, row2, row3 ], ), ), ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/landing/landing.dart
import 'package:flutter/material.dart'; import 'package:express_booking_app/landing/landing_center_container.dart'; import 'package:express_booking_app/landing/landing_bottom_circle.dart'; class Landing extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFF3834AF), body: Stack( children: <Widget>[ LandingWidgetsContainer(), BottomCircle(436,-50), BottomCircle(490,-150), ], ) ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/landing/landing_bottom_circle.dart
import 'package:flutter/material.dart'; class BottomCircle extends StatelessWidget { double topMargin; double rightMargin; BottomCircle(this.topMargin, this.rightMargin); @override Widget build(BuildContext context) { return Positioned( child: Container( width: 750, height: 300, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( color: Color(0x11FFFFFF), style: BorderStyle.solid, width: 35.0 ), ), ), top: topMargin, right: rightMargin, ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/landing/landing_center_container.dart
import 'package:express_booking_app/login/login.dart'; import 'package:flutter/material.dart'; import 'package:express_booking_app/landing/landing_icon_list.dart'; class LandingWidgetsContainer extends StatelessWidget { @override Widget build(BuildContext context) { return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ LandingIconsList(), Container( width: 180, height: 40, margin: EdgeInsets.only( top: 30.0 ), child: FlatButton( onPressed: (){ Navigator.push(context, MaterialPageRoute(builder: (context) => Login())); }, child: Text('GET STARTED'), color: Color(0xff5E5AD5), textColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(3.0)), ), ), ), ], ), ), ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/landing/landing_icon.dart
import 'package:flutter/material.dart'; class LandingIcon extends StatelessWidget { IconData icon; LandingIcon(this.icon); @override Widget build(BuildContext context) { return Container( height: 45.0, width: 45.0, decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff5E5AD5) ), child: Center( child: Icon( icon, color: Colors.white, ), ), ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/buy_ticket_offers.dart
import 'package:flutter/material.dart'; class OfferTile extends StatelessWidget { Icon offerIc; String title; String subtitle; OfferTile(this.offerIc, this.title, this.subtitle); @override Widget build(BuildContext context) { final tile = ListTile( contentPadding: EdgeInsets.only( top: 5, left: 20, right: 20, bottom: 5 ), leading: offerIc, title: Text( title, style: TextStyle( color: Colors.grey, fontSize: 14, fontFamily: "Roboto", ), ), subtitle: Text( subtitle, style: TextStyle( color: Colors.grey, fontSize: 10, fontFamily: "Roboto", ), ), ); final tileContainer = Container( margin: EdgeInsets.only( left: 20, right: 20, bottom: 20 ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, boxShadow: [ BoxShadow( color: Color(0xffE2E2F3), offset: Offset(0, 3), blurRadius: 3, spreadRadius: 0 ), BoxShadow( color: Color(0xffE2E2F3), offset: Offset(0, 3), blurRadius: 3, spreadRadius: 0 ), BoxShadow( color: Color(0xffE2E2F3), offset: Offset(0, 3), blurRadius: 3, spreadRadius: 0 ) ] ), child: tile, ); return tileContainer; } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/center_logo.dart
import 'package:flutter/material.dart'; class BarCenterLogo extends StatelessWidget { String logo; BarCenterLogo(this.logo); @override Widget build(BuildContext context) { return Align( alignment: Alignment.topCenter, child: Padding( padding: EdgeInsets.only( top: 40 ), child: Image.asset( logo, width: 50, height: 50, ), ) ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/travel_date_container.dart
import 'package:flutter/material.dart'; import 'dart:async'; import 'package:intl/intl.dart'; class TravelDate extends StatefulWidget { @override _TravelDateState createState() => _TravelDateState(); } class _TravelDateState extends State<TravelDate> { final DateTime todayDate = DateTime.now();//Instance of today before $date, so the initialDate>firstDate DateTime date = DateTime.now(); final formatter = DateFormat('yy-MMM-dd-EEE');//February 3, 2019 = 19-Feb-03-Sun List<String> dateInfo;//formate.format(date).split object instance final journeyText = Container( margin: EdgeInsets.only( bottom: 10 ), child: Text( 'Journey date', style: TextStyle( color: Colors.white54, fontSize: 12, fontFamily: "Roboto", ), ), ); @override Widget build(BuildContext context) { dateInfo = formatter.format(date).split("-"); final dayLabel = Container( margin: EdgeInsets.only( right: 8 ), child: Text( dateInfo[2], style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 28 ), ), ); final weekDayNameLabel = Container( margin: EdgeInsets.only( bottom: 6 ), child: Text( dateInfo[3], style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 14 ), ), ); final monthNameLabel = Container( margin: EdgeInsets.only( right: 3 ), child: Text( dateInfo[1], style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 10 ), ), ); final yearNumberLabel = Text( dateInfo[0], style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 10 ), ); final dayRow = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ monthNameLabel, yearNumberLabel ], ); final dayColumn = Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ weekDayNameLabel, dayRow ], ); final dateContainer = InkWell( onTap: (){ _selectDate(context); }, child: Row( children: <Widget>[ dayLabel, dayColumn ], ), ); final datePickerColum = Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ journeyText, dateContainer ], ); final todayButton = Container( width: 60, height: 35, margin: EdgeInsets.only( right: 10 ), child: RaisedButton( padding: EdgeInsets.all(3), textColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4) ), color: Colors.black54, child: Text('Today'), onPressed: (){ setState(() { date = getDate(); }); }, ), ); final tomorrowButton = RaisedButton( padding: EdgeInsets.all(3), textColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4) ), color: Colors.black54, child: Text('Tomorrow'), onPressed: (){ setState(() { date = DateTime(todayDate.year, todayDate.month, todayDate.day+1); }); }, ); final buttonRow = Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ todayButton, tomorrowButton ], ); final travelDateContainer = Container( height: 80, decoration: BoxDecoration( color: Colors.black45, borderRadius: BorderRadius.circular(6), ), margin: EdgeInsets.only( bottom: 10 ), padding: EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ datePickerColum, buttonRow ], ) ); return travelDateContainer; } /* selectDate is a Future<Null> async function because the app will wait till the user picks a date. tutorial -> https://www.youtube.com/watch?v=8sFE8IQyv_c */ Future<Null> _selectDate(BuildContext context) async{ final DateTime picked = await showDatePicker( context: context, initialDate: date, firstDate: getDate(), lastDate: DateTime(2020) ); setState(() { if(picked != null && picked != date){ date = picked; } }); } DateTime getDate(){ //Get today date return DateTime(todayDate.year, todayDate.month, todayDate.day); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/buy_ticket_labels_card.dart
import 'package:express_booking_app/buy_ticket/travel_date_container.dart'; import 'package:flutter/material.dart'; class BuyTicketCard extends StatelessWidget { String background = "assets/travel.jpg"; @override Widget build(BuildContext context) { final fromLabel = Container( margin: EdgeInsets.only( bottom: 10 ), child: TextField( style: TextStyle( color: Colors.white, fontSize: 12, fontFamily: "Roboto", ), decoration: InputDecoration( hintText: 'From', contentPadding: EdgeInsets.all(15), hintStyle: TextStyle( color: Colors.white54, fontSize: 12, fontFamily: "Roboto", ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(6), borderSide: BorderSide.none ), filled: true, fillColor: Colors.black45, ), cursorColor: Colors.white, maxLines: 1, ), ); final toLabel = Container( margin: EdgeInsets.only( bottom: 10 ), child: TextField( style: TextStyle( color: Colors.white, fontSize: 12, fontFamily: "Roboto", ), decoration: InputDecoration( hintText: 'To', contentPadding: EdgeInsets.all(15), hintStyle: TextStyle( color: Colors.white54, fontSize: 12, fontFamily: "Roboto", ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(6), borderSide: BorderSide.none ), filled: true, fillColor: Colors.black45, ), cursorColor: Colors.white, maxLines: 1, ), ); final searchButton = Container( width: 350, height: 50, child: FlatButton( onPressed: ()=>{}, color: Color(0xAA3834AF), child: Text( 'SEARCH BUSES', textAlign: TextAlign.center, ), textColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4) ), padding: EdgeInsets.all(10), ), ); final labelsColum = Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ fromLabel, toLabel, TravelDate(), searchButton, ], ); final ticketCard = Container( margin: EdgeInsets.only( top: 20, bottom: 6, left: 20, right: 20 ), height: 310, padding: EdgeInsets.all(20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage(background), fit: BoxFit.cover ) ), child: labelsColum, ); return ticketCard; } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/buy_ticket_offers_list.dart
import 'package:express_booking_app/buy_ticket/buy_ticket_offers.dart'; import 'package:flutter/material.dart'; class TicketOfferList extends StatelessWidget { final subtitle = "use code first only on app"; final title1 = "Save up to 25% BDT on bus ticket"; final title2 = "Cashback up to 15% on bus ticket"; @override Widget build(BuildContext context) { return ListView( children: <Widget>[ Container( alignment: Alignment.topLeft, margin: EdgeInsets.only( left: 16, bottom: 10 ), child: Text( 'Offers for you', style: TextStyle( fontFamily: "Roboto", fontSize: 14, color: Colors.grey, fontWeight: FontWeight.w600 ), textAlign: TextAlign.start, ), ), OfferTile(Icon(Icons.card_giftcard), title1, subtitle), OfferTile(Icon(Icons.directions_car), title1, subtitle), OfferTile(Icon(Icons.monetization_on), title2, subtitle), OfferTile(Icon(Icons.attach_money), title2, subtitle), ], ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/buy_ticket/buy_ticket_screen.dart
import 'package:express_booking_app/buy_ticket/buy_ticket_labels_card.dart'; import 'package:express_booking_app/buy_ticket/buy_ticket_offers_list.dart'; import 'package:express_booking_app/buy_ticket/center_logo.dart'; import 'package:express_booking_app/bus_companies/header_bar.dart'; import 'package:flutter/material.dart'; class BuyTicketScreen extends StatelessWidget { String logo; BuyTicketScreen(this.logo); @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: <Widget>[ HeaderBar(), Column( children: <Widget>[ BarCenterLogo(logo), BuyTicketCard(), ], ), Container( margin: EdgeInsets.only( top: 410 ), child: TicketOfferList() ) ], ), resizeToAvoidBottomPadding: false, ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/book_ticket/ticket_card.dart
import 'package:express_booking_app/bus_companies/bus_companies_screen.dart'; import 'package:flutter/material.dart'; class TicketCard extends StatelessWidget { IconData cardIcon; String cardTitle; String cardDesc; Color gradient1; Color gradient2; bool doTap; TicketCard(this.cardIcon, this.cardTitle, this.cardDesc, this.gradient1, this.gradient2, this.doTap); @override Widget build(BuildContext context) { final icon = Icon( cardIcon, color: Colors.white, size: 100, ); final title = Container( margin: EdgeInsets.only( top: 10.0 ), child: Text( cardTitle, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontWeight: FontWeight.w600, fontSize: 22, ), ), ); final desc = Container( margin: EdgeInsets.only( top: 10.0 ), child: Text( cardDesc, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 12, ), ), ); final cardContainer = Container( height: 190, width: 180, margin: EdgeInsets.only( top: 12.0, left: 5.0, right: 5.0 ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15.0), gradient: LinearGradient( colors: [ gradient1, gradient2, ], tileMode: TileMode.clamp, begin: FractionalOffset.bottomRight, end: FractionalOffset.centerLeft, ) ), child: InkWell( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ icon, title, desc ], ), onTap: (){ if(doTap){ Navigator.push(context, MaterialPageRoute(builder: (context)=>BusCompaniesScreen())); } }, ) ); return cardContainer; } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/book_ticket/ticket_card_grid.dart
import 'package:flutter/material.dart'; import 'package:express_booking_app/book_ticket/ticket_card.dart'; class TicketsGrid extends StatelessWidget { @override Widget build(BuildContext context) { return Container( child: GridView.count( crossAxisCount: 2, children: <Widget>[ TicketCard(Icons.airplanemode_active, "Flight", "509 flights Available", Color(0xff01C6F8), Color(0xff01EAE2), false), TicketCard(Icons.directions_bus, "Bus", "800+ Bus Available", Color(0xffDCBE22), Color(0xffF9F5A9), true), TicketCard(Icons.train, "Train", "60 train Available", Color(0xff08C79E), Color(0xff80F6BC), false), TicketCard(Icons.local_taxi, "Cab", "5000 Cab Available", Color(0xffA074F3), Color(0xffE6B1F4), false), TicketCard(Icons.movie, "Movie", "12 Movie Hall Available", Color(0xffFF7C58), Color(0xffFFC080), false), TicketCard(Icons.hotel, "Hotel", "400 Hotel Available", Color(0xffFFA4AA), Color(0xffFB6BB1), false), ], ) ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/book_ticket/book_ticket_screen.dart
import 'package:express_booking_app/book_ticket/ticket_card_grid.dart'; import 'package:flutter/material.dart'; class BookTicketScreen extends StatelessWidget { final picLink = "https://pbs.twimg.com/profile_images/725087606522843137/VmtIbx5p_400x400.jpg"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0.0, leading: Icon(Icons.more_vert, color: Color(0xff2521A7)), title: Text( "Book your ticket online", style: TextStyle( color: Color(0xFF3834AF), fontFamily: "Roboto", fontSize: 17 ), ), centerTitle: true, actions: <Widget>[ Container( margin: EdgeInsets.only( right: 10.0, ), child: CircleAvatar( radius: 30, backgroundImage: NetworkImage(picLink), ), ) ], ), body: TicketsGrid(), ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/login/login_button_list.dart
import 'package:express_booking_app/app_icon.dart'; import 'package:express_booking_app/login/login_button.dart'; import 'package:express_booking_app/login/login_divider.dart'; import 'package:flutter/material.dart'; class LoginButtonList extends StatelessWidget { final imgGoogle = AssetImage("assets/google-logo.png"); final imgTwitter = AssetImage("assets/twitter-logo.png"); final imgFacebook = AssetImage("assets/facebook-logo.png"); final template = "Continue with "; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: EdgeInsets.only( bottom: 20.0 ), child: AppIcon(20, Color(0xFF3834AF)) ), LoginButton(imgGoogle,Colors.white, template+"Google", Color(0xFF3834AF)), LoginButton(imgFacebook,Color(0xff475993), template+"Facebook", Colors.white), LoginButton(imgTwitter,Color(0xff28AAE1), template+"Twitter", Colors.white), LoginDivider(), LoginButton(null,Color(0xFF3834AF), "Create new account", Colors.white), ], ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/login/login_button.dart
import 'package:express_booking_app/book_ticket/book_ticket_screen.dart'; import 'package:flutter/material.dart'; class LoginButton extends StatelessWidget { AssetImage image; Color backgroundColor; String text; Color textColor; LoginButton(this.image, this.backgroundColor, this.text, this.textColor); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only( top: 15.0 ), padding: EdgeInsets.only( top: 5.0, left: 8.0 ), width: 300, height: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(3.0), color: backgroundColor, boxShadow: [ BoxShadow( color: Colors.black38, blurRadius: 8.0, offset: Offset( 1.0, 2.0 ) ), ] ), child: InkWell( onTap: (){ Navigator.push(context, MaterialPageRoute(builder: (context) => BookTicketScreen())); }, child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ image == null ? Icon(Icons.person_add, color: Colors.white, size: 30):Image(image: image,height: 30, width: 30), Container( margin: EdgeInsets.only( left: 60.0 ), child: Text( text, style: TextStyle( color: textColor, fontSize: 14, fontFamily: "Roboto", ), textAlign: TextAlign.center, ), ) ], ), ) ); } }
0
mirrored_repositories/Express-Booking-App/lib
mirrored_repositories/Express-Booking-App/lib/login/login_divider.dart
import 'package:express_booking_app/app_icon.dart'; import 'package:flutter/material.dart'; class LoginDivider extends StatelessWidget { final _color = Color(0xffA1A0D9); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only( top: 15.0 ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Container( width: 70, height: 3, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.elliptical(5.0, 5.0)), color: _color, ), ), Container( margin: EdgeInsets.only( left: 8.0, right: 8.0 ), child: AppIcon(8, _color), ), Container( width: 70, height: 3, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.elliptical(5.0, 5.0)), color: _color, ), ) ], ), ); } }
0