repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/Flutter-Apps/budget_management/lib | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/add_expense.dart | import 'package:budget_management/models/expense.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class NewExpense extends StatefulWidget {
const NewExpense({super.key, required this.onAddExpense});
final void Function(Expense expense) onAddExpense;
@override
State<StatefulWidget> createState() {
return _NewExpense();
}
}
class _NewExpense extends State<NewExpense> {
final _inputTitleController = TextEditingController();
final _inputExpenseController = TextEditingController();
Category _selectedCategory = Category.vacation;
DateTime? _selectedDate;
void _inputDatePicker() async {
final now = DateTime.now();
final firstDate = DateTime(now.year - 1, now.month, now.day);
final selectedDate = await showDatePicker(
context: context,
initialDate: now,
firstDate: firstDate,
lastDate: now,
);
setState(() {
_selectedDate = selectedDate;
});
}
void _submitExpense() {
final enteredAmount = double.tryParse(_inputExpenseController.text);
final isAmountInvalid = enteredAmount == null || enteredAmount <= 0;
if (_inputTitleController.text.trim().isEmpty ||
isAmountInvalid ||
_selectedDate == null) {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text(
'Invalid Input',
style: GoogleFonts.lato(fontWeight: FontWeight.bold),
),
content: Text(
'Please input correct value',
style: GoogleFonts.lato(fontWeight: FontWeight.w400),
),
actions: [
TextButton(
onPressed: () {
Navigator.pop(ctx);
},
child: Text(
'Okay',
style: GoogleFonts.lato(fontWeight: FontWeight.bold),
),
)
],
),
);
return;
}
widget.onAddExpense(Expense(
title: _inputTitleController.text,
amount: enteredAmount,
date: _selectedDate!,
category: _selectedCategory));
Navigator.pop(context);
}
@override
void dispose() {
_inputTitleController.dispose();
_inputExpenseController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 48, 16, 16),
child: Column(
children: [
TextField(
controller: _inputTitleController,
maxLength: 50,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
label: Text(
'Title',
),
),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(),
),
const SizedBox(
height: 2,
),
Row(
children: [
Expanded(
child: TextField(
controller: _inputExpenseController,
maxLength: 10,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
prefixText: '€ ',
label: Text(
'Expense',
),
),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(),
),
),
const SizedBox(
width: 16,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_selectedDate == null
? 'No date selected'
: formatter.format(_selectedDate!),
style: GoogleFonts.lato(
fontWeight: FontWeight.normal,
fontSize: 16,
),
),
IconButton(
onPressed: _inputDatePicker,
icon: const Icon(Icons.calendar_month_rounded))
],
))
],
),
Row(
children: [
DropdownButton(
value: _selectedCategory,
items: Category.values
.map(
(category) => DropdownMenuItem(
value: category,
child: Text(
category.name.toUpperCase(),
style:
Theme.of(context).textTheme.bodyMedium!.copyWith(
fontWeight: FontWeight.w400,
),
),
),
)
.toList(),
onChanged: (value) {
if (value == null) {
return;
}
setState(() {
_selectedCategory = value;
});
},
),
const Spacer(),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(
'Cancel',
style: GoogleFonts.lato(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
),
ElevatedButton(
onPressed: _submitExpense,
child: Text(
'Save',
style: GoogleFonts.lato(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
),
],
)
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/expenses.dart | import 'package:budget_management/widgets/add_expense.dart';
import 'package:budget_management/widgets/chart/chart.dart';
import 'package:budget_management/widgets/expenses_list/expenses_list.dart';
import 'package:budget_management/models/expense.dart';
import 'package:flutter/material.dart';
class Expenses extends StatefulWidget {
const Expenses({super.key});
@override
State<Expenses> createState() {
return _Expenses();
}
}
class _Expenses extends State<Expenses> {
final List<Expense> _expeneseList = [
Expense(
title: 'Laptop',
amount: 110.00,
date: DateTime.now(),
category: Category.work,
),
Expense(
title: 'Transportation',
amount: 23.00,
date: DateTime.now(),
category: Category.travel,
),
Expense(
title: 'Fish and Chips',
amount: 12.00,
date: DateTime.now(),
category: Category.food,
),
Expense(
title: 'Ibiza',
amount: 200.00,
date: DateTime.now(),
category: Category.vacation,
),
];
void _addExpense(Expense expense) {
setState(() {
_expeneseList.add(expense);
});
}
void _removeExpense(Expense expense) {
final expenseIndex = _expeneseList.indexOf(expense);
setState(() {
_expeneseList.remove(expense);
});
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 3),
content: const Text('Item Removed'),
action: SnackBarAction(
label: 'Undo',
onPressed: () {
setState(() {
_expeneseList.insert(expenseIndex, expense);
});
},
),
),
);
}
void _openAddExpenseOverLay() {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (ctx) => NewExpense(onAddExpense: _addExpense));
}
@override
Widget build(BuildContext context) {
Widget mainContent = const Center(
child: Text('No items are present in the expense list'),
);
if (_expeneseList.isNotEmpty) {
mainContent = ExpensesList(
expenses: _expeneseList,
onRemove: _removeExpense,
);
}
return Scaffold(
appBar: AppBar(
title: const Text(
'Budget Manager',
),
actions: [
IconButton(
onPressed: _openAddExpenseOverLay,
icon: const Icon(Icons.add),
)
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Chart(expenses: _expeneseList),
Expanded(
child: mainContent,
),
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib/widgets | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/expenses_list/expenses_item.dart | import 'package:budget_management/models/expense.dart';
import 'package:flutter/material.dart';
class ExpenseItem extends StatelessWidget {
const ExpenseItem({super.key, required this.expense});
final Expense expense;
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
expense.title,
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(
height: 4,
),
Row(
children: [
Text(
'€${expense.amount.toStringAsFixed(2)}',
),
const Spacer(),
Row(
children: [
Icon(
categoryIcons[expense.category],
),
const SizedBox(
width: 8,
),
Text(
expense.formattedDate,
)
],
)
],
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib/widgets | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/expenses_list/expenses_list.dart | import 'package:budget_management/models/expense.dart';
import 'package:budget_management/widgets/expenses_list/expenses_item.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class ExpensesList extends StatelessWidget {
const ExpensesList({
super.key,
required this.expenses,
required this.onRemove,
});
final void Function(Expense expense) onRemove;
final List<Expense> expenses;
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: expenses.length,
itemBuilder: (ctx, index) => Dismissible(
key: ValueKey(expenses[index]),
background: Container(
color: Theme.of(context).colorScheme.error.withOpacity(0.8),
margin: const EdgeInsets.symmetric(horizontal: 14),
child: Center(
child: Text(
'Deleted',
style: GoogleFonts.lato(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
),
onDismissed: (direction) {
onRemove(expenses[index]);
},
child: ExpenseItem(expense: expenses[index]),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib/widgets | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/chart/chart.dart | import 'package:flutter/material.dart';
import 'package:budget_management/widgets/chart/chart_bar.dart';
import 'package:budget_management/models/expense.dart';
class Chart extends StatelessWidget {
const Chart({super.key, required this.expenses});
final List<Expense> expenses;
List<ExpenseBucket> get buckets {
return [
ExpenseBucket.forCategory(expenses, Category.food),
ExpenseBucket.forCategory(expenses, Category.vacation),
ExpenseBucket.forCategory(expenses, Category.travel),
ExpenseBucket.forCategory(expenses, Category.work),
];
}
double get maxTotalExpense {
double maxTotalExpense = 0;
for (final bucket in buckets) {
if (bucket.totalExpenses > maxTotalExpense) {
maxTotalExpense = bucket.totalExpenses;
}
}
return maxTotalExpense;
}
@override
Widget build(BuildContext context) {
final isDarkMode =
MediaQuery.of(context).platformBrightness == Brightness.dark;
return Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.symmetric(
vertical: 16,
horizontal: 8,
),
width: double.infinity,
height: 180,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
gradient: LinearGradient(
colors: [
Theme.of(context).colorScheme.primary.withOpacity(0.3),
Theme.of(context).colorScheme.primary.withOpacity(0.0)
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
child: Column(
children: [
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
for (final bucket in buckets) // alternative to map()
ChartBar(
fill: bucket.totalExpenses == 0
? 0
: bucket.totalExpenses / maxTotalExpense,
)
],
),
),
const SizedBox(height: 12),
Row(
children: buckets
.map(
(bucket) => Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Icon(
categoryIcons[bucket.category],
color: isDarkMode
? Theme.of(context).colorScheme.secondary
: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.7),
),
),
),
)
.toList(),
)
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib/widgets | mirrored_repositories/Flutter-Apps/budget_management/lib/widgets/chart/chart_bar.dart | import 'package:flutter/material.dart';
class ChartBar extends StatelessWidget {
const ChartBar({
super.key,
required this.fill,
});
final double fill;
@override
Widget build(BuildContext context) {
final isDarkMode =
MediaQuery.of(context).platformBrightness == Brightness.dark;
return Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: FractionallySizedBox(
heightFactor: fill,
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius:
const BorderRadius.vertical(top: Radius.circular(8)),
color: isDarkMode
? Theme.of(context).colorScheme.secondary
: Theme.of(context).colorScheme.primary.withOpacity(0.65),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management/lib | mirrored_repositories/Flutter-Apps/budget_management/lib/models/expense.dart | import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:uuid/uuid.dart';
const uuid = Uuid();
final formatter = DateFormat.yMd();
enum Category {
food,
travel,
vacation,
work,
}
const categoryIcons = {
Category.food: Icons.food_bank_rounded,
Category.travel: Icons.car_rental_rounded,
Category.vacation: Icons.flight_takeoff_rounded,
Category.work: Icons.work,
};
class Expense {
Expense({
required this.title,
required this.amount,
required this.date,
required this.category,
}) : id = uuid.v4();
final String id;
final String title;
final double amount;
final DateTime date;
final Category category;
String get formattedDate {
return formatter.format(date);
}
}
class ExpenseBucket {
const ExpenseBucket({
required this.category,
required this.expenses,
});
ExpenseBucket.forCategory(List<Expense> allExpenses, this.category)
: expenses = allExpenses
.where((expense) => expense.category == category)
.toList();
final Category category;
final List<Expense> expenses;
double get totalExpenses {
double sum = 0;
for (final expense in expenses) {
sum += expense.amount; // sum = sum + expense.amount
}
return sum;
}
}
| 0 |
mirrored_repositories/Flutter-Apps/budget_management | mirrored_repositories/Flutter-Apps/budget_management/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:budget_management/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-Apps/try_app | mirrored_repositories/Flutter-Apps/try_app/lib/quiz.dart | import 'package:flutter/material.dart';
import 'package:try_app/data/questions.dart';
import 'package:try_app/questions_screen.dart';
import 'package:try_app/summary/result_screen.dart';
import 'package:try_app/start_screen.dart';
class Quiz extends StatefulWidget {
const Quiz({super.key});
@override
State<Quiz> createState() {
return _QuizState();
}
}
class _QuizState extends State<Quiz> {
List<String> selectedAnswer = [];
var activeScreen = 'start-screen';
void switchScreen() {
setState(() {
activeScreen = 'questions-screen';
});
}
void quizRestart() {
setState(() {
selectedAnswer = [];
activeScreen = 'questions-screen';
});
}
void homeScreen() {
setState(() {
selectedAnswer = [];
activeScreen = 'start-screen';
});
}
void chooseAnswer(String userAnswer) {
selectedAnswer.add(userAnswer);
if (selectedAnswer.length == questionList.length) {
setState(() {
activeScreen = 'result-screen';
});
}
}
@override
Widget build(context) {
Widget screenWidget = StartScreen(switchScreen);
if (activeScreen == 'questions-screen') {
screenWidget = QuestionsScreen(
onSelectAnswer: chooseAnswer,
);
}
if (activeScreen == 'result-screen') {
screenWidget = ResultsScreen(
chosenAnswers: selectedAnswer,
onRestart: quizRestart,
onHome: homeScreen);
}
return MaterialApp(
home: Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Color.fromARGB(255, 153, 211, 187),
Color.fromARGB(255, 255, 255, 255),
], begin: Alignment.topCenter),
),
child: screenWidget,
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app | mirrored_repositories/Flutter-Apps/try_app/lib/questions_screen.dart | import 'package:flutter/material.dart';
import 'package:try_app/answer_button.dart';
import 'package:try_app/data/questions.dart';
import 'package:google_fonts/google_fonts.dart';
class QuestionsScreen extends StatefulWidget {
const QuestionsScreen({
super.key,
required this.onSelectAnswer,
});
final void Function(String userAnswer) onSelectAnswer;
@override
State<QuestionsScreen> createState() {
return _QuestionsScreenState();
}
}
class _QuestionsScreenState extends State<QuestionsScreen> {
var indexQuestion = 0;
void answerQuestion(String userAnswer) {
widget.onSelectAnswer(userAnswer);
setState(() {
indexQuestion++;
});
}
@override
Widget build(context) {
final question = questionList[indexQuestion];
return SizedBox(
width: double.infinity,
child: Container(
margin: const EdgeInsets.all(40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
question.question,
style: GoogleFonts.lato(
color: const Color.fromARGB(255, 19, 90, 100),
fontSize: 22,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(
height: 30,
),
...question.getShuffledList().map((item) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AnswerButton(
answers: item,
onTap: () {
answerQuestion(item);
},
),
const SizedBox(
height: 10,
),
],
);
}),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app | mirrored_repositories/Flutter-Apps/try_app/lib/start_screen.dart | import 'package:flutter/material.dart';
class StartScreen extends StatelessWidget {
const StartScreen(this.startQuiz, {super.key});
final void Function() startQuiz;
@override
Widget build(context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/images/b.png',
width: 200,
),
const SizedBox(
height: 30,
),
const Text(
'Quiz Me',
style: TextStyle(
color: Color.fromARGB(255, 19, 90, 100),
fontSize: 28,
fontWeight: FontWeight.w700),
),
const SizedBox(height: 20),
ElevatedButton.icon(
onPressed: startQuiz,
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 241, 202, 27)),
label: const Text(
'Start Quiz',
style:
TextStyle(color: Colors.white, fontWeight: FontWeight.w300),
),
icon: const Icon(Icons.arrow_right_alt),
)
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app | mirrored_repositories/Flutter-Apps/try_app/lib/answer_button.dart | import 'package:flutter/material.dart';
class AnswerButton extends StatelessWidget {
const AnswerButton({super.key, required this.answers, required this.onTap});
final String answers;
final void Function() onTap;
@override
Widget build(context) {
return ElevatedButton(
onPressed: onTap,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 40),
backgroundColor: const Color.fromARGB(255, 19, 90, 100),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
),
child: Text(
answers,
style: const TextStyle(
fontWeight: FontWeight.normal,
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app | mirrored_repositories/Flutter-Apps/try_app/lib/main.dart | import 'package:flutter/material.dart';
import 'package:try_app/quiz.dart';
void main() {
runApp(const Quiz());
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/summary/result_screen.dart | import 'package:flutter/material.dart';
import 'package:try_app/data/questions.dart';
import 'package:try_app/summary/summary.dart';
import 'package:google_fonts/google_fonts.dart';
class ResultsScreen extends StatelessWidget {
const ResultsScreen({
super.key,
required this.chosenAnswers,
required this.onRestart,
required this.onHome,
});
final void Function() onHome;
final void Function() onRestart;
final List<String> chosenAnswers;
List<Map<String, Object>> getSummary() {
List<Map<String, Object>> summary = [];
for (var i = 0; i < chosenAnswers.length; i++) {
summary.add({
'index': i,
'question': questionList[i].question,
'correctAnswer': questionList[i].answer[0],
'userAnswer': chosenAnswers[i],
});
}
return summary;
}
@override
Widget build(BuildContext context) {
final summaryVar = getSummary();
final totalNumQuestion = questionList.length;
final totalNumCorrectAnswer = summaryVar.where((data) {
return data['userAnswer'] == data['correctAnswer'];
}).length;
return SizedBox(
width: double.infinity,
child: Container(
margin: const EdgeInsets.all(40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"You have corretly answered $totalNumCorrectAnswer out of $totalNumQuestion questions",
style: GoogleFonts.lato(
color: const Color.fromARGB(255, 19, 90, 100),
fontSize: 22,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(
height: 30,
),
QuestionSummary(summaryData: summaryVar),
const SizedBox(
height: 60,
),
SizedBox(
width: double.infinity,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 80),
child: TextButton.icon(
onPressed: onRestart,
icon: const Icon(Icons.refresh),
label: const Text('Restart'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 10),
backgroundColor: const Color.fromARGB(255, 19, 90, 100),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)),
)),
),
),
const SizedBox(
height: 10,
),
SizedBox(
width: double.infinity,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 80),
child: TextButton.icon(
onPressed: onHome,
icon: const Icon(Icons.home),
label: const Text('Home'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 10),
backgroundColor: const Color.fromARGB(255, 19, 158, 17),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)),
)),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/summary/summary_item_final.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:try_app/summary/question_identifier.dart';
class SummaryItem extends StatelessWidget {
const SummaryItem({super.key, required this.itemData});
final Map<String, Object> itemData;
@override
Widget build(BuildContext context) {
final isCorrectAnswer = itemData['userAnswer'] == itemData['correctAnswer'];
final questionIndex = itemData['index'] as int;
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
QuestionIdentifer(
questionIndex: questionIndex,
isAnswerCorrect: isCorrectAnswer,
),
const SizedBox(
width: 20,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
itemData['question'].toString(),
style: GoogleFonts.lato(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
const SizedBox(
height: 5,
),
RichText(
text: TextSpan(
text: 'Correct: ',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 12, 121, 57),
),
children: [
TextSpan(
text: itemData['correctAnswer'].toString(),
style: DefaultTextStyle.of(context).style,
),
],
),
),
const SizedBox(
height: 2,
),
RichText(
text: TextSpan(
text: 'Yours: ',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 30, 112, 137),
),
children: [
TextSpan(
text: itemData['userAnswer'].toString(),
style: DefaultTextStyle.of(context).style,
),
],
),
),
const SizedBox(
height: 30,
),
],
))
],
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/summary/summary.dart | import 'package:flutter/material.dart';
import 'package:try_app/summary/summary_item_final.dart';
class QuestionSummary extends StatelessWidget {
const QuestionSummary({super.key, required this.summaryData});
final List<Map<String, Object>> summaryData;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 470,
child: SingleChildScrollView(
child: Column(
children: [
...summaryData.map(
(data) {
return SummaryItem(itemData: data);
},
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/summary/question_identifier.dart | import 'package:flutter/material.dart';
class QuestionIdentifer extends StatelessWidget {
const QuestionIdentifer(
{super.key, required this.questionIndex, required this.isAnswerCorrect});
final bool isAnswerCorrect;
final int questionIndex;
@override
Widget build(BuildContext context) {
final questionNumber = questionIndex + 1;
return Container(
height: 30,
width: 30,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isAnswerCorrect ? Colors.green : Colors.red,
borderRadius: BorderRadius.circular(10),
),
child: Text(
questionNumber.toString(),
style: const TextStyle(
fontWeight: FontWeight.w400,
color: Colors.white,
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/models/quiz_questions.dart | class Questions {
const Questions(this.question, this.answer);
final String question;
final List<String> answer;
List<String> getShuffledList() {
final shuffledList = List.of(answer);
shuffledList.shuffle();
return shuffledList;
}
}
| 0 |
mirrored_repositories/Flutter-Apps/try_app/lib | mirrored_repositories/Flutter-Apps/try_app/lib/data/questions.dart | import 'package:try_app/models/quiz_questions.dart';
const questionList = [
Questions(
"Who is the current President of the United States?",
["Joe Biden", "Donald Trump", "Barack Obama", "George W. Bush"],
),
Questions(
"What is the capital city of Japan?",
["Tokyo", "Beijing", "Seoul", "Bangkok"],
),
Questions(
"Who wrote the play 'Romeo and Juliet'?",
["William Shakespeare", "Jane Austen", "Charles Dickens", "Mark Twain"],
),
Questions(
"In which year did the Titanic sink?",
["1912", "1905", "1920", "1935"],
),
Questions(
"Which planet is known as the 'Red Planet'?",
["Mars", "Venus", "Jupiter", "Saturn"],
),
Questions(
"What is the currency of Australia?",
["Australian Dollar", "Euro", "Pound Sterling", "Yen"],
),
Questions(
"Who is the author of 'To Kill a Mockingbird'?",
["Harper Lee", "J.K. Rowling", "George Orwell", "Ernest Hemingway"],
),
Questions(
"What is the largest ocean on Earth?",
["Pacific Ocean", "Atlantic Ocean", "Indian Ocean", "Arctic Ocean"],
),
Questions(
"Who painted the 'Mona Lisa'?",
["Leonardo da Vinci", "Vincent van Gogh", "Pablo Picasso", "Claude Monet"],
),
Questions(
"Which country is famous for its pyramids?",
["Egypt", "Mexico", "Greece", "China"],
),
];
| 0 |
mirrored_repositories/Flutter-Apps/try_app | mirrored_repositories/Flutter-Apps/try_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 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:try_app/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-Apps/dice_roll | mirrored_repositories/Flutter-Apps/dice_roll/lib/style_text.dart | import 'package:flutter/material.dart';
class StyleText extends StatelessWidget {
const StyleText(this.text, {super.key});
final String text;
@override
Widget build(context) {
return Text(
text,
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 28.0),
textAlign: TextAlign.center,
);
}
}
// final String text;
// @override
// Widget build(context) {
// return Column(
// children: [
// Text(
// text,
// textAlign: TextAlign.left,
// style: const TextStyle(
// color: Colors.white, fontWeight: FontWeight.bold, fontSize: 28.0),
// ),
// // const SizedBox(height: 8),
// Image.asset('assets/images/dice-1.png'),
// ],
// );
// }
// }
| 0 |
mirrored_repositories/Flutter-Apps/dice_roll | mirrored_repositories/Flutter-Apps/dice_roll/lib/background_container.dart | import 'package:flutter/material.dart';
// import 'package:dice_roll/style_text.dart';
import 'package:dice_roll/dice_roller.dart';
class BackgroundContainer extends StatelessWidget {
const BackgroundContainer(this.color1, this.color2, {super.key});
const BackgroundContainer.green({super.key})
: color1 = const Color.fromARGB(255, 228, 241, 153),
color2 = const Color.fromARGB(255, 162, 223, 144);
final Color color1;
final Color color2;
@override
Widget build(context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [color1, color2],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: const Center(child: DiceRoller()),
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/dice_roll | mirrored_repositories/Flutter-Apps/dice_roll/lib/main.dart | import 'package:flutter/material.dart';
import 'package:dice_roll/background_container.dart';
import 'package:dice_roll/style_text.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const StyleText('Dice Game'),
backgroundColor: const Color.fromARGB(255, 90, 167, 88),
centerTitle: true,
),
body: const BackgroundContainer.green(),
),
),
);
}
| 0 |
mirrored_repositories/Flutter-Apps/dice_roll | mirrored_repositories/Flutter-Apps/dice_roll/lib/dice_roller.dart | import 'package:flutter/material.dart';
import 'dart:math';
final randomizer = Random();
class DiceRoller extends StatefulWidget {
const DiceRoller({super.key});
@override
State<DiceRoller> createState() {
return _DiceRollerState();
}
}
class _DiceRollerState extends State<DiceRoller> {
var clickDice = 3;
void rollDice() {
setState(() {
clickDice = randomizer.nextInt(6) + 1;
});
}
@override
Widget build(context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/images/dice-$clickDice.png',
width: 200,
),
ElevatedButton(
onPressed: rollDice,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: Colors.white,
elevation: 5.0,
textStyle: const TextStyle(fontSize: 15.0),
padding: const EdgeInsets.only(top: 5, bottom: 5)),
child: const Text('Roll'),
)
],
);
}
}
| 0 |
mirrored_repositories/Flutter-Apps/dice_roll | mirrored_repositories/Flutter-Apps/dice_roll/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:dice_roll/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-uttils | mirrored_repositories/flutter-uttils/lib/home_page.dart | import 'package:flutter/material.dart';
import 'package:test_app/fragments/bottom_navigation.dart';
import 'package:test_app/fragments/pagination.dart';
import 'package:test_app/network_call_1.dart';
import 'fragments/home_fragment.dart';
import 'fragments/image_view.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Widget _widget = ListPage();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
centerTitle: false,
actions: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(Icons.notifications),
),
IconButton(
onPressed: () {},
icon: Icon(Icons.search),
),
],
),
body: _widget,
// floatingActionButton: FloatingActionButton.extended(
// label: Text('Hello'),
// tooltip: 'hello',
// icon: Icon(Icons.person),
// onPressed: () {
// // Navigator.pushNamed(context, 'second-page');
// showDialog(
// context: context,
// builder: (context) {
// return AlertDialog(
// title: Text(
// 'Hellooo',
// ),
// actions: <Widget>[
// ButtonBar(
// children: <Widget>[
// RaisedButton(
// child: Text(
// 'Yes',
// style: TextStyle(color: Colors.white),
// ),
// onPressed: () {},
// ),
// RaisedButton(
// child: Text(
// 'Cancel',
// style: TextStyle(color: Colors.white),
// ),
// onPressed: () => Navigator.of(context).pop(),
// )
// ],
// ),
// ],
// );
// },
// );
// },
// ),
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
padding: EdgeInsets.all(0),
child: Container(
height: 250,
),
),
ListTile(
onTap: () {
changeWidget('ListView', ListPage());
},
title: Text('ListView'),
leading: Icon(
Icons.list,
color: Colors.red,
),
subtitle: Text(
'Listview Examples',
style: TextStyle(
fontSize: 12,
),
),
),
ListTile(
onTap: () {
changeWidget('ListView', ImageView());
},
title: Text('Images'),
leading: Icon(
Icons.image,
color: Colors.green,
),
subtitle: Text(
'Loading image from url & asset',
style: TextStyle(
fontSize: 12,
),
),
),
ListTile(
onTap: () {
changeWidget('HTTP', NetowrkList());
},
title: Text('HTTP'),
leading: Icon(
Icons.pages,
color: Colors.blue,
),
subtitle: Text(
'Populating list from url',
style: TextStyle(
fontSize: 12,
),
),
),
ListTile(
onTap: () {
changeWidget('BottomBar', Bottomnavigation());
},
title: Text('Bottom Bar'),
leading: Icon(
Icons.pageview,
color: Colors.pink,
),
subtitle: Text(
'Bottom Navigation example',
style: TextStyle(
fontSize: 12,
),
),
),
ListTile(
onTap: () {
changeWidget('Pagination', PaginationPage());
},
title: Text('Pagination Example'),
leading: Icon(
Icons.view_array,
color: Colors.orange,
),
subtitle: Text(
'Paginating through a list of images',
style: TextStyle(
fontSize: 12,
),
),
),
],
),
),
);
}
changeWidget(String name, Widget child) {
setState(() {
_widget = child;
});
Navigator.pop(context);
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/datamodel.dart | // To parse this JSON data, do
//
// final dataResponse = dataResponseFromJson(jsonString);
import 'dart:convert';
DataResponse dataResponseFromJson(String str) => DataResponse.fromJson(json.decode(str));
String dataResponseToJson(DataResponse data) => json.encode(data.toJson());
class DataResponse {
List<OfferList> offerList;
String status;
DataResponse({
this.offerList,
this.status,
});
factory DataResponse.fromJson(Map<String, dynamic> json) => new DataResponse(
offerList: new List<OfferList>.from(json["offer_list"].map((x) => OfferList.fromJson(x))),
status: json["status"],
);
Map<String, dynamic> toJson() => {
"offer_list": new List<dynamic>.from(offerList.map((x) => x.toJson())),
"status": status,
};
}
class OfferList {
String cash;
String des;
String image;
int img;
String offer;
OfferList({
this.cash,
this.des,
this.image,
this.img,
this.offer,
});
factory OfferList.fromJson(Map<String, dynamic> json) => new OfferList(
cash: json["cash"],
des: json["des"],
image: json["image"],
img: json["img"],
offer: json["offer"],
);
Map<String, dynamic> toJson() => {
"cash": cash,
"des": des,
"image": image,
"img": img,
"offer": offer,
};
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/second_page.dart | import 'package:flutter/material.dart';
class Secondpage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Second Page'),
),
body: RaisedButton(
child: Text('Finish'),
onPressed: (){
Navigator.pop(context);
},
),
);
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/list.dart | import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'datamodel.dart';
import 'dart:convert';
class Listpage extends StatefulWidget {
const Listpage({Key key}) : super(key: key);
@override
_ListpageState createState() => _ListpageState();
}
class _ListpageState extends State<Listpage> {
ScrollController _scrollController = ScrollController();
List<OfferList> _list = [];
@override
void initState() {
super.initState();
getData();
_scrollController.addListener((){
if(_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
print('Yes');
}
});
}
@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
appBar: AppBar(
title: Text('ListView'),
),
body: _list.length > 0
? ListView.builder(
controller: _scrollController,
itemCount: _list.length,
itemBuilder: (context, index) {
OfferList data = _list[index];
return ListTile(
title: Text(data.offer),
);
},
)
: Center(
child: CircularProgressIndicator(),
),
),
);
}
void getData() async {
var data =
await http.get('https://limo-9264.firebaseio.com/home_offers.json');
DataResponse datamodel = DataResponse.fromJson(json.decode(data.body));
print(datamodel.status);
setState(() {
_list = datamodel.offerList;
});
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/login.dart | import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
String dropdownValue = 'One';
String _phone = '';
String _password = '';
bool _hidePassword = true;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
elevation: 0,
title: Text('Login'),
),
body: Center(
child: Card(
child: Column(
// mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 32,
),
Text('Please Login to proceed.'),
Padding(
padding:
EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 16),
child: TextField(
onChanged: (value) {
_phone = value;
},
keyboardType: TextInputType.phone,
decoration: InputDecoration(
labelText: 'Phone',
border: OutlineInputBorder(),
prefix: Text('+91 '),
prefixIcon: Icon(Icons.phone)),
),
),
Container(
padding: EdgeInsets.all(16),
child: TextField(
obscureText: _hidePassword,
onChanged: (sruthi) {
_password = sruthi;
},
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.lock),
suffixIcon: IconButton(
onPressed: () {
setState(() {
_hidePassword = !_hidePassword;
});
},
icon: Icon(_hidePassword
? Icons.visibility_off
: Icons.visibility),
),
),
),
),
RaisedButton(
color: Colors.black,
onPressed: () {
print('$_phone $_password');
Navigator.pushNamed(context, 'home-page');
},
child: Text(
'Submit',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/network_call_1.dart | import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'service/api_service.dart';
import 'datamodel.dart';
class NetowrkList extends StatefulWidget {
const NetowrkList({Key key}) : super(key: key);
@override
_NetowrkListState createState() => _NetowrkListState();
}
class _NetowrkListState extends State<NetowrkList> {
ScrollController _scrollController = ScrollController();
@override
void initState() {
// TODO: implement initState
super.initState();
_scrollController.addListener((){
if(_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
print('Yes');
}
});
}
@override
Widget build(BuildContext context) {
return Container(
child: Material(
child: FutureBuilder(
future: getData(),
builder:
(BuildContext context, AsyncSnapshot<DataResponse> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
controller: _scrollController,
itemCount: snapshot.data.offerList.length,
itemBuilder: (context, index) {
OfferList data = snapshot.data.offerList[index];
return ListTile(
onTap: () {
},
trailing: Icon(Icons.check_box),
title: Text(data.des),
subtitle: Text(data.cash),
leading: CircleAvatar(
backgroundImage: NetworkImage(data.image)
),
);
},
);
} else {
return Center(
child: Text('Data not found'),
);
}
},
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/lib/main.dart | import 'package:flutter/material.dart';
import 'fragments/image_view.dart';
import 'second_page.dart';
import 'home_page.dart';
import 'login.dart';
void main() => runApp(Myapp());
class Myapp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: {
'second-page': (BuildContext context) => Secondpage(),
'home-page': (BuildContext context) => HomePage(),
'images-page': (BuildContext context) => ImageView(),
'/': (context) => LoginPage()
},
theme: ThemeData(
primaryColor: Colors.blue,
brightness: Brightness.light,
),
debugShowCheckedModeBanner: false,
);
}
}
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/model/pixabay_model.dart | // To parse this JSON data, do
//
// final pixabayModel = pixabayModelFromJson(jsonString);
import 'dart:convert';
PixabayModel pixabayModelFromJson(String str) => PixabayModel.fromJson(json.decode(str));
String pixabayModelToJson(PixabayModel data) => json.encode(data.toJson());
class PixabayModel {
int totalHits;
List<Hit> hits;
int total;
PixabayModel({
this.totalHits,
this.hits,
this.total,
});
factory PixabayModel.fromJson(Map<String, dynamic> json) => new PixabayModel(
totalHits: json["totalHits"],
hits: new List<Hit>.from(json["hits"].map((x) => Hit.fromJson(x))),
total: json["total"],
);
Map<String, dynamic> toJson() => {
"totalHits": totalHits,
"hits": new List<dynamic>.from(hits.map((x) => x.toJson())),
"total": total,
};
}
class Hit {
String largeImageUrl;
int webformatHeight;
int webformatWidth;
int likes;
int imageWidth;
int id;
int userId;
int views;
int comments;
String pageUrl;
int imageHeight;
String webformatUrl;
Type type;
int previewHeight;
String tags;
int downloads;
String user;
int favorites;
int imageSize;
int previewWidth;
String userImageUrl;
String previewUrl;
Hit({
this.largeImageUrl,
this.webformatHeight,
this.webformatWidth,
this.likes,
this.imageWidth,
this.id,
this.userId,
this.views,
this.comments,
this.pageUrl,
this.imageHeight,
this.webformatUrl,
this.type,
this.previewHeight,
this.tags,
this.downloads,
this.user,
this.favorites,
this.imageSize,
this.previewWidth,
this.userImageUrl,
this.previewUrl,
});
factory Hit.fromJson(Map<String, dynamic> json) => new Hit(
largeImageUrl: json["largeImageURL"],
webformatHeight: json["webformatHeight"],
webformatWidth: json["webformatWidth"],
likes: json["likes"],
imageWidth: json["imageWidth"],
id: json["id"],
userId: json["user_id"],
views: json["views"],
comments: json["comments"],
pageUrl: json["pageURL"],
imageHeight: json["imageHeight"],
webformatUrl: json["webformatURL"],
type: typeValues.map[json["type"]],
previewHeight: json["previewHeight"],
tags: json["tags"],
downloads: json["downloads"],
user: json["user"],
favorites: json["favorites"],
imageSize: json["imageSize"],
previewWidth: json["previewWidth"],
userImageUrl: json["userImageURL"],
previewUrl: json["previewURL"],
);
Map<String, dynamic> toJson() => {
"largeImageURL": largeImageUrl,
"webformatHeight": webformatHeight,
"webformatWidth": webformatWidth,
"likes": likes,
"imageWidth": imageWidth,
"id": id,
"user_id": userId,
"views": views,
"comments": comments,
"pageURL": pageUrl,
"imageHeight": imageHeight,
"webformatURL": webformatUrl,
"type": typeValues.reverse[type],
"previewHeight": previewHeight,
"tags": tags,
"downloads": downloads,
"user": user,
"favorites": favorites,
"imageSize": imageSize,
"previewWidth": previewWidth,
"userImageURL": userImageUrl,
"previewURL": previewUrl,
};
}
enum Type { PHOTO, VECTOR_SVG }
final typeValues = new EnumValues({
"photo": Type.PHOTO,
"vector/svg": Type.VECTOR_SVG
});
class EnumValues<T> {
Map<String, T> map;
Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
if (reverseMap == null) {
reverseMap = map.map((k, v) => new MapEntry(v, k));
}
return reverseMap;
}
}
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/service/api_service.dart | import 'package:test_app/datamodel.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<DataResponse> getData() async {
var data =
await http.get('https://limo-9264.firebaseio.com/home_offers.json');
DataResponse datamodel = DataResponse.fromJson(json.decode(data.body));
if(data.statusCode == 200) {
return datamodel;
} else return DataResponse();
}
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/fragments/home_fragment.dart | import 'package:flutter/material.dart';
class ListPage extends StatefulWidget {
@override
_ListPageState createState() => _ListPageState();
}
class _ListPageState extends State<ListPage> {
final List<DataModel> _myList = [
DataModel('Leo', "Nagercoil"),
DataModel('Akhil', "Kerala"),
DataModel('Abhijth', "Trivanduram"),
DataModel('Akarsh', "Calicut"),
DataModel('Sruthi', "Kottayam"),
];
ScrollController _scrollController = ScrollController();
@override
void initState() {
super.initState();
_scrollController.addListener(
() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
print('Yes');
}
},
);
}
@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
body: ListView.separated(
itemCount: _myList.length,
controller: _scrollController,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(_myList[index].name),
subtitle: Text(_myList[index].city),
leading: Icon(Icons.person),
onTap: () {},
);
},
separatorBuilder: (context, index) {
return index == 3
? LimitedBox(
maxHeight: 4,
child: Container(
color: Colors.black,
),
maxWidth: 4,
)
: Container();
},
),
));
}
}
class DataModel {
String name;
String city;
DataModel(this.name, this.city);
}
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/fragments/image_preview.dart | import 'package:flutter/material.dart';
import 'package:test_app/model/pixabay_model.dart';
class ImagePreview extends StatelessWidget {
final Hit hit;
ImagePreview(this.hit);
@override
Widget build(BuildContext context) {
return Material(
color: Colors.black,
child: Stack(
children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
color: Colors.white,
child: Hero(
tag: hit.largeImageUrl,
child: Image.network(
hit.largeImageUrl,
fit: BoxFit.cover,
// loadingBuilder: (context, child, event) {
// return event == null
// ? child
// : Center(
// child: SizedBox(
// width: 32,
// height: 32,
// child: CircularProgressIndicator(),
// ),
// );
// },
),
),
),
Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
),
),
// Padding(
// padding: EdgeInsets.all(32),
// child: IconButton(
// onPressed: () => Navigator.pop(context),
// icon: Icon(
// Icons.arrow_back,
// color: Colors.white,
// ),
// ),
// )
],
),
);
}
}
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/fragments/image_view.dart | import 'package:flutter/material.dart';
class ImageView extends StatelessWidget {
const ImageView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
body: Column(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
color: Colors.green,
child: Image.network(
'https://i.pinimg.com/originals/bc/c0/86/bcc0860537b4030e6e62fa0a38ef907b.jpg',
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent event) {
if(event == null) return child;
else
return Center(
child: CircularProgressIndicator(),
);
},
fit: BoxFit.cover,
),
)),
Expanded(
flex: 1,
child: Container(
// height: 150,
child: Image.asset(
'images/image1.jpeg',
fit: BoxFit.cover,
),
color: Colors.blue,
),
)
],
),
));
}
}
// class ZigZagClipper extends CustomClipper<Path> {
// // ClipType clipType;
// // ZigZagClipper(this.clipType);
// @override
// Path getClip(Size size) {
// // TODO: implement getClip
// Path path = Path();
// path.lineTo(0, size.height);
// path.quadraticBezierTo(
// size.width / 4, size.height - 40, size.width / 2, size.height - 20);
// path.quadraticBezierTo(
// 3 / 4 * size.width, size.height, size.width, size.height - 30);
// path.lineTo(size.width, 0);
// path.close();
// return path;
// }
// @override
// bool shouldReclip(CustomClipper<Path> oldClipper) {
// // TODO: implement shouldReclip
// return true;
// }
// }
| 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/fragments/bottom_navigation.dart | import 'package:flutter/material.dart';
class Bottomnavigation extends StatefulWidget {
Bottomnavigation({Key key}) : super(key: key);
_BottomnavigationState createState() => _BottomnavigationState();
}
class _BottomnavigationState extends State<Bottomnavigation> {
@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
bottomNavigationBar: BottomAppBar(
// color: Colors.pink,
child: Row(
children: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(Icons.home),
)
],
),
),
),
);
}
} | 0 |
mirrored_repositories/flutter-uttils/lib | mirrored_repositories/flutter-uttils/lib/fragments/pagination.dart | import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:test_app/fragments/image_preview.dart';
import 'dart:io';
import 'dart:convert';
import 'package:test_app/model/pixabay_model.dart';
class PaginationPage extends StatefulWidget {
PaginationPage({Key key}) : super(key: key);
_PaginationPageState createState() => _PaginationPageState();
}
class _PaginationPageState extends State<PaginationPage> {
List<Hit> _imageList = List<Hit>();
ScrollController _scrollController = ScrollController();
int page = 1;
bool isLoading = false;
@override
void initState() {
super.initState();
getImages(page);
_scrollController.addListener(() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
page += 1;
print('Scroll pos $_scrollController.position');
print('Length ${_imageList.length}');
print(page);
getImages(page);
setState(() {
isLoading = true;
});
}
});
}
@override
Widget build(BuildContext context) {
return Material(
child: Stack(
children: [
ListView.builder(
controller: _scrollController,
itemCount: _imageList.length,
itemBuilder: (context, index) {
Hit hit = _imageList[index];
return Hero(
tag: hit.largeImageUrl,
child: Material(
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImagePreview(hit)));
},
child: Container(
width: double.infinity,
height: MediaQuery.of(context).size.width * 0.60,
margin: EdgeInsets.all(4),
// color: Colors.black,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
hit.webformatUrl,
),
fit: BoxFit.cover)),
),
),
),
);
},
),
Align(
alignment: Alignment.bottomCenter,
child: isLoading
? Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(
strokeWidth: 3,
),
),
Text(
'Loading..',
style: TextStyle(fontSize: 18, color: Colors.black),
)
],
),
margin: EdgeInsets.only(bottom: 16),
padding: EdgeInsets.only(
left: 4,
right: 4,
top: 16,
bottom: 16,
),
width: 175,
// height: 45,
// color: Colors.white,
decoration: BoxDecoration(
// border: Border.all(color: Colors.blue,width: 4),
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(32))),
)
: Container(),
),
],
),
);
}
void getImages(int _page) async {
final response = await http.get(
'https://pixabay.com/api?key=12900320-f89616c91146daffabb68bab0&page=$page',
headers: {
HttpHeaders.contentTypeHeader: 'application/x-www-form-urlencoded'
});
if (response.statusCode == 200) {
PixabayModel pixabayModel =
PixabayModel.fromJson(json.decode(response.body));
// print(pixabayModel.toJson());
if (pixabayModel.totalHits > 0) {
setState(() {
_imageList.addAll(pixabayModel.hits);
isLoading = false;
});
}
} else {}
}
}
| 0 |
mirrored_repositories/flutter-uttils | mirrored_repositories/flutter-uttils/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:test_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/My-Expenses | mirrored_repositories/My-Expenses/lib/main.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '/widgets/chart.dart';
import '/widgets/transaction_list.dart';
import '/widgets/new_transaction.dart';
import 'models/transaction.dart';
void main() {
// WidgetsFlutterBinding.ensureInitialized();
// SystemChrome.setPreferredOrientations([
// DeviceOrientation.portraitUp
// ]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter App',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final List<Transaction> transactions = [
// Transaction(
// id: 'id1', title: 'New Shoes', amount: 400, date: DateTime.now()),
// Transaction(
// id: 'id2', title: 'Groceries', amount: 100, date: DateTime.now()),
];
bool showChart = false;
List<Transaction> get recentTransaction{
return transactions.where((element) {
return element.date.isAfter(DateTime.now().subtract(Duration(days: 7)));
}).toList();
}
void addNewTransaction(String Title, double Amount, DateTime dateSelected){
var newTx = Transaction(
id: DateTime.now().toString(),
title: Title,
amount: Amount,
date: dateSelected);
setState(() {
transactions.add(newTx);
});
}
void startAddNewTransaction(BuildContext ctx){
showModalBottomSheet(
isScrollControlled: true,
context: ctx,
backgroundColor:Color.fromARGB(255, 43, 42, 42),
builder: (_){
return Newtransaction(addNewTransaction);
});
}
void deleteTransaction(String id){
setState(() {
return transactions.removeWhere((element) => element.id == id);
});
}
@override
Widget build(BuildContext context) {
final isLandscape = MediaQuery.of(context).orientation == Orientation.landscape;
final appBar = AppBar(
actions: [
Platform.isIOS ?
IconButton(onPressed: () {
startAddNewTransaction(context);
},
icon: Icon(Icons.add, color: Colors.white,)) :
Container(),
],
backgroundColor:Color.fromARGB(255, 161, 15, 246) ,
title: Text("My Expenses"),
);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.black,
appBar: appBar,
body: SingleChildScrollView(
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if(isLandscape)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Show Chart",style: TextStyle(color: Colors.white),),
Switch.adaptive(
inactiveTrackColor: Colors.grey,
activeColor: Color.fromARGB(255, 161, 15, 246),
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.3,
child: Chart(recentTransaction)),
if(!isLandscape)
Container(
height: (MediaQuery.of(context).size.height -
appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.7,
child: TransactionList(transactions,deleteTransaction)),
if(isLandscape)showChart
? Container(
height: (MediaQuery.of(context).size.height -
appBar.preferredSize.height - MediaQuery.of(context).padding.top)* 0.6,
child: Chart(recentTransaction))
: Container(
height: (MediaQuery.of(context).size.height -
appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.7,
child: TransactionList(transactions,deleteTransaction)),
],
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: Platform.isIOS?Container():
FloatingActionButton(
backgroundColor: Color.fromARGB(255, 161, 15, 246),
child: Icon(Icons.add),
onPressed: () {
startAddNewTransaction(context);
},
),
),
);
}
}
| 0 |
mirrored_repositories/My-Expenses/lib | mirrored_repositories/My-Expenses/lib/widgets/new_transaction.dart |
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class Newtransaction extends StatefulWidget {
final Function addTx;
Newtransaction(this.addTx);
@override
State<Newtransaction> createState() => _NewtransactionState();
}
class _NewtransactionState extends State<Newtransaction> {
final titlecontroller = TextEditingController();
final amountController = TextEditingController();
DateTime? selectedDate;
void submitData(){
final enteredTitle = titlecontroller.text;
final enteredAmount = double.parse(amountController.text);
if((titlecontroller.text).isEmpty || double.parse(amountController.text) <= 0 || selectedDate == null){
return;
}
widget.addTx(
enteredTitle,
enteredAmount,
selectedDate,
);
Navigator.of(context).pop();
}
void datePicker(){
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2023),
lastDate: DateTime.now(),
builder: (context, child) {
return Theme(
data: ThemeData.dark().copyWith(
colorScheme: ColorScheme.dark(
primary: Color.fromARGB(255, 161, 15, 246),
onPrimary: Colors.white,
surface: Color.fromARGB(255, 161, 15, 246),
onSurface: Colors.white,
),
dialogBackgroundColor:Color.fromARGB(255, 43, 42, 42),
),
child: child!);
},
).then((value){
if(value == null){
return;
}
setState(() {
selectedDate = value;
});
});
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Card(
color: Color.fromARGB(255, 43, 42, 42),
child: Container(
padding: EdgeInsets.only(
top: 10,
left: 10,
right: 10,
bottom: MediaQuery.of(context).viewInsets.bottom + 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextField(
cursorColor: Color.fromARGB(255, 161, 15, 246),
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
labelText: "Title",
labelStyle:TextStyle(color: Colors.white),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color.fromARGB(255, 161, 15, 246),
)
)),
controller: titlecontroller,
keyboardType: TextInputType.name,
onSubmitted: (value) => submitData(),),
TextField(
style: TextStyle(color: Colors.white),
cursorColor: Color.fromARGB(255, 161, 15, 246),
decoration: InputDecoration(
labelText: "Amount",
labelStyle:TextStyle(color: Colors.white),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color.fromARGB(255, 161, 15, 246),
)
)),
controller: amountController,
keyboardType: TextInputType.number,
onSubmitted: (value) => submitData()),
Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
Expanded(
child: Text(selectedDate == null ? "No Date Chosen!" : "Picked Date : ${DateFormat.yMMMd().format(selectedDate!)}",style:TextStyle(color: Colors.white),)),
TextButton(onPressed: (() {
datePicker();
}), child: Text("Choose A Date", style: TextStyle(fontWeight: FontWeight.bold,color: Color.fromARGB(255, 161, 15, 246)),))
],
),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color.fromARGB(255, 161, 15, 246))),
onPressed: submitData,
child: Text("Add Transaction",style: TextStyle(fontWeight: FontWeight.bold),)),
],
),
),
),
);
}
} | 0 |
mirrored_repositories/My-Expenses/lib | mirrored_repositories/My-Expenses/lib/widgets/transaction_list.dart | import 'package:flutter/material.dart';
import '../models/transaction.dart';
import 'package:intl/intl.dart';
class TransactionList extends StatelessWidget {
final List<Transaction> user_transactions;
final Function delTx;
TransactionList(this.user_transactions, this.delTx);
@override
Widget build(BuildContext context) {
return Container(
child: user_transactions.isEmpty ? Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Text("Not Tansaction Added Yet!",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white),),
),
)
],
):ListView.builder(
itemBuilder: (context, index) {
return Card(
color: Color.fromARGB(255, 54, 54, 54),
elevation: 5,
margin: EdgeInsets.symmetric(vertical: 8,horizontal: 10),
child: ListTile(
leading: CircleAvatar(
backgroundColor: Color.fromARGB(255, 161, 15, 246),
radius: 30,
child: Padding(
padding: const EdgeInsets.all(10),
child: FittedBox(
child: Text("₹:${user_transactions[index].amount}",style: TextStyle(fontWeight: FontWeight.bold,),)),
),
),
title: Text(user_transactions[index].title, style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white),),
subtitle: Text(DateFormat.yMMMd().format(user_transactions[index].date),style: TextStyle(color: Colors.white54)),
trailing: IconButton(
icon: Icon(Icons.delete),
color: Color.fromARGB(255, 234, 49, 74),
onPressed: () {
delTx(user_transactions[index].id);
},),
),
);
},
itemCount: user_transactions.length,
)
);
}
} | 0 |
mirrored_repositories/My-Expenses/lib | mirrored_repositories/My-Expenses/lib/widgets/chart.dart | import 'package:flutter/material.dart';
import 'package:personal_expenses/widgets/chart_bar.dart';
import '/models/transaction.dart';
import 'package:intl/intl.dart';
class Chart extends StatelessWidget {
List<Transaction> recentTransaction;
Chart(this.recentTransaction);
List<Map<String, Object>> get getGroupedTransactionValues{
return List.generate(7, (index) {
final weekDay = DateTime.now().subtract(Duration(days: index));
var totalSum = 0.0;
for(var i =0; i<recentTransaction.length; i++){
if(recentTransaction[i].date.day == weekDay.day &&
recentTransaction[i].date.month == weekDay.month &&
recentTransaction[i].date.year == weekDay.year){
totalSum += recentTransaction[i].amount;
}
}
return{'day': DateFormat.E().format(weekDay).substring(0,1), 'amount': totalSum};
}).reversed.toList();
}
double get maxSpending{
return getGroupedTransactionValues.fold(0.0, (sum, item) {
return sum + (item['amount'] as double);
});
}
@override
Widget build(BuildContext context) {
return Card(
color: Color.fromARGB(255, 43, 42, 42),
elevation: 6,
margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
child: Padding(
padding: EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: getGroupedTransactionValues.map((data) {
return Flexible(
fit: FlexFit.tight,
child: ChartBar(
data['day'].toString(),
data['amount'] as double,
maxSpending == 0.0 ? 0.0: (data['amount'] as double) / maxSpending),
);
}).toList(),
),
),
);
}
} | 0 |
mirrored_repositories/My-Expenses/lib | mirrored_repositories/My-Expenses/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, Constraints) {
return Column(
children: [
Container(
height: Constraints.maxHeight * 0.15,
child: FittedBox(
child: Text('₹${spendingAmount.toStringAsFixed(0)}',style: TextStyle(color: Colors.white),)),
),
SizedBox(
height: Constraints.maxHeight * 0.05,
),
Container(
height: Constraints.maxHeight * 0.6,
width: 10,
child: Stack(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey, width: 1),
color: Color.fromARGB(255, 183, 182, 182),
borderRadius: BorderRadius.circular(10),
),
),
FractionallySizedBox(
heightFactor: spendingPctOfTotal,
child: Container(
decoration: BoxDecoration(
color: Color.fromARGB(255, 161, 15, 246),
borderRadius: BorderRadius.circular(10)),
),
),
],
),
),
SizedBox(
height: Constraints.maxHeight * 0.05,
),
Container(
height: Constraints.maxHeight * 0.15,
child: FittedBox(
child: Text(label,style: TextStyle(color: Colors.white)))),
],
);
});
}
} | 0 |
mirrored_repositories/My-Expenses/lib | mirrored_repositories/My-Expenses/lib/models/transaction.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/My-Expenses | mirrored_repositories/My-Expenses/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:personal_expenses/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/firebase-chatapp | mirrored_repositories/firebase-chatapp/lib/constants.dart | import 'package:flutter/material.dart';
const kSendButtonTextStyle = TextStyle(
color: Colors.lightBlueAccent,
fontWeight: FontWeight.bold,
fontSize: 18.0,
);
const kMessageTextFieldDecoration = InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
hintText: 'Type your message here...',
border: InputBorder.none,
);
const kMessageContainerDecoration = BoxDecoration(
border: Border(
top: BorderSide(color: Colors.lightBlueAccent, width: 2.0),
),
);
const kInputDecoration = InputDecoration(
hintText: 'Enter your email',
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.lightBlueAccent, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.lightBlueAccent, width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
); | 0 |
mirrored_repositories/firebase-chatapp | mirrored_repositories/firebase-chatapp/lib/main.dart | import 'package:chatapp/presentation/chat_screen.dart';
import 'package:chatapp/presentation/login_screen.dart';
import 'package:chatapp/presentation/registration_screen.dart';
import 'package:chatapp/presentation/welcome_screen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(FlashChat());
}
class FlashChat extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: WelcomeScreen.id,
routes: {
WelcomeScreen.id: (context) => WelcomeScreen(),
ChatScreen.id: (context) => ChatScreen(),
LoginScreen.id: (context) => LoginScreen(),
RegistrationScreen.id: (context) => RegistrationScreen(),
});
}
}
| 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/widgets/custom_button.dart | import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
CustomButton({required this.text, required this.color, required this.onPressed});
final String text;
final Color color;
final Function onPressed;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Material(
elevation: 5.0,
color: color,
borderRadius: BorderRadius.circular(30.0),
child: MaterialButton(
textColor: Colors.white,
onPressed: () => onPressed(),
minWidth: 200.0,
height: 42.0,
child: Text(
text,
),
),
),
);
}
} | 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/widgets/chat_bubbe.dart | import 'package:flutter/material.dart';
class ChatBubble extends StatelessWidget {
ChatBubble({required this.text, required this.sender, required this.isUser});
bool isUser;
String text;
String sender;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Column(
crossAxisAlignment: isUser? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [
Text(sender, style: TextStyle(fontSize: 12, color: Colors.black54),),
Material(
elevation: 8,
borderRadius: isUser? BorderRadius.only(topLeft: Radius.circular(20), bottomRight: Radius.circular(20), bottomLeft:Radius.circular(20)):BorderRadius.only(topRight: Radius.circular(20), bottomRight: Radius.circular(20), bottomLeft:Radius.circular(20)),
color: isUser? Colors.lightBlue : Colors.grey[200],
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10),
child: Text(text, style: TextStyle(color: isUser? Colors.white: Colors.black54,
fontSize: 18),),
),
)
],
),
);
}
} | 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/widgets/stream_builder_chat_area.dart | import 'package:chatapp/widgets/chat_bubbe.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class StreamBuilderChatArea extends StatelessWidget {
const StreamBuilderChatArea({
Key? key,
required FirebaseFirestore firestore,
required this.mail,
}) : _firestore = firestore, super(key: key);
final FirebaseFirestore _firestore;
final String? mail;
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('messages').orderBy('timestamp').snapshots(),
builder: (context, snapshot){
if(!snapshot.hasData){
return Center(child: CircularProgressIndicator(
backgroundColor: Colors.lightBlue,
),);}
final messages = snapshot.data!.docs.reversed;
List<ChatBubble> messageWidgets = [];
for(var message in messages){
final messageText = message['text'];
final messageSender = message['sender'];
final isUser = messageSender == mail ? true : false;
final messageWidget = ChatBubble(text: messageText, sender: messageSender, isUser : isUser);
messageWidgets.add(messageWidget);
}
return Expanded(
child: ListView(
reverse: true,
children: messageWidgets,
),
);
});
}
} | 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/presentation/registration_screen.dart | import 'package:chatapp/constants.dart';
import 'package:chatapp/presentation/chat_screen.dart';
import 'package:chatapp/widgets/custom_button.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
class RegistrationScreen extends StatefulWidget {
static const String id = 'registration_screen';
@override
_RegistrationScreenState createState() => _RegistrationScreenState();
}
class _RegistrationScreenState extends State<RegistrationScreen> {
final _auth = FirebaseAuth.instance;
late String email;
late String password;
bool showSpinner = false ;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: ModalProgressHUD(
inAsyncCall: showSpinner,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Flexible(
child: Hero(
tag: 'logo',
child: Container(
height: 200.0,
child: Image.asset('images/logo.png'),
),
),
),
SizedBox(
height: 48.0,
),
TextField(
keyboardType: TextInputType.emailAddress,
textAlign: TextAlign.center,
onChanged: (value) {
email = value;
},
decoration:
kInputDecoration.copyWith(hintText: 'Enter your email')),
SizedBox(
height: 8.0,
),
TextField(
textAlign: TextAlign.center,
obscureText: true,
onChanged: (value) {
password = value;
},
decoration:
kInputDecoration.copyWith(hintText: 'Enter your password')),
SizedBox(
height: 24.0,
),
CustomButton(
text: 'Register',
color: Colors.blue,
onPressed: () async{
setState(() {
showSpinner = true;
});
try{
final newUser = await _auth.createUserWithEmailAndPassword(email: email, password: password);
if(newUser != null){Navigator.pushReplacementNamed(context, ChatScreen.id);}}
catch(e){
print(e);
}})
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/presentation/welcome_screen.dart | import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:chatapp/presentation/login_screen.dart';
import 'package:chatapp/presentation/registration_screen.dart';
import 'package:chatapp/widgets/custom_button.dart';
import 'package:flutter/material.dart';
class WelcomeScreen extends StatefulWidget {
static const String id = 'welcome_screen';
@override
_WelcomeScreenState createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> with SingleTickerProviderStateMixin{
late AnimationController controller;
late Animation animation;
@override
void initState() {
// TODO: implement initState
super.initState();
controller = AnimationController(
duration: Duration(seconds: 2),
vsync: this);
animation = ColorTween(begin: Colors.blueGrey, end: Colors.white).animate(controller);
//animation = CurvedAnimation(parent: controller, curve: Curves.easeIn);
controller.forward();
/*controller.addStatusListener((status) {
if(status ==AnimationStatus.completed){controller.reverse(from: 1.0);}
else if (status ==AnimationStatus.dismissed){controller.forward();}
});*/
controller.addListener(() {
setState(() {
});
print(animation.value);});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
controller.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: animation.value,
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Hero(
tag: 'logo',
child: Container(
child: Image.asset('images/logo.png'),
height: 60,
),
),
SizedBox(
width: 250.0,
child: DefaultTextStyle(
style: const TextStyle(
fontSize: 39,
fontWeight: FontWeight.w900,
color: Colors.black
),
child: AnimatedTextKit(
pause: Duration(seconds: 3),
animatedTexts: [
TypewriterAnimatedText('Flash Chat', speed: Duration(milliseconds: 150)),
],
onTap: () {
print("Tap Event");
},
),
),
)
],
),
SizedBox(
height: 48.0,
),
CustomButton(text: 'Log In', color: Colors.lightBlueAccent, onPressed:(){Navigator.pushNamed(context, LoginScreen.id);} ),
CustomButton(text: 'Register', color: Colors.blue, onPressed:(){Navigator.pushNamed(context, RegistrationScreen.id);} ),
],
),
),
);
}
} | 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/presentation/chat_screen.dart | import 'package:chatapp/constants.dart';
import 'package:chatapp/widgets/chat_bubbe.dart';
import 'package:chatapp/widgets/stream_builder_chat_area.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class ChatScreen extends StatefulWidget {
static const String id = 'chat_screen';
@override
_ChatScreenState createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
//! Setup Firebase here
final _firestore = FirebaseFirestore.instance;
final _auth = FirebaseAuth.instance;
var loggedInUser;
late String message;
TextEditingController textEditingController = TextEditingController();
void messagesStream()async{
await for(var snapshot in _firestore.collection('messages').snapshots()){
for (var message in snapshot.docs){
print(message.data());
}
}
}
void getCurrentUser() async {
try {
final user = await _auth.currentUser;
if (user != null) {
loggedInUser = user;
}
} catch (e) {
print(e);
print('FEHLER');
}
}
void getMessages()async{
final fireMessage = await _firestore.collection('messages').get();
for(var message in fireMessage.docs){
print(message.data());
}
}
@override
void initState() {
// TODO: implement initState
super.initState();
getCurrentUser();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: null,
actions: <Widget>[
IconButton(
icon: Icon(Icons.close),
onPressed: () {
//Implement logout functionality
_auth.signOut();
Navigator.pop(context);
}),
],
title: Text('⚡️Chat'),
backgroundColor: Colors.lightBlueAccent,
),
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
StreamBuilderChatArea(firestore: _firestore, mail: _auth.currentUser?.email,),
Container(
decoration: kMessageContainerDecoration,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: TextField(
controller: textEditingController ,
onChanged: (value) {
message = value;
//Do something with the user input.
},
decoration: kMessageTextFieldDecoration,
),
),
FlatButton(
onPressed: () {
_firestore.collection('messages').add(
{'text': message, 'sender': loggedInUser.email, 'timestamp': FieldValue.serverTimestamp(),}
);
textEditingController.clear();
},
child: Text(
'Send',
style: kSendButtonTextStyle,
),
),
],
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/firebase-chatapp/lib | mirrored_repositories/firebase-chatapp/lib/presentation/login_screen.dart |
import 'package:chatapp/constants.dart';
import 'package:chatapp/presentation/chat_screen.dart';
import 'package:chatapp/widgets/custom_button.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
class LoginScreen extends StatefulWidget {
static const String id = 'login_screen';
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
FirebaseAuth _auth = FirebaseAuth.instance;
late String email;
late String password;
bool showSpinner = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: ModalProgressHUD(
inAsyncCall: showSpinner,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Flexible(
child: Hero(
tag: 'logo',
child: Container(
height: 200.0,
child: Image.asset('images/logo.png'),
),
),
),
SizedBox(
height: 48.0,
),
TextField(
keyboardType: TextInputType.emailAddress,
textAlign: TextAlign.center,
onChanged: (value) {
email = value;
//Do something with the user input.
},
decoration: kInputDecoration),
SizedBox(
height: 8.0,
),
TextField(
textAlign: TextAlign.center,
obscureText: true,
onChanged: (value) {
password = value;
},
decoration: kInputDecoration.copyWith(hintText: 'Enter your password'),
),
SizedBox(
height: 24.0,
),
CustomButton(text: 'Log In', color: Colors.lightBlueAccent, onPressed: ()async{
setState(() {
showSpinner = true;
});
try{
UserCredential userCredential = await _auth.signInWithEmailAndPassword(email: email, password: password);
if (userCredential != null){Navigator.pushReplacementNamed(context, ChatScreen.id);}
}
catch(e){print(e);}
}),
],
),
),
),
);
}
} | 0 |
mirrored_repositories/firebase-chatapp | mirrored_repositories/firebase-chatapp/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:chatapp/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(FlashChat());
// 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/aran_learn_flutter | mirrored_repositories/aran_learn_flutter/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Aplikasi Hello Word"),
),
body: Center(
child: Container(
color: Colors.lightBlue,
width: 150,
height: 100,
child: Text(
"Hello World satu dua tiga empat lima enam tujuh delapan sembilan sepuluh",
maxLines: 10,
overflow: TextOverflow.ellipsis,
softWrap: false,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
fontSize: 20),
)),
),
),
);
}
}
| 0 |
mirrored_repositories/aran_learn_flutter | mirrored_repositories/aran_learn_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 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:aran_learn_flutter/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/RelayApp | mirrored_repositories/RelayApp/lib/main.dart | import 'dart:ui' as Ui;
import 'package:commons/commons.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';
import 'package:i18n_extension/i18n_extension.dart';
import 'package:i18n_extension/i18n_widget.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
import 'package:relay/mixins/route_aware_analytics_mixin.dart';
import 'package:relay/services/app_reviews_service.dart';
import 'package:relay/services/purchases_service.dart';
import 'package:relay/ui/app_styles.dart';
import 'package:relay/ui/models/app_settings_model.dart';
import 'package:relay/ui/models/package_info_model.dart';
import 'package:relay/ui/screens/splash_screen.dart';
import 'package:relay/ioc/dependency_registrar.dart';
void main() {
FlutterError.onError = Crashlytics.instance.recordFlutterError;
runApp(MyApp());
DependencyRegistrar.registerDependencies();
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
if(Translations.missingKeys.isNotEmpty) {
print(Translations.missingKeys.map((t) => "\n\t\t\t\t\"${t.text}\" : \"${t.text}\",").join("\n"));
}
return OKToast(
position: ToastPosition.bottom,
textAlign: TextAlign.center,
textStyle: AppStyles.heading2Bold.copyWith(color: Colors.white),
backgroundColor: AppStyles.brightGreenBlue,
radius: 20.0,
child: MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => AppSettingsModel()),
Provider<PurchasesService>.value(value: dependencyLocator<PurchasesService>()),
ChangeNotifierProvider(create: (_) => PackageInfoModel(),),
Provider<AppReviewsService>.value(value: dependencyLocator<AppReviewsService>())
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Ui.Locale('en', "US"),
],
navigatorObservers: [routeObserver],
home: I18n(
initialLocale: Ui.Locale('en', 'US'),
child: SplashScreen()),
),
),
);
}
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/translation/eula.dart | class Eula {
static String get text => """END USER LICENSE AGREEMENT
Last updated 04/27/2020
Relay is licensed to You (End-User) by Trelly Holdings LLC d/b/a Hinterland Supply Co., located at 6169 Havelock Dr, Clarkston, Michigan 48346, United States (hereinafter: Licensor), for use only under the terms of this License Agreement.
By downloading the Application from the Apple AppStore, and any update thereto (as permitted by this License Agreement), You indicate that You agree to be bound by all of the terms and conditions of this License Agreement, and that You accept this License Agreement.
The parties of this License Agreement acknowledge that Apple is not a Party to this License Agreement and is not bound by any provisions or obligations with regard to the Application, such as warranty, liability, maintenance and support thereof. Trelly Holdings LLC d/b/a Hinterland Supply Co., not Apple, is solely responsible for the licensed Application and the content thereof.
This License Agreement may not provide for usage rules for the Application that are in conflict with the latest App Store Terms of Service. Trelly Holdings LLC d/b/a Hinterland Supply Co. acknowledges that it had the opportunity to review said terms and this License Agreement is not conflicting with them.
All rights not expressly granted to You are reserved.
1. THE APPLICATION
Relay (hereinafter: Application) is a piece of software created to Allow group texting without large reply all threads. - and customized for Apple mobile devices. It is used to send group messages..
The Application is not tailored to comply with industry-specific regulations (Health Insurance Portability and Accountability Act (HIPAA), Federal Information Security Management Act (FISMA), etc.), so if your interactions would be subjected to such laws, you may not use this Application. You may not use the Application in a way that would violate the Gramm-Leach-Bliley Act (GLBA).
2. SCOPE OF LICENSE
2.1 You are given a non-transferable, non-exclusive, non-sublicensable license to install and use the Licensed Application on any Apple-branded Products that You (End-User) own or control and as permitted by the Usage Rules set forth in this section and the App Store Terms of Service, with the exception that such licensed Application may be accessed and used by other accounts associated with You (End-User, The Purchaser) via Family Sharing or volume purchasing.
2.2 This license will also govern any updates of the Application provided by Licensor that replace, repair, and/or supplement the first Application, unless a separate license is provided for such update in which case the terms of that new license will govern.
2.3 You may not share or make the Application available to third parties (unless to the degree allowed by the Apple Terms and Conditions, and with Trelly Holdings LLC d/b/a Hinterland Supply Co.'s prior written consent), sell, rent, lend, lease or otherwise redistribute the Application.
2.4 You may not reverse engineer, translate, disassemble, integrate, decompile, integrate, remove, modify, combine, create derivative works or updates of, adapt, or attempt to derive the source code of the Application, or any part thereof (except with Trelly Holdings LLC d/b/a Hinterland Supply Co.'s prior written consent).
2.5 You may not copy (excluding when expressly authorized by this license and the Usage Rules) or alter the Application or portions thereof. You may create and store copies only on devices that You own or control for backup keeping under the terms of this license, the App Store Terms of Service, and any other terms and conditions that apply to the device or software used. You may not remove any intellectual property notices. You acknowledge that no unauthorized third parties may gain access to these copies at any time.
2.6 Violations of the obligations mentioned above, as well as the attempt of such infringement, may be subject to prosecution and damages.
2.7 Licensor reserves the right to modify the terms and conditions of licensing.
2.8 Nothing in this license should be interpreted to restrict third-party terms. When using the Application, You must ensure that You comply with applicable third-party terms and conditions.
3. TECHNICAL REQUIREMENTS
3.1 Licensor attempts to keep the Application updated so that it complies with modified/new versions of the firmware and new hardware. You are not granted rights to claim such an update.
3.2 You acknowledge that it is Your responsibility to confirm and determine that the app end-user device on which You intend to use the Application satisfies the technical specifications mentioned above.
3.3 Licensor reserves the right to modify the technical specifications as it sees appropriate at any time.
4. NO MAINTENANCE OR SUPPORT
4.1 Trelly Holdings LLC d/b/a Hinterland Supply Co. is not obligated, expressed or implied, to provide any maintenance, technical or other support for the Application.
4.2 Trelly Holdings LLC d/b/a Hinterland Supply Co. and the End-User acknowledge that Apple has no obligation whatsoever to furnish any maintenance and support services with respect to the licensed Application.
5. USE OF DATA
You acknowledge that Licensor will be able to access and adjust Your downloaded licensed Application content and Your personal information, and that Licensor's use of such material and information is subject to Your legal agreements with Licensor and Licensor's privacy policy: https://meandhim-s3.s3.amazonaws.com/Images/hsco-privacy.pdf.
6. LIABILITY
6.1 Licensor takes no accountability or responsibility for any damages caused due to a breach of duties according to Section 2 of this Agreement. To avoid data loss, You are required to make use of backup functions of the Application to the extent allowed by applicable third-party terms and conditions of use. You are aware that in case of alterations or manipulations of the Application, You will not have access to licensed Application.
7. WARRANTY
7.1 Licensor warrants that the Application is free of spyware, trojan horses, viruses, or any other malware at the time of Your download. Licensor warrants that the Application works as described in the user documentation.
7.2 No warranty is provided for the Application that is not executable on the device, that has been unauthorizedly modified, handled inappropriately or culpably, combined or installed with inappropriate hardware or software, used with inappropriate accessories, regardless if by Yourself or by third parties, or if there are any other reasons outside of Trelly Holdings LLC d/b/a Hinterland Supply Co.'s sphere of influence that affect the executability of the Application.
7.3 You are required to inspect the Application immediately after installing it and notify Trelly Holdings LLC d/b/a Hinterland Supply Co. about issues discovered without delay by e-mail provided in Product Claims. The defect report will be taken into consideration and further investigated if it has been mailed within a period of nine thousand (9000) days after discovery.
7.4 If we confirm that the Application is defective, Trelly Holdings LLC d/b/a Hinterland Supply Co. reserves a choice to remedy the situation either by means of solving the defect or substitute delivery.
7.5 In the event of any failure of the Application to conform to any applicable warranty, You may notify the App-Store-Operator, and Your Application purchase price will be refunded to You. To the maximum extent permitted by applicable law, the App-Store-Operator will have no other warranty obligation whatsoever with respect to the App, and any other losses, claims, damages, liabilities, expenses and costs attributable to any negligence to adhere to any warranty.
7.6 If the user is an entrepreneur, any claim based on faults expires after a statutory period of limitation amounting to twelve (12) months after the Application was made available to the user. The statutory periods of limitation given by law apply for users who are consumers.
8. PRODUCT CLAIMS
Trelly Holdings LLC d/b/a Hinterland Supply Co. and the End-User acknowledge that Trelly Holdings LLC d/b/a Hinterland Supply Co., and not Apple, is responsible for addressing any claims of the End-User or any third party relating to the licensed Application or the End-User’s possession and/or use of that licensed Application, including, but not limited to:
(i) product liability claims;
(ii) any claim that the licensed Application fails to conform to any applicable legal or regulatory requirement; and
(iii) claims arising under consumer protection, privacy, or similar legislation, including in connection with Your Licensed Application’s use of the HealthKit and HomeKit.
9. LEGAL COMPLIANCE
You represent and warrant that You are not located in a country that is subject to a U.S. Government embargo, or that has been designated by the U.S. Government as a "terrorist supporting" country; and that You are not listed on any U.S. Government list of prohibited or restricted parties.
10. CONTACT INFORMATION
For general inquiries, complaints, questions or claims concerning the licensed Application, please contact:
Support Team
6169 Havelock Dr
Clarkston, MI 48346
United States
[email protected]
11. TERMINATION
The license is valid until terminated by Trelly Holdings LLC d/b/a Hinterland Supply Co. or by You. Your rights under this license will terminate automatically and without notice from Trelly Holdings LLC d/b/a Hinterland Supply Co. if You fail to adhere to any term(s) of this license. Upon License termination, You shall stop all use of the Application, and destroy all copies, full or partial, of the Application.
12. THIRD-PARTY TERMS OF AGREEMENTS AND BENEFICIARY
Trelly Holdings LLC d/b/a Hinterland Supply Co. represents and warrants that Trelly Holdings LLC d/b/a Hinterland Supply Co. will comply with applicable third-party terms of agreement when using licensed Application.
In Accordance with Section 9 of the "Instructions for Minimum Terms of Developer's End-User License Agreement," Apple and Apple's subsidiaries shall be third-party beneficiaries of this End User License Agreement and - upon Your acceptance of the terms and conditions of this license agreement, Apple will have the right (and will be deemed to have accepted the right) to enforce this End User License Agreement against You as a third-party beneficiary thereof.
13. INTELLECTUAL PROPERTY RIGHTS
Trelly Holdings LLC d/b/a Hinterland Supply Co. and the End-User acknowledge that, in the event of any third-party claim that the licensed Application or the End-User's possession and use of that licensed Application infringes on the third party's intellectual property rights, Trelly Holdings LLC d/b/a Hinterland Supply Co., and not Apple, will be solely responsible for the investigation, defense, settlement and discharge or any such intellectual property infringement claims.
14. APPLICABLE LAW
This license agreement is governed by the laws of the State of Michigan excluding its conflicts of law rules.
15. MISCELLANEOUS
15.1 If any of the terms of this agreement should be or become invalid, the validity of the remaining provisions shall not be affected. Invalid terms will be replaced by valid ones formulated in a way that will achieve the primary purpose.
15.2 Collateral agreements, changes and amendments are only valid if laid down in writing. The preceding clause can only be waived in writing.""";
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/translation/translations.dart | import 'package:i18n_extension/i18n_extension.dart';
extension Localization on String {
static TranslationsByLocale _t = Translations.byLocale("en_us") +
{
"en_us": {
"No" : "No",
"Yes" : "Yes",
"Confirm delete?" : "Confirm delete?",
"Search..." : "Search...",
"Groups" : "Groups",
"%d Contacts" : "%d Contacts",
"Contacts" : "Contacts",
"Add Contact" : "Add Contact",
"Open Settings" : "Open Settings",
"Exit" : "Exit",
"Compose" : "Compose",
"compose" : "compose",
"Please enter a message first." : "Please enter a message first.",
"send" : "send",
"skip" : "skip",
"Skip" : "Skip",
"Next" : "Next",
"Get started" : "Get started",
"New Group" : "New Group",
"save" : "save",
"Save" : "Save",
"%s (copy)" : "%s (copy)",
"delete" : "delete",
"Duplicate" : "Duplicate",
"Delete" : "Delete",
"Cancel" : "Cancel",
"No results." : "No results.",
"Let's add your first group." : "Let's add your first group.",
"loading your contacts. " : "loading your contacts. ",
"loading your contacts.. " : "loading your contacts.. ",
"loading your contacts..." : "loading your contacts...",
" and %d more" : " and %d more",
"Mobile #" : "Mobile #",
"Sent on %s" : "Sent on %s",
"Please select some contacts." : "Please select some contacts.",
"Choose Number" : "Choose Number",
"Please give your group a name." : "Please give your group a name.",
"Okay" : "Okay",
"Let's add your first group." : "Let's add your first group.",
"Are you sure you want to delete the group '%s'?" : "Are you sure you want to delete the group '%s'?",
"Check this box to confirm delete!" : "Check this box to confirm delete!",
"Group Name" : "Group Name",
"Your Profile" : "Your Profile",
"Enter Name" : "Enter Name",
"change" : "change",
"Group Sorting" : "Group Sorting",
"Last Sent First" : "Last Sent First",
"Alphabetical" : "Alphabetical",
"Signature" : "Signature",
"Include signature on every message." : "Include signature on every message.",
"Settings" : "Settings",
"Unlimited Groups" : "Unlimited Groups",
"year*" : "year*",
"six months*" : "six months*",
"three months*" : "three months*",
"two monnths*" : "two months*",
"monthly*" : "monthly*",
"weekly*" : "weekly*",
"product_pricing: %s / %s" : "%s / %s",
"lifetime" : "lifetime",
"Restore Purchases" : "Restore Purchases",
"subscription_tos" : "* Subscriptions will automatically renew and your purchase method will be charged at the end of each period, unless you unsubscribe at least 24 hours before.",
"Purchase failed." : "Purchase failed.",
"Terms of Use" : "Terms of Use",
"Privacy Policy" : "Privacy Policy",
"I Agree" : "I Agree",
"Version: %s" : "Version: %s",
"Review Relay" : "Review Relay",
"Do you want to rate or review Relay on the app store?" : "Do you want to rate or review Relay on the app store?",
"Enjoying Relay?" : "Enjoying Relay?",
"Not Right Now" : "Not Right Now",
"no-contacts-permission-text" : "Relay cannot function without access to your contacts.\n\nPlease reinstall the app and allow access or open settings to allow Relay access to contacts.",
"Unlimited groups have not been purchased using this account." : "Unlimited groups have not been purchased using this account.",
"product_description" : "Unlock unlimited mass texting groups. Create as many new groups as you need and send unlimited messages.\n\nGet access to new pro features like scheduled messages, templates and more.",
" (%d people selected)" : ""
.zero(" (No people selected)")
.one(" (1 person selected)")
.many(" (%d people selected)"),
"%d People" : ""
.zero("Empty")
.one("1 Person")
.many("%d People"),
"Sent to %d people | " : ""
.one("Sent to 1 person | ")
.many("Sent to %d people | "),
"%d Recipients" : ""
.one("1 Recipient")
.many("%d Recipients"),
}
};
String get i18n => localize(this, _t);
String plural(int number) => localizePlural(number, this, _t);
String fill(List<Object> params) => localizeFill(this.i18n, params);
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/translation/privacy_policy.dart | class PrivacyPolicy {
static String get text => """Privacy Policy
Protecting your private information is our priority. This Statement of Privacy applies to
https://www.hinterlandsupply.co and Trelly Holdings LLC d/b/a Hinterland Supply Co. and
governs data collection and usage. For the purposes of this Privacy Policy, unless otherwise noted,
all references to Trelly Holdings LLC d/b/a Hinterland Supply Co. include
https://www.hinterlandsupply.co, mobile apps or and all mobile applications it has developed.. By
using the mobile apps or website, you consent to the data practices described in this statement.
Collection of your Personal Information
We do not collect any personal information about you unless you voluntarily provide it to us.
However, you may be required to provide certain personal information to us when you elect to use
certain products or services available on the Site. These may include: (a) registering for an account
on our Site; (b) entering a sweepstakes or contest sponsored by us or one of our partners; (c)
signing up for special offers from selected third parties; (d) sending us an email message; (e)
submitting your credit card or other payment information when ordering and purchasing products
and services on our Site. To wit, we will use your information for, but not limited to,
communicating with you in relation to services and/or products you have requested from us. We
also may gather additional personal or non-personal information in the future.
Sharing Information with Third Parties
mobile apps or does not sell, rent or lease its customer lists to third parties.
mobile apps or may share data with trusted partners to help perform statistical analysis, send you
email or postal mail, provide customer support, or arrange for deliveries. All such third parties are
prohibited from using your personal information except to provide these services to mobile apps
or, and they are required to maintain the confidentiality of your information.
mobile apps or may disclose your personal information, without notice, if required to do so by law
or in the good faith belief that such action is necessary to: (a) conform to the edicts of the law or
comply with legal process served on mobile apps or or the site; (b) protect and defend the rights
or property of mobile apps or; and/or (c) act under exigent circumstances to protect the personal
safety of users of mobile apps or, or the public.
Tracking User Behavior
mobile apps or may keep track of the websites and pages our users visit within mobile apps or, in
order to determine what mobile apps or services are the most popular. This data is used to deliver
customized content and advertising within mobile apps or to customers whose behavior indicates
that they are interested in a particular subject area.
Automatically Collected Information
Information about your computer hardware and software may be automatically collected by
mobile apps or. This information can include: your IP address, browser type, domain names,
access times and referring website addresses. This information is used for the operation of the
This is a RocketLawyer.com document. Page 1 of 3
service, to maintain quality of the service, and to provide general statistics regarding use of the
mobile apps or website.
Use of Cookies
The mobile apps or website may use "cookies" to help you personalize your online experience. A
cookie is a text file that is placed on your hard disk by a web page server. Cookies cannot be
used to run programs or deliver viruses to your computer. Cookies are uniquely assigned to you,
and can only be read by a web server in the domain that issued the cookie to you.
One of the primary purposes of cookies is to provide a convenience feature to save you time. The
purpose of a cookie is to tell the Web server that you have returned to a specific page. For
example, if you personalize mobile apps or pages, or register with mobile apps or site or services,
a cookie helps mobile apps or to recall your specific information on subsequent visits. This
simplifies the process of recording your personal information, such as billing addresses, shipping
addresses, and so on. When you return to the same mobile apps or website, the information you
previously provided can be retrieved, so you can easily use the mobile apps or features that you
customized.
You have the ability to accept or decline cookies. Most Web browsers automatically accept
cookies, but you can usually modify your browser setting to decline cookies if you prefer. If you
choose to decline cookies, you may not be able to fully experience the interactive features of the
mobile apps or services or websites you visit.
Links
This website contains links to other sites. Please be aware that we are not responsible for the
content or privacy practices of such other sites. We encourage our users to be aware when they
leave our site and to read the privacy statements of any other site that collects personally
identifiable information.
Security of your Personal Information
mobile apps or secures your personal information from unauthorized access, use, or disclosure.
mobile apps or uses the following methods for this purpose:
When personal information (such as a credit card number) is transmitted to other websites, it is
protected through the use of encryption, such as the Secure Sockets Layer (SSL) protocol.
We strive to take appropriate security measures to protect against unauthorized access to or
alteration of your personal information. Unfortunately, no data transmission over the Internet or any
wireless network can be guaranteed to be 100% secure. As a result, while we strive to protect
your personal information, you acknowledge that: (a) there are security and privacy limitations
inherent to the Internet which are beyond our control; and (b) security, integrity, and privacy of any
and all information and data exchanged between you and us through this Site cannot be
guaranteed.
- SSL Protocol
This is a RocketLawyer.com document. Page 2 of 3
Children Under Thirteen
mobile apps or does not knowingly collect personally identifiable information from children under
the age of thirteen. If you are under the age of thirteen, you must ask your parent or guardian for
permission to use this website.
E-mail Communications
From time to time, mobile apps or may contact you via email for the purpose of providing
announcements, promotional offers, alerts, confirmations, surveys, and/or other general
communication. In order to improve our Services, we may receive a notification when you open an
email from mobile apps or or click on a link therein.
If you would like to stop receiving marketing or promotional communications via email from mobile
apps or, you may opt out of such communications by clicking on the UNSUBSCRIBE button.
External Data Storage Sites
We may store your data on servers provided by third party hosting vendors with whom we have
contracted.
Changes to this Statement
mobile apps or reserves the right to change this Privacy Policy from time to time. We will notify
you about significant changes in the way we treat personal information by sending a notice to the
primary email address specified in your account, by placing a prominent notice on our site, and/or
by updating any privacy information on this page. Your continued use of the Site and/or Services
available through this Site after such modifications will constitute your: (a) acknowledgment of the
modified Privacy Policy; and (b) agreement to abide and be bound by that Policy.
Contact Information
mobile apps or welcomes your questions or comments regarding this Statement of Privacy. If you
believe that mobile apps or has not adhered to this Statement, please contact mobile apps or at:
Trelly Holdings LLC d/b/a Hinterland Supply Co.
6169 Havelock Dr.
Clarkston, Michigan 48346 """;
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/ioc/dependency_registrar.dart | import 'package:get_it/get_it.dart';
import 'package:relay/services/app_reviews_service.dart';
import 'package:relay/services/contacts_service.dart';
import 'package:relay/services/purchases_service.dart';
import 'package:relay/services/analytics_service.dart';
import 'package:relay/services/app_settings_service.dart';
import 'package:relay/services/message_service.dart';
import 'package:relay/services/image_service.dart';
import 'package:relay/services/group_service.dart';
import 'package:relay/services/database_service.dart';
import 'package:relay/data/db/database_factory.dart';
import 'package:relay/data/db/database_provider.dart';
import 'package:relay/data/db/local_database_factory.dart';
import 'package:relay/data/db/remote_database_factory.dart';
final dependencyLocator = GetIt.instance;
class DependencyRegistrar {
/// Register app dependencies.
static void registerDependencies() {
dependencyLocator.registerSingleton(AnalyticsService());
dependencyLocator.registerSingleton(AppSettingsService());
dependencyLocator.registerSingleton<LocalDatabaseFactory>(SembastDatabaseFactory());
dependencyLocator.registerSingleton<RemoteDatabaseFactory>(FirebaseDatabaseFactory());
dependencyLocator.registerSingleton(DatabaseProvider());
dependencyLocator.registerSingleton(DatabaseService());
dependencyLocator.registerSingleton(ContactsService());
dependencyLocator.registerSingleton(ImageService());
dependencyLocator.registerSingleton(GroupService());
dependencyLocator.registerSingleton(MessageService());
dependencyLocator.registerSingleton(PurchasesService());
dependencyLocator.registerSingleton(AppReviewsService());
}
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/group_sort.dart | import 'package:relay/translation/translations.dart';
abstract class GroupSort {
final int _value;
static const GroupSort lastSentFirst = _LastSentFirst(1);
static const GroupSort alphabetical = _Alphabetical(2);
const GroupSort._(this._value);
static List<String> get valueStrings => [
lastSentFirst.toString(),
alphabetical.toString()
];
static List<GroupSort> get values => [
lastSentFirst,
alphabetical
];
static GroupSort parseInt(int value) {
return values.firstWhere((v) => v._value == value, orElse: () => null);
}
int toInt();
}
class _LastSentFirst extends GroupSort {
const _LastSentFirst(int value) : super._(value);
@override
String toString() {
return "Last Sent First".i18n;
}
@override
bool operator ==(Object other) {
if((other is GroupSort) == false) return false;
if(other is _LastSentFirst) return true;
return false;
}
@override
int get hashCode => toString().hashCode;
@override
int toInt() => _value;
}
class _Alphabetical extends GroupSort {
const _Alphabetical(int value) : super._(value);
@override
String toString() {
return "Alphabetical".i18n;
}
@override
int get hashCode => toString().hashCode;
@override
bool operator ==(Object other) {
if((other is GroupSort) == false) return false;
if(other is _Alphabetical) return true;
return false;
}
@override
int toInt() => _value;
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/message_item.dart | import 'dart:collection';
import 'package:relay/models/message_recipient.dart';
import 'package:relay/data/db/dto/message_dto.dart';
import 'package:relay/models/group_item.dart';
class MessageItemModel {
final String message;
final UnmodifiableListView<MessageRecipient> recipients;
final DateTime sendDateTime;
final GroupItemModel group;
final int id;
MessageItemModel({this.message, this.recipients, this.sendDateTime, this.group, this.id});
MessageItemModel.fromDto(MessageDto dto, GroupItemModel group) : this(
id: dto.id,
message: dto.message,
sendDateTime: dto.sendDateTime,
group: group,
recipients: UnmodifiableListView(
dto
.recipients
.entries
.map((contact)
=> MessageRecipient(
contact.key,
contact.value)))
);
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/toggleable_contact_model.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:relay/models/toggleable.dart';
import 'package:relay/models/contact_item.dart';
class ToggleableContactItemModel extends Toggleable<ContactItemModel> implements ChangeNotifier, ContactItemModel {
final ContactItemModel _baseModel;
ToggleableContactItemModel(this._baseModel) : super(_baseModel);
String get fullName => _baseModel.fullName;
@override
void addListener(listener) => _baseModel.addListener(listener);
@override
void dispose() => _baseModel.dispose();
@override
bool get hasListeners => _baseModel.hasListeners;
@override
void notifyListeners() => _baseModel.notifyListeners();
@override
void removeListener(listener) => _baseModel.removeListener(listener);
@override
DateTime get birthday => _baseModel.birthday;
@override
set birthday(DateTime value) => _baseModel.birthday = value;
@override
String get company => _baseModel.company;
@override
set company(String value) => _baseModel.company = value;
@override
String get firstName => _baseModel.firstName;
@override
set firstName(String value) => _baseModel.firstName = value;
@override
File get imageFile => _baseModel.imageFile;
@override
set imageFile(File value) => _baseModel.imageFile = value;
@override
String get imagePath => _baseModel.imagePath;
@override
set imagePath(String value) => _baseModel.imagePath = value;
@override
String get lastName => _baseModel.lastName;
@override
set lastName(String value) => _baseModel.lastName = value;
@override
String get phone => _baseModel.phone;
@override
set phone(String value) => _baseModel.phone = value;
@override
int get id => _baseModel.id;
@override
String get initials => _baseModel.initials;
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/contact_item.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:relay/data/db/dto/contact_dto.dart';
class ContactItemModel extends ChangeNotifier {
int _id;
String _firstName;
String _lastName;
String _phone;
String _imagePath;
String _company;
DateTime _birthday;
File _imageFile;
ContactItemModel._(this._id, this._firstName, this._lastName, this._phone, this._company, this._birthday, this._imagePath);
factory ContactItemModel({int id, String firstName, String lastName, String phone, String company, DateTime birthday, String imagePath}) {
assert(id != null);
assert(id >= 0);
assert(firstName.isNotEmpty);
assert(phone.isNotEmpty);
return ContactItemModel._(id, firstName, lastName, phone, company, birthday, imagePath);
}
factory ContactItemModel.fromDto(ContactDto dto) {
return ContactItemModel._(dto.id, dto.firstName, dto.lastName, dto.phone, dto.company, dto.birthday, dto.imagePath);
}
/// [id] of the group.
int get id => _id;
/// The [firstName] of the contact.
String get firstName => _firstName ?? "";
String get fullName => (firstName ?? "") + (lastName.isNotEmpty ? " $lastName" : "");
/// The `File` containing the image referenced at [imagePath].
set imageFile(File value) {
if(_imageFile != value) {
_imageFile = value;
notifyListeners();
}
}
/// The `File` containing the image referenced at [imagePath].
File get imageFile => _imageFile;
/// The [firstName] of the contact.
set firstName(String value) {
if(_firstName != value) {
_firstName = value;
notifyListeners();
}
}
/// The [lastName] of the contact.
String get lastName => _lastName ?? "";
/// The [lastName] of the contact.
set lastName(String value) {
if(_lastName != value) {
_lastName = value;
notifyListeners();
}
}
String get initials => fullName?.isEmpty == true
? company?.isNotEmpty == true ? company.substring(0,1) : ""
: "${firstName?.isNotEmpty == true ? firstName.substring(0,1) : ""}" +
"${lastName?.isNotEmpty == true ? lastName.substring(0,1) : ""}";
/// The [phone] of the contact.
String get phone => _phone;
/// The [phone] of the contact.
set phone(String value) {
if(_phone != value) {
_phone = value;
notifyListeners();
}
}
/// The [company] of the contact.
String get company => _company;
/// The [company] of the contact.
set company(String value) {
if(_company != value) {
_company = value;
notifyListeners();
}
}
/// The [imagePath] of the contact's avatar.
String get imagePath => _imagePath;
/// The [imagePath] of the contact's avatar.
set imagePath(String value) {
if(_imagePath != value) {
_imagePath = value;
notifyListeners();
}
}
/// The [birthday] of the contact.
DateTime get birthday => _birthday;
/// The [birthday] of the contact.
set birthday(DateTime value) {
if(_birthday != value) {
_birthday = value;
notifyListeners();
}
}
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/message_recipient.dart | import 'package:relay/models/contact_item.dart';
class MessageRecipient {
final String name;
final String number;
const MessageRecipient(this.name, this.number);
MessageRecipient.fromContact(ContactItemModel contact) : this(contact.fullName, contact.phone);
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/toggleable_group_item.dart |
import 'package:flutter/foundation.dart';
import 'package:relay/data/db/dto/preferred_send_type.dart';
import 'package:relay/models/toggleable.dart';
import 'package:relay/models/contact_item.dart';
import 'package:relay/models/group_item.dart';
class ToggleableGroupItemModel extends Toggleable<GroupItemModel> implements ChangeNotifier, GroupItemModel {
final GroupItemModel _baseModel;
ToggleableGroupItemModel(this._baseModel) : super(_baseModel);
/// [id] of the group.
@override
int get id => _baseModel.id;
/// The [preferredSendType] is a default way to communicate with this group.
@override
PreferredSendType get preferredSendType => _baseModel.preferredSendType;
/// The [preferredSendType] is a default way to communicate with this group.
@override
set preferredSendType(PreferredSendType value) {
_baseModel.preferredSendType = value;
}
/// [name] of the group.
@override
String get name => _baseModel.name;
/// [name] of the group.
@override
set name(String value) {
_baseModel.name = value;
}
/// The [contacts] list for the group.
@override
List<ContactItemModel> get contacts => _baseModel.contacts;
/// the last `DateTime` that a message was sent to this group.
@override
DateTime get lastMessageSentDate => _baseModel.lastMessageSentDate;
/// the last `DateTime` that a message was sent to this group.
@override
set lastMessageSentDate(DateTime value) => _baseModel.lastMessageSentDate = value;
/// The `DateTime` of the groups creation.
@override
DateTime get creationDate => _baseModel.creationDate;
/// Add a new [contact] to the [contacts] list.
@override
void addContact(ContactItemModel contact) => _baseModel.addContact(contact);
/// Remove a [contact] from the [contacts] list.
@override
void removeContact(ContactItemModel contact) => _baseModel.removeContact(contact);
@override
void addListener(listener) => _baseModel.addListener(listener);
@override
void dispose() => _baseModel.dispose();
@override
bool get hasListeners => _baseModel.hasListeners;
@override
void notifyListeners() => _baseModel.notifyListeners();
@override
void removeListener(listener) => _baseModel.removeListener(listener);
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/toggleable.dart | import 'package:flutter/foundation.dart';
abstract class Toggleable<T extends ChangeNotifier> implements ChangeNotifier {
final T _baseModel;
bool _selected = false;
bool get selected => _selected;
set selected(bool value) {
if(_selected != value) {
_selected = value;
_baseModel.notifyListeners();
}
}
Toggleable(this._baseModel);
void toggle() {
_selected = !_selected;
_baseModel.notifyListeners();
}
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/models/group_item.dart | import 'dart:core';
import 'package:flutter/foundation.dart';
import 'package:relay/data/db/dto/contact_dto.dart';
import 'package:relay/data/db/dto/group_dto.dart';
import 'package:relay/data/db/dto/preferred_send_type.dart';
import 'package:relay/models/contact_item.dart';
class GroupItemModel extends ChangeNotifier {
int _id;
String _name;
PreferredSendType _preferredSendType;
List<ContactItemModel> _contacts;
DateTime _lastMessageSentDate;
DateTime _creationDate;
GroupItemModel._(this._id, this._name, this._contacts, this._preferredSendType, this._lastMessageSentDate, this._creationDate);
factory GroupItemModel({
int id,
String name = "",
List<ContactItemModel> contacts,
PreferredSendType preferredSendType = PreferredSendType.Unset,
DateTime lastMessageSent,
DateTime creationDate}) {
assert(id != null);
assert(id >= 0);
assert(name != null);
assert(name.isNotEmpty);
assert(creationDate != null);
assert(creationDate.isBefore(DateTime.now()));
return GroupItemModel._(id, name, contacts ?? [], preferredSendType, lastMessageSent, creationDate);
}
factory GroupItemModel.fromDTO(GroupDto g, List<ContactDto> contacts) {
return GroupItemModel(
id: g.id,
name: g.name,
preferredSendType: g.preferredSendType,
contacts: contacts.map((c) => ContactItemModel.fromDto(c)).toList(),
lastMessageSent: g.lastMessageSentDate,
creationDate: g.creationDate);
}
/// [id] of the group.
int get id => _id;
/// The [preferredSendType] is a default way to communicate with this group.
PreferredSendType get preferredSendType => _preferredSendType;
/// The [preferredSendType] is a default way to communicate with this group.
set preferredSendType(PreferredSendType value) {
if(_preferredSendType != value) {
_preferredSendType = value;
}
notifyListeners();
}
/// [name] of the group.
String get name => _name;
/// [name] of the group.
set name(String value) {
if(_name != value) {
_name = value;
}
notifyListeners();
}
/// The [contacts] list for the group.
List<ContactItemModel> get contacts => _contacts;
/// the last `DateTime` that a message was sent to this group.
DateTime get lastMessageSentDate => _lastMessageSentDate;
/// the last `DateTime` that a message was sent to this group.
set lastMessageSentDate(DateTime value) {
_lastMessageSentDate = value;
notifyListeners();
}
/// The `DateTime` of the groups creation.
DateTime get creationDate => _creationDate;
/// Add a new [contact] to the [contacts] list.
void addContact(ContactItemModel contact) {
_contacts.add(contact);
notifyListeners();
}
/// Remove a [contact] from the [contacts] list.
void removeContact(ContactItemModel contact) {
_contacts.removeWhere((c) => c.id == contact.id);
notifyListeners();
}
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/app_database.dart | import 'package:relay/data/db/db_collection.dart';
abstract class AppDatabase {
int get version => null;
Future updateVersion(int version);
DbCollection collections(String collectionName);
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/database_factory.dart | import 'package:relay/data/db/app_database.dart';
abstract class DatabaseFactory {
Future<AppDatabase> create(String dbName);
}
abstract class LocalDatabaseFactory extends DatabaseFactory {}
abstract class RemoteDatabaseFactory extends DatabaseFactory {} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/query_package.dart | import 'package:relay/data/db/db_collection.dart';
class QueryPackage {
String key;
dynamic value;
FilterType filter;
QueryPackage({this.key, this.value, this.filter});
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/remote_database_factory.dart | import 'package:relay/data/db/app_database.dart';
import 'package:relay/data/db/database_factory.dart';
class FirebaseDatabaseFactory extends RemoteDatabaseFactory {
@override
Future<AppDatabase> create(String dbName) {
return null;
}
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/db_collection.dart | import 'package:flutter/foundation.dart';
import 'package:relay/data/db/dto/dto.dart';
import 'package:relay/data/db/query_package.dart';
abstract class DbCollection {
/// delete the item by id.
Future deleteFromId(int id);
/// delete the supplied item.
Future deleteFromDto(DTO dto);
/// add a new item. If the item already exists, update it.
Future<int> add(DTO dto);
/// update an existing item. If the item doesn't exist, add it.
Future update(DTO dto);
/// Query the collection based on the provided [query]. If multiple queries are provided they are combined into an 'and' filter.
/// Optionally sorts the results based on [sortKey] of a specific field by the supplied [sort] order.
Future<List<T>> query<T extends DTO>(List<QueryPackage> query, T Function(Map<String, dynamic>) itemCreator, {SortOrderType sort, String sortKey, bool findFirst = false});
/// get all the items in this collection.
Future<List<T>> getAll<T extends DTO>(T Function(Map<String, dynamic>) itemCreator);
/// Get one record with the given [id] and create items with the supplied [itemCreator].
Future<T> getOne<T extends DTO>(int id, {@required T Function(Map<String, dynamic>) itemCreator});
/// Get many records from the given list of id's in [idList] and create items with the supplied [itemCreator].
Future<List<T>> getMany<T extends DTO>(List<int> idList, {@required T Function(Map<String, dynamic>) itemCreator});
/// Search all records for a specified [query] string
Future<List<T>> search<T extends DTO>(String query, T Function(Map<String, dynamic>) itemCreator);
}
enum FilterType {
EqualTo,
GreaterThan,
LessThan,
NotEqualTo,
GreaterThanOrEqualTo,
LessThanOrEqualTo,
Contains
}
enum SortOrderType {
Ascending,
Decending
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/sembast_database.dart | import 'package:flutter/foundation.dart';
import 'package:sembast/sembast_io.dart';
import 'package:sembast/utils/sembast_import_export.dart';
import 'dto/dto.dart';
import 'package:sembast/sembast.dart';
import 'app_database.dart';
import 'db_collection.dart';
import 'query_package.dart';
class SembastDatabase implements AppDatabase {
Database _db;
SembastDatabase(Database db) {
_db = db;
}
@override
int get version => _db.version;
@override
DbCollection collections(String collectionName) {
return SembastStore(_db, collectionName);
}
@override
Future updateVersion(int version) async {
assert(_db.version < version);
var path = _db.path;
var exported = await exportDatabase(_db);
exported["version"] = version;
_db.close();
var db = await importDatabase(exported, databaseFactoryIo, path);
_db = db;
}
}
class SembastStore implements DbCollection {
Database _db;
String _storeName;
SembastStore(Database db, String storeName) {
_db = db;
_storeName = storeName;
}
@override
Future<int> add(DTO dto) async {
if(dto.id != -1) {
await update(dto);
return dto.id;
}
var store = intMapStoreFactory.store(_storeName);
int newId;
var map = dto.toMap();
await _db.transaction((txn) async {
newId = await store.add((txn), map);
});
return newId;
}
@override
Future deleteFromDto(DTO dto) async {
if(dto.id == -1) {
return;
}
await deleteFromId(dto.id);
}
@override
Future deleteFromId(int id) async {
if(id == -1) {
return;
}
var store = intMapStoreFactory.store(_storeName);
await _db.transaction((txn) async {
await store.record(id).delete(txn);
});
}
@override
Future<List<T>> query<T extends DTO>(List<QueryPackage> query, T Function(Map<String, dynamic>) itemCreator, {SortOrderType sort, String sortKey, bool findFirst = false}) async {
Finder finder;
if(query.length == 1) {
finder = Finder(
filter: _getFilter(query.first),
);
} else {
finder = Finder(
filter: Filter.and(
query
.map((q) => _getFilter(q))
.toList()
)
);
}
if(sort != null && sortKey.isNotEmpty) {
finder.sortOrder = SortOrder(sortKey, sort == SortOrderType.Ascending);
}
final store = intMapStoreFactory.store(_storeName);
List<RecordSnapshot<int, Map<String, dynamic>>> records;
await _db.transaction((txn) async {
if(findFirst) {
records = [ await store.findFirst(txn, finder: finder) ];
} else {
records = await store.find(txn, finder: finder);
}
});
return records
.map((r) {
var map = Map<String,dynamic>.from(r.value);
map["id"] = r.key;
return itemCreator(map);
})
.toList();
}
@override
Future update(DTO dto) async {
if(dto.id == -1) {
await add(dto);
return;
}
var store = intMapStoreFactory.store(_storeName);
await _db.transaction((txn) async {
await store.record(dto.id).put(txn, dto.toMap());
});
}
@override
Future<List<T>> getAll<T extends DTO>(T Function(Map<String, dynamic>) itemCreator) async {
var store = intMapStoreFactory.store(_storeName);
List<RecordSnapshot<int, Map<String, dynamic>>> records;
await _db.transaction((txn) async {
records = await store.find(txn);
});
return records
.map((r) {
var map = Map<String,dynamic>.from(r.value);
map["id"] = r.key;
return itemCreator(map);
})
.toList();
}
@override
Future<T> getOne<T extends DTO>(int id, {@required T Function(Map<String, dynamic>) itemCreator}) async {
assert(id >= 0);
assert(itemCreator != null);
var store = intMapStoreFactory.store(_storeName);
Map<String, dynamic> record;
await _db.transaction((txn) async {
if(await store.record(id).exists(txn)) {
record = await store.record(id).get(txn);
}
});
if(record != null) {
return itemCreator(record);
}
return null;
}
@override
Future<List<T>> getMany<T extends DTO>(List<int> idList, {@required T Function(Map<String, dynamic>) itemCreator}) async {
List<T> items = [];
for(var id in idList.where((i) => i != null && i >= 0)) {
items.add(await getOne(id, itemCreator: itemCreator));
}
return items.where((item) => item != null).toList();
}
@override
Future<List<T>> search<T extends DTO>(String query, T Function(Map<String, dynamic>) itemCreator) async {
var finder = Finder(filter: Filter.matches("searchString", ".*$query.*"));
var store = intMapStoreFactory.store(_storeName);
List<RecordSnapshot<int, Map<String, dynamic>>> records;
await _db.transaction((txn) async {
records = await store.find(txn, finder: finder);
});
return records
.map((r) {
r.value["id"] = r.key;
return itemCreator(r.value);
})
.toList();
}
Filter _getFilter(QueryPackage query) {
final field = query.key;
final value = query.value;
switch(query.filter) {
case FilterType.GreaterThan:
return Filter.greaterThan(field, value);
break;
case FilterType.LessThan:
return Filter.lessThan(field, value);
break;
case FilterType.NotEqualTo:
return Filter.notEquals(field, value);
break;
case FilterType.GreaterThanOrEqualTo:
return Filter.greaterThanOrEquals(field, value);
break;
case FilterType.LessThanOrEqualTo:
return Filter.lessThanOrEquals(field, value);
break;
case FilterType.Contains:
if(value is int) {
return Filter.custom((RecordSnapshot<dynamic, dynamic> record) {
var valueRec = record.value[field];
if(valueRec is int) {
return valueRec == value;
} else if(valueRec is List) {
return valueRec.contains(value);
} else {
return false;
}
});
} else {
return Filter.matches(field, value, anyInList: true);
}
break;
default:
// default case is equals.
return Filter.equals(field, value);
break;
}
}
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/local_database_factory.dart | import 'package:path_provider/path_provider.dart';
import 'package:sembast/sembast_io.dart';
import 'package:path/path.dart';
import 'package:relay/data/db/app_database.dart';
import 'package:relay/data/db/database_factory.dart';
import 'package:relay/data/db/sembast_database.dart';
class SembastDatabaseFactory extends LocalDatabaseFactory {
@override
Future<AppDatabase> create(String dbName) async {
final directory = await getApplicationDocumentsDirectory();
final dbPath = join(directory.path, dbName);
final db = await databaseFactoryIo.openDatabase(dbPath);
return SembastDatabase(db);
}
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/database_upgrader.dart | import 'package:relay/data/db/app_database.dart';
class DatabaseUpgrader {
DatabaseUpgrader._();
static Future upgradeDatabase(AppDatabase db) async {
// Nothing to do yet.
}
} | 0 |
mirrored_repositories/RelayApp/lib/data | mirrored_repositories/RelayApp/lib/data/db/database_provider.dart | import 'package:path/path.dart';
import 'package:relay/ioc/dependency_registrar.dart';
import 'package:relay/data/db/app_database.dart';
import 'package:relay/data/db/database_factory.dart';
class DatabaseProvider {
LocalDatabaseFactory _localDbFactory;
RemoteDatabaseFactory _remoteDbFactory;
Map<String, AppDatabase> _localDatabases = Map<String, AppDatabase>();
Map<String, AppDatabase> _remoteDatabases = Map<String, AppDatabase>();
/// Creates an instance of the database provider.
DatabaseProvider([LocalDatabaseFactory local, RemoteDatabaseFactory remote]) {
_localDbFactory = local ?? dependencyLocator<LocalDatabaseFactory>();
_remoteDbFactory = remote ?? dependencyLocator<RemoteDatabaseFactory>();
}
/// Gets a local database with the given [dbName].
Future<AppDatabase> getLocalDatabase(String dbName) async {
final name = _normalizeName(dbName);
if(_localDatabases.containsKey(name)) {
return _localDatabases[name];
}
return _localDatabases[name] = await _localDbFactory.create(name);
}
Future<AppDatabase> getRemoteDatabase(String dbName) async {
final name = _normalizeName(dbName);
if(_remoteDatabases.containsKey(name)) {
return _remoteDatabases[name];
}
return _remoteDatabases[name] = await _remoteDbFactory.create(name);
}
String _normalizeName(String dbName) {
if(!dbName.endsWith(".db")) {
dbName = join(dbName, ".db");
}
return dbName.toLowerCase();
}
}
| 0 |
mirrored_repositories/RelayApp/lib/data/db | mirrored_repositories/RelayApp/lib/data/db/dto/preferred_send_type.dart | enum PreferredSendType {
Unset,
Individually,
Group,
Anonymous
} | 0 |
mirrored_repositories/RelayApp/lib/data/db | mirrored_repositories/RelayApp/lib/data/db/dto/group_dto.dart | import 'package:sembast/utils/value_utils.dart';
import 'package:relay/data/db/dto/dto.dart';
import 'package:relay/data/db/dto/preferred_send_type.dart';
class GroupDto extends DTO {
final String name;
final PreferredSendType preferredSendType;
final List<int> contacts;
final DateTime lastMessageSentDate;
final DateTime creationDate;
GroupDto({int id, this.name, this.preferredSendType, this.contacts, this.lastMessageSentDate, this.creationDate}) : super(id: id ?? -1);
@override
GroupDto copy() {
return GroupDto(
name: name,
preferredSendType: preferredSendType,
contacts: contacts,
lastMessageSentDate: lastMessageSentDate,
creationDate: creationDate
);
}
@override
GroupDto.fromMap(Map<String, dynamic> map)
: this(
id: map['id'],
name: map['name'],
contacts: cloneList(map['contacts']).map((i) => i as int).toList(),
lastMessageSentDate: map.containsKey("lastMessageSentDate")
? map['lastMesssageSentDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['lastMessageSentDate'])
: null
: null,
creationDate: map.containsKey('creationDate') ? DateTime.fromMillisecondsSinceEpoch(map['creationDate']) : null,
preferredSendType: map.containsKey('preferredSendType')
? PreferredSendType.values.firstWhere((v) => v.toString().split('.').last == map['preferredSendType'], orElse: () => PreferredSendType.Unset)
: PreferredSendType.Unset);
@override
Map<String, dynamic> toMap() {
return {
'name': name,
'contacts': (contacts ?? <int>[]).toList(growable: false),
'preferredSendType': preferredSendType.toString().split('.').last,
'creationDate': creationDate == null ? null : creationDate.millisecondsSinceEpoch,
'lastMessageSentDate': lastMessageSentDate == null ? null : lastMessageSentDate.millisecondsSinceEpoch
};
}
GroupDto copyWith({
int id,
String name,
PreferredSendType preferredSendType,
List<int> contacts,
DateTime lastMessageSentDate,
DateTime creationDate
}) {
return GroupDto(
id: id ?? this.id,
name: name ?? this.name,
preferredSendType: preferredSendType ?? this.preferredSendType,
contacts: contacts ?? this.contacts,
lastMessageSentDate: lastMessageSentDate ?? this.lastMessageSentDate,
creationDate: creationDate ?? this.creationDate
);
}
} | 0 |
mirrored_repositories/RelayApp/lib/data/db | mirrored_repositories/RelayApp/lib/data/db/dto/message_dto.dart | import 'package:flutter/foundation.dart';
import 'package:sembast/utils/value_utils.dart';
import 'package:relay/data/db/dto/dto.dart';
class MessageDto extends DTO {
final String message;
final DateTime sendDateTime;
final Map<String, String> recipients;
final int groupId;
const MessageDto({
int id,
@required this.message,
@required this.sendDateTime,
@required this.recipients,
@required this.groupId}) : super(id: id ?? -1);
@override
MessageDto.fromMap(Map<String, dynamic> map) : this(
id: map['id'],
groupId: map['groupId'],
message: map['message'],
recipients: Map<String, String>.from(cloneMap(map['recipients'])),
sendDateTime: map.containsKey('sendDateTime') && map['sendDateTime'] != null ? DateTime.fromMillisecondsSinceEpoch(map['sendDateTime']) : null);
@override
MessageDto copy() {
return MessageDto(
id: id,
groupId: groupId,
message: message,
recipients: recipients,
sendDateTime: sendDateTime);
}
@override
Map<String, dynamic> toMap() {
try {
return {
'id' : id,
'groupId' : groupId,
'message' : message,
'sendDateTime' : sendDateTime.millisecondsSinceEpoch,
'recipients' : Map<String, dynamic>.from(recipients)
};
} catch(e) {
return {};
}
}
MessageDto copyWith({int id, int groupId, String message, DateTime sendDateTime, Map<String, String> recipients}) {
return MessageDto(
id: id ?? this.id,
message: message ?? this.message,
sendDateTime: sendDateTime ?? this.sendDateTime,
recipients: recipients ?? this.recipients,
groupId: groupId ?? this.groupId);
}
} | 0 |
mirrored_repositories/RelayApp/lib/data/db | mirrored_repositories/RelayApp/lib/data/db/dto/contact_dto.dart | import 'package:relay/data/db/dto/dto.dart';
class ContactDto extends DTO {
final String firstName;
final String lastName;
final String phone;
final String imagePath;
final String company;
final DateTime birthday;
const ContactDto({int id, this.firstName, this.lastName, this.phone, this.imagePath, this.company, this.birthday}) : super(id: id ?? -1);
@override
ContactDto.fromMap(Map<String, dynamic> map) : this(
id: map['id'],
firstName: map['firstName'],
lastName: map['lastName'],
phone: map['phone'],
imagePath: map['imagePath'],
company: map['company'],
birthday: map.containsKey('birthday') && map['birthday'] != null ? DateTime.fromMillisecondsSinceEpoch(map['birthday']) : null);
@override
ContactDto copy() {
return ContactDto(
id: id,
firstName: firstName,
lastName: lastName,
phone: phone,
imagePath: imagePath,
company: company,
birthday: birthday);
}
@override
Map<String, dynamic> toMap() {
return {
'id' : id,
'firstName': firstName,
'lastName': lastName,
'phone': phone,
'imagePath': imagePath,
'company': company,
'birthday': birthday != null ? birthday.millisecondsSinceEpoch : null
};
}
} | 0 |
mirrored_repositories/RelayApp/lib/data/db | mirrored_repositories/RelayApp/lib/data/db/dto/dto.dart | import 'package:relay/core/mappable.dart';
abstract class DTO extends Mappable {
final int id;
const DTO({this.id = -1});
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/core/mappable.dart | abstract class Mappable {
const Mappable();
Mappable.fromMap(Map<String, dynamic> map);
Map<String, dynamic> toMap();
Mappable copy();
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/core/app_settings_keys.dart | class AppSettingsConstants {
static const String profile_name_settings_key = "profile_name";
static const String profile_image_path_settings_key = "profile_image_page";
static const String profile_user_id = "profile_user_id";
static const String group_sorting_settings_key = "default_group_sort";
static const String signature_settings_key = "signature";
static const String auto_include_signature_settings_key = "auto_signature";
static const String analytics_app_open_count = "analytics_app_open_count";
static const String analytics_message_count = "analytics_message_count";
static const String reviews_have_been_shown = "reviews_have_been_shown";
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/mixins/route_aware_analytics_mixin.dart | import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:flutter/widgets.dart';
// A Navigator observer that notifies RouteAwares of changes to state of their Route
final routeObserver = RouteObserver<PageRoute>();
mixin RouteAwareAnalytics<T extends StatefulWidget> on State<T> implements RouteAware {
String get screenName;
String get screenClass;
@override
void didChangeDependencies() {
routeObserver.subscribe(this, ModalRoute.of(context));
super.didChangeDependencies();
}
@override
void dispose() {
routeObserver.unsubscribe(this);
super.dispose();
}
@override
void didPop() {}
@override
void didPopNext() {
// Called when the top route has been popped off,
// and the current route shows up.
_setCurrentScreen(screenName, screenClass);
}
@override
void didPush() {
// Called when the current route has been pushed.
_setCurrentScreen(screenName, screenClass);
}
@override
void didPushNext() {}
Future<void> _setCurrentScreen(String screenName, String screenClass) {
print('Setting current screen to $screenName');
return FirebaseAnalytics().setCurrentScreen(
screenName: screenName,
screenClassOverride: screenClass,
);
}
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/mixins/color_mixin.dart | import 'dart:ui';
extension HexColor on Color {
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
static Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}
/// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`).
String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
'${alpha.toRadixString(16).padLeft(2, '0')}'
'${red.toRadixString(16).padLeft(2, '0')}'
'${green.toRadixString(16).padLeft(2, '0')}'
'${blue.toRadixString(16).padLeft(2, '0')}';
} | 0 |
mirrored_repositories/RelayApp/lib | mirrored_repositories/RelayApp/lib/ui/app_styles.dart | import 'package:flutter/material.dart';
import 'package:relay/mixins/color_mixin.dart';
class AppStyles {
static Color get lightGrey => HexColor.fromHex("#F3F3F3");
static Color get darkGrey => HexColor.fromHex("#707070");
static Color get primaryGradientStart => HexColor.fromHex("#3E7389");
static Color get primaryGradientEnd => HexColor.fromHex("#4447A8");
static Color get brightGreenBlue => HexColor.fromHex("#76CAD8");
static TextStyle get heading1 => TextStyle(fontFamily: "Avenir", fontSize: 24, fontWeight: FontWeight.bold, color:Colors.white);
static TextStyle get heading2 => TextStyle(fontFamily: "Avenir", fontSize: 16, color:Colors.black);
static TextStyle get heading2Bold => heading2.copyWith(fontWeight: FontWeight.bold);
static TextStyle get paragraph => TextStyle(fontFamily: "Avenir", fontSize: 14, color:Colors.white,);
static TextStyle get smallText => TextStyle(fontFamily: "Avenir", fontSize: 10, color:Colors.black,);
static double get horizontalMargin => 30.0;
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/transitions/fade_route.dart | import 'package:flutter/material.dart';
class FadeRoute extends PageRouteBuilder {
final Widget page;
FadeRoute({this.page})
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) =>
page,
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
FadeTransition(
opacity: animation,
child: child,
),
);
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/transitions/scale_route.dart | import 'package:flutter/material.dart';
class ScaleRoute extends PageRouteBuilder {
final Widget page;
ScaleRoute({this.page})
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) =>
page,
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
ScaleTransition(
scale: Tween<double>(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Curves.fastOutSlowIn,
),
),
child: child,
),
);
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/three_dots.dart | import 'package:flutter/material.dart';
class ThreeDots extends StatelessWidget {
final Function onTap;
const ThreeDots({
Key key, this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: 30,
height: 30,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 3.0),
child: Container(
height: 3.00,
width: 3.00,
decoration: BoxDecoration(
color: Color(0xff707070),
shape: BoxShape.circle, ),),
),
Padding(
padding: const EdgeInsets.only(right: 3.0),
child: Container(
height: 3.00,
width: 3.00,
decoration: BoxDecoration(
color: Color(0xff707070),
shape: BoxShape.circle, ),),
),
Padding(
padding: const EdgeInsets.only(right: 3.0),
child: Container(
height: 3.00,
width: 3.00,
decoration: BoxDecoration(
color: Color(0xff707070),
shape: BoxShape.circle, ),),
),
],),
),
);
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/message_container.dart | import 'dart:math';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:relay/models/message_recipient.dart';
import 'package:relay/ui/app_styles.dart';
import 'package:relay/translation/translations.dart';
class MessageContainer extends StatelessWidget {
/// The text of the message.
final String message;
/// The [recipients] that received this [message];
final List<MessageRecipient> recipients;
/// `DateTime` when the message was sent.
final DateTime sendDateTime;
/// Callback when the details text is tapped.
final Function onDetailsPressed;
/// Padding after the message box and details text have been drawn.
final EdgeInsets padding;
const MessageContainer({
Key key,
@required this.message,
@required this.sendDateTime,
@required this.onDetailsPressed,
@required this.recipients,
this.padding = const EdgeInsets.only(bottom: 40.0),
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(minHeight: 80.0),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [AppStyles.primaryGradientStart, AppStyles.primaryGradientEnd],
begin: Alignment.bottomLeft,
end: Alignment.topRight),
borderRadius: BorderRadius.only(topLeft: Radius.circular(40.00), topRight: Radius.circular(40.00), bottomLeft: Radius.circular(40.00))),
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text(
message,
style: AppStyles.paragraph.copyWith(color: Colors.white)))),
),
Padding(padding: EdgeInsets.only(top: 3.0)),
GestureDetector(
onTap: () => showDialog(
context: context,
child: AlertDialog(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("%d Recipients".plural(recipients.length),
style: AppStyles.heading1.copyWith(color: Colors.black)),
Text(
"Sent on %s".fill([DateFormat.yMMMMd(Intl.defaultLocale).add_jm().format(sendDateTime)]),
style: AppStyles.paragraph.copyWith(color: Colors.black))
],
),
content: SizedBox(
width: min(400.0, MediaQuery.of(context).size.width - 80.0),
height: min(200.0, MediaQuery.of(context).size.height / 2),
child: ListView.builder(
shrinkWrap: true,
itemCount: recipients.length,
itemBuilder: (context, index) {
var recipient = recipients[index];
return Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Column(children: <Widget>[
Text(recipient.name, style: AppStyles.heading2Bold),
Text(recipient.number, style: AppStyles.paragraph.copyWith(color: Colors.black))],),
);
}),
))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"Sent to %d people | ".plural(recipients.length) + DateFormat.yMd(Intl.defaultLocale).add_jm().format(sendDateTime),
style: AppStyles.paragraph.copyWith(color: AppStyles.darkGrey),),
SizedBox(width: 5.0,),
Container(
height: 16.0,
width: 16.0,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: AppStyles.darkGrey)),
child: AutoSizeText("i", minFontSize: 0,))
],
),
),
],),
);
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/contact_list_item.dart | import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:relay/ui/models/add_new_group_model.dart';
import 'package:relay/ui/models/contact_search_result_model.dart';
import 'package:relay/ui/app_styles.dart';
class ContactListItem extends StatelessWidget {
const ContactListItem({
Key key,
@required this.contact,
}) : super(key: key);
final ContactSearchResultModel contact;
@override
Widget build(BuildContext context) {
var model = Provider.of<AddNewGroupModel>(context);
var lastContact = model.filteredAllContactsList.last;
return GestureDetector(
onTap: () => model.selectContact(context: context, contact: contact),
child: Container(
height: 80.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
contact.selected
? Container(
width: 50,
height: 50,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppStyles.brightGreenBlue
),
child: Icon(Icons.check, color: Colors.white))
: contact.image != null && contact.image.isNotEmpty
? Container(
width: 50,
height: 50,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: MemoryImage(contact.image),
fit: BoxFit.fill)))
: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppStyles.primaryGradientStart,
AppStyles.primaryGradientEnd],
begin: Alignment.bottomLeft,
end: Alignment.topRight),
shape: BoxShape.circle),
child: Center(
child:Padding(
padding: const EdgeInsets.all(8.0),
child: AutoSizeText(contact.initials, style: AppStyles.heading1.copyWith(color: Colors.white),),
),),),
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 14.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextOneLine(contact.name, style: AppStyles.heading2Bold,),
Text(contact.phoneNumberSubtitle, style: AppStyles.smallText)
],
),
),
)
],),
if(contact != lastContact) Center(child: Container(width: MediaQuery.of(context).size.width * 0.75, height: 1.00, color: Color(0xffdbdbdb),))
],),
),
);
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/hamburger.dart | import 'package:flutter/material.dart';
class Hamburger extends StatelessWidget {
final double width;
final Function onTap;
const Hamburger({
Key key,
this.width = 16.0,
@required this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: SizedBox(
width: width + 15.0,
height: width + 15.0,
child: Center(
child: SizedBox(
width: width,
child: Column(
children: <Widget>[
Align(
alignment: Alignment.topRight,
child: FractionallySizedBox(
widthFactor: 0.7,
child: Container(
height: 2.00,
color: Colors.white)),
),
LayoutBuilder(
builder: (_, cc) => Padding(
padding: EdgeInsets.symmetric(vertical: 4.0),
child: Container(
height: 2.00,
width: cc.maxWidth,
color: Colors.white),
),
),
Align(
alignment: Alignment.bottomLeft,
child: FractionallySizedBox(
widthFactor: 0.7,
child: Container(
height: 2.00,
color: Colors.white)),
),
],
),
),
),
),
);
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/long_arrow_button.dart | import 'dart:ui';
import 'package:flutter/material.dart';
class LongArrowButton extends StatelessWidget {
final Function() onTap;
const LongArrowButton({
Key key,
@required this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: CustomPaint(
size: Size(MediaQuery.of(context).size.width / 3, 20.0),
painter: _Arrow()),
);
}
}
class _Arrow extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final pointMode = PointMode.polygon;
final arrowBack = size.height / 2.5;
final arrowHeadPoints = [
Offset(size.width - arrowBack, 0),
Offset(size.width, size.height / 2),
Offset(size.width - arrowBack, size.height)
];
final linePoints = [
Offset(0, size.height / 2),
Offset(size.width, size.height / 2)
];
final paint = Paint()
..color = Colors.white
.. strokeWidth = 0.5
..strokeCap = StrokeCap.round;
canvas.drawPoints(pointMode, arrowHeadPoints, paint);
canvas.drawPoints(pointMode, linePoints, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/widgets/group_item_card.dart | import 'dart:io';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:commons/commons.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:relay/models/group_item.dart';
import 'package:relay/ui/screens/compose_message_screen.dart';
import 'package:vibration/vibration.dart';
import 'package:relay/ui/models/groups_collection_model.dart';
import 'package:relay/ui/screens/group_view_screen.dart';
import 'package:relay/models/toggleable_group_item.dart';
import 'package:relay/ui/app_styles.dart';
import 'package:relay/models/contact_item.dart';
import 'package:relay/ui/widgets/three_dots.dart';
import 'package:relay/translation/translations.dart';
class GroupItemCard extends StatelessWidget {
final ToggleableGroupItemModel group;
const GroupItemCard({
Key key, @required this.group,
}) : super(key: key);
@override
Widget build(BuildContext context) {
var model = Provider.of<GroupsCollectionModel>(context);
return Padding(
padding: const EdgeInsets.only(bottom: 15.0),
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.fastLinearToSlowEaseIn,
height: group.selected ? 142.0 : 100.0,
width: MediaQuery.of(context).size.width,
child: Stack(
children: <Widget>[
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
height: 70.00,
decoration: BoxDecoration(
color: Colors.white12,
boxShadow: [
BoxShadow(
offset: Offset(1.00,1.00),
color: Color(0xff000000).withOpacity(0.16),
blurRadius: 25,),],
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20.0),
bottomRight: Radius.circular(20.0))),
child: Padding(
padding: const EdgeInsets.only(top:28.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
GestureDetector(
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => GroupViewScreen(group))),
child: Text(
"%d Contacts".i18n.fill([group.contacts.length]),
style: AppStyles.heading2Bold.copyWith(color: Colors.white))),
Padding(
padding: const EdgeInsets.all(6.0),
child: Container(
width: 2.00,
color: Color(0xffffffff).withOpacity(0.12),),
),
GestureDetector(
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => ComposeMessageScreen(group: group, recipients: group.contacts))),
child: Text(
"Compose".i18n,
style: AppStyles.heading2Bold.copyWith(color: AppStyles.brightGreenBlue)))
],),
),),
),
Positioned(
top: 0,
left: 0,
right: 0,
height: 100,
child: GestureDetector(
onLongPress: () => _showModalDialog(context, group),
onDoubleTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => GroupViewScreen(group))),
onTap: () {
model.toggleSelected(group);
},
child: Container(
decoration: BoxDecoration(
color: Color(0xffffffff),
boxShadow: [
BoxShadow(
offset: Offset(2.00, 2.00),
color: Color(0xff000000).withOpacity(0.16),
blurRadius: 25.0,),],
borderRadius: BorderRadius.circular(20.00),),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(group.name, style: AppStyles.heading2Bold),
Row(children: group.contacts.length > 5
? group.contacts
.take(5)
.map((contact) => contact.imagePath == null || contact.imagePath.isEmpty
? _buildInitialsAvatar(contact)
: _getSmallContactImage(contact.imageFile)).toList() + [ThreeDots()]
: group.contacts.map((contact) => contact.imagePath == null || contact.imagePath.isEmpty
? _buildInitialsAvatar(contact)
: _getSmallContactImage(contact.imageFile)).toList())
],)
),
),
),
),
],
),
),
);
}
Widget _buildInitialsAvatar(ContactItemModel contact) {
return Padding(
padding: const EdgeInsets.only(right:10.0),
child: Container(
width: 25.0,
height: 25.0,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppStyles.primaryGradientStart,
AppStyles.primaryGradientEnd],
begin: Alignment.bottomLeft,
end: Alignment.topRight),
shape: BoxShape.circle),
child: Center(
child:Padding(
padding: const EdgeInsets.all(4.0),
child: AutoSizeText(
contact.initials,
minFontSize: 1,
style: AppStyles.heading1.copyWith(color: Colors.white),),
),),),
);
}
Widget _getSmallContactImage(File image) {
return Padding(
padding: const EdgeInsets.only(right:10.0),
child: Container(
height: 25.0,
width: 25.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: FileImage(image))
)));
}
void _showModalDialog(BuildContext context, GroupItemModel model) async {
var groupCollectionModel = Provider.of<GroupsCollectionModel>(context, listen: false);
try {
if(await Vibration.hasVibrator()) {
await Vibration.vibrate(duration: 100);
}
} catch(_) {}
optionsDialog(
context,
model.name,
<Option>[
if(!groupCollectionModel.shouldShowPaywall) Option(
Text("Duplicate".i18n, style: AppStyles.heading2Bold),
Icon(Icons.content_copy),
() => Provider.of<GroupsCollectionModel>(context, listen: false).duplicateGroup(model)
),
Option(
Text("Delete".i18n, style: AppStyles.heading2Bold),
Icon(Icons.delete_outline),
() => confirmationDialog(
context,
"Are you sure you want to delete the group '%s'?".fill([model.name]),
confirmationText: "Check this box to confirm delete!".i18n,
title: "Confirm delete?".i18n,
icon: AlertDialogIcon.WARNING_ICON,
negativeText: "No".i18n,
positiveText: "Yes".i18n,
positiveAction: () async {
await Provider.of<GroupsCollectionModel>(context, listen: false).deleteGroup(model);
})
)
]);
}
} | 0 |
mirrored_repositories/RelayApp/lib/ui | mirrored_repositories/RelayApp/lib/ui/models/app_bootstraper_model.dart | import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:relay/core/app_settings_keys.dart';
import 'package:relay/data/db/database_upgrader.dart';
import 'package:relay/services/database_service.dart';
import 'package:relay/ui/models/onboarding/onboarding_model.dart';
import 'package:relay/ioc/dependency_registrar.dart';
import 'package:relay/services/app_settings_service.dart';
import 'package:relay/ui/models/package_info_model.dart';
class AppBootstrapperModel extends ChangeNotifier {
final String lastOnboardingVersionSettingString = "last_onboarding_version";
final Duration _minimumWaitDuration = Duration(milliseconds: 1500);
final AppSettingsService _appSettings;
final DatabaseService _databaseService;
BootstrapStatus _status = BootstrapStatus.Initializing;
AppBootstrapperModel._(this._appSettings, this._databaseService);
factory AppBootstrapperModel([AppSettingsService appSettings, DatabaseService dbService]) {
return AppBootstrapperModel._(
appSettings ?? dependencyLocator<AppSettingsService>(),
dbService ?? dependencyLocator<DatabaseService>());
}
BootstrapStatus get status => _status;
Future init(BuildContext context) async {
BootstrapStatus status;
Stopwatch stopwatch = Stopwatch();
stopwatch.start();
DatabaseUpgrader.upgradeDatabase(await _databaseService.getMainStorage());
var lastOnboardingVersion = await _appSettings.getSettingInt(lastOnboardingVersionSettingString, 0);
if(lastOnboardingVersion < OnboardingModel.currentOnboardingVersion) {
status = BootstrapStatus.RequiresOnboarding;
} else {
status = BootstrapStatus.ReadyToLaunch;
}
while(await Permission.contacts.isGranted == false && !await Permission.contacts.isPermanentlyDenied) {
await Permission.contacts.request();
if(await Permission.contacts.isDenied) {
break;
}
}
await _incrementAppOpenCount();
await Provider.of<PackageInfoModel>(context, listen: false).init();
stopwatch.stop();
if(stopwatch.elapsedMilliseconds < _minimumWaitDuration.inMilliseconds) {
await Future.delayed(Duration(milliseconds: _minimumWaitDuration.inMilliseconds - stopwatch.elapsedMilliseconds));
}
_status = status;
notifyListeners();
}
Future _incrementAppOpenCount() async {
var openCount = await _appSettings.getSettingInt(AppSettingsConstants.analytics_app_open_count);
openCount++;
_appSettings.setSettingInt(AppSettingsConstants.analytics_app_open_count, openCount);
print("recording app open count: $openCount");
}
}
enum BootstrapStatus {
Initializing,
ReadyToLaunch,
RequiresOnboarding
} | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.