mirror of
https://github.com/flutter/samples.git
synced 2026-05-01 20:16:50 +00:00
Adding Rally App to Flutter Samples (#135)
This commit is contained in:
committed by
Andrew Brogdon
parent
3348c2f2dd
commit
c056b754a2
37
material_studies/rally/lib/tabs/accounts.dart
Normal file
37
material_studies/rally/lib/tabs/accounts.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:rally/data.dart';
|
||||
import 'package:rally/finance.dart';
|
||||
import 'package:rally/charts/pie_chart.dart';
|
||||
|
||||
/// A page that shows a summary of accounts.
|
||||
class AccountsView extends StatelessWidget {
|
||||
final List<AccountData> items = DummyDataService.getAccountDataList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double balanceTotal = sumAccountDataPrimaryAmount(items);
|
||||
return FinancialEntityView(
|
||||
heroLabel: 'Total',
|
||||
heroAmount: balanceTotal,
|
||||
segments: buildSegmentsFromAccountItems(items),
|
||||
wholeAmount: balanceTotal,
|
||||
financialEntityCards: buildAccountDataListViews(items),
|
||||
);
|
||||
}
|
||||
}
|
||||
43
material_studies/rally/lib/tabs/bills.dart
Normal file
43
material_studies/rally/lib/tabs/bills.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:rally/data.dart';
|
||||
import 'package:rally/finance.dart';
|
||||
import 'package:rally/charts/pie_chart.dart';
|
||||
|
||||
/// A page that shows a summary of bills.
|
||||
class BillsView extends StatefulWidget {
|
||||
@override
|
||||
_BillsViewState createState() => _BillsViewState();
|
||||
}
|
||||
|
||||
class _BillsViewState extends State<BillsView>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final List<BillData> items = DummyDataService.getBillDataList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double dueTotal = sumBillDataPrimaryAmount(items);
|
||||
return FinancialEntityView(
|
||||
heroLabel: 'Due',
|
||||
heroAmount: dueTotal,
|
||||
segments: buildSegmentsFromBillItems(items),
|
||||
wholeAmount: dueTotal,
|
||||
financialEntityCards: buildBillDataListViews(items),
|
||||
);
|
||||
}
|
||||
}
|
||||
43
material_studies/rally/lib/tabs/budgets.dart
Normal file
43
material_studies/rally/lib/tabs/budgets.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:rally/charts/pie_chart.dart';
|
||||
import 'package:rally/data.dart';
|
||||
import 'package:rally/finance.dart';
|
||||
|
||||
class BudgetsView extends StatefulWidget {
|
||||
@override
|
||||
_BudgetsViewState createState() => _BudgetsViewState();
|
||||
}
|
||||
|
||||
class _BudgetsViewState extends State<BudgetsView>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final List<BudgetData> items = DummyDataService.getBudgetDataList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double capTotal = sumBudgetDataPrimaryAmount(items);
|
||||
double usedTotal = sumBudgetDataAmountUsed(items);
|
||||
return FinancialEntityView(
|
||||
heroLabel: 'Left',
|
||||
heroAmount: capTotal - usedTotal,
|
||||
segments: buildSegmentsFromBudgetItems(items),
|
||||
wholeAmount: capTotal,
|
||||
financialEntityCards: buildBudgetDataListViews(items, context),
|
||||
);
|
||||
}
|
||||
}
|
||||
151
material_studies/rally/lib/tabs/overview.dart
Normal file
151
material_studies/rally/lib/tabs/overview.dart
Normal file
@@ -0,0 +1,151 @@
|
||||
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:rally/colors.dart';
|
||||
import 'package:rally/data.dart';
|
||||
import 'package:rally/finance.dart';
|
||||
import 'package:rally/formatters.dart';
|
||||
|
||||
/// A page that shows a status overview.
|
||||
class OverviewView extends StatefulWidget {
|
||||
@override
|
||||
_OverviewViewState createState() => _OverviewViewState();
|
||||
}
|
||||
|
||||
class _OverviewViewState extends State<OverviewView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accountDataList = DummyDataService.getAccountDataList();
|
||||
final billDataList = DummyDataService.getBillDataList();
|
||||
final budgetDataList = DummyDataService.getBudgetDataList();
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: ListView(children: [
|
||||
_AlertsView(),
|
||||
SizedBox(height: 16),
|
||||
_FinancialView(
|
||||
title: 'Accounts',
|
||||
total: sumAccountDataPrimaryAmount(accountDataList),
|
||||
financialItemViews: buildAccountDataListViews(accountDataList),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
_FinancialView(
|
||||
title: 'Bills',
|
||||
total: sumBillDataPrimaryAmount(billDataList),
|
||||
financialItemViews: buildBillDataListViews(billDataList),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
_FinancialView(
|
||||
title: 'Budgets',
|
||||
total: sumBudgetDataPrimaryAmount(budgetDataList),
|
||||
financialItemViews: buildBudgetDataListViews(budgetDataList, context),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AlertsView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 16, top: 4, bottom: 4),
|
||||
color: RallyColors.cardBackground,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Alerts'),
|
||||
FlatButton(
|
||||
onPressed: () {},
|
||||
child: Text('SEE ALL'),
|
||||
textColor: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(color: RallyColors.primaryBackground, height: 1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Heads up, you’ve used up 90% of your Shopping budget for '
|
||||
'this month.'),
|
||||
),
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.sort, color: RallyColors.white60),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FinancialView extends StatelessWidget {
|
||||
_FinancialView({this.title, this.total, this.financialItemViews});
|
||||
|
||||
final String title;
|
||||
final double total;
|
||||
final List<FinancialEntityCategoryView> financialItemViews;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
color: RallyColors.cardBackground,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text(title),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16),
|
||||
child: Text(
|
||||
Formatters.usdWithSign.format(total),
|
||||
style: theme.textTheme.body2.copyWith(
|
||||
fontSize: 44.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
...financialItemViews.sublist(0, min(financialItemViews.length, 3)),
|
||||
FlatButton(
|
||||
child: Text('SEE ALL'),
|
||||
textColor: Colors.white,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
54
material_studies/rally/lib/tabs/settings.dart
Normal file
54
material_studies/rally/lib/tabs/settings.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2019-present the Flutter authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:rally/data.dart';
|
||||
|
||||
class SettingsView extends StatefulWidget {
|
||||
@override
|
||||
_SettingsViewState createState() => _SettingsViewState();
|
||||
}
|
||||
|
||||
class _SettingsViewState extends State<SettingsView> {
|
||||
List<Widget> items = DummyDataService.getSettingsTitles()
|
||||
.map((title) => _SettingsItem(title))
|
||||
.toList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(children: items);
|
||||
}
|
||||
}
|
||||
|
||||
class _SettingsItem extends StatelessWidget {
|
||||
_SettingsItem(this.title);
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlatButton(
|
||||
textColor: Colors.white,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(children: <Widget>[
|
||||
Text(title),
|
||||
]),
|
||||
),
|
||||
onPressed: () {},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user