repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/page_path.dart
|
class PagePath {
static const String privacyPolicyPage = 'privacyPolicy';
static const String addCardPage = 'addCardPage';
static const String addTaskPage = 'addTask';
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/detail_screen.dart
|
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:todo/pages/page_path.dart';
import 'package:todo/widgets/todo_badge/widget.dart';
import 'package:todo/widgets/task_progress_indicator/widget.dart';
import 'package:todo/widgets/delete_alert_dialog/widget.dart';
import 'package:todo/model/task_list_model.dart';
import 'package:todo/model/hero_id_model.dart';
import 'package:todo/utils/color_utils.dart';
class DetailScreen extends StatefulWidget {
final String taskId;
final HeroId heroId;
DetailScreen({
@required this.taskId,
@required this.heroId,
});
@override
DetailScreenState createState() => DetailScreenState();
}
class DetailScreenState extends State<DetailScreen>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<Offset> _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
);
_animation = Tween<Offset>(begin: Offset(0, 1.0), end: Offset(0.0, 0.0))
.animate(_controller);
}
@override
Widget build(BuildContext context) {
_controller.forward();
return AnimatedBuilder(
animation:_animation,
builder: (BuildContext context, Widget child) {
return ScopedModelDescendant<TodoListModel>(
builder: (BuildContext context, Widget child, TodoListModel model) {
var _task;
try {
_task = model.tasks.firstWhere((t) => t.id == widget.taskId);
} catch (e) {
return Container(color: Colors.white);
}
var _todos =
model.todos.where((t) => t.parent == widget.taskId).toList();
var _hero = widget.heroId;
var _color = ColorUtils.getColorFrom(_task.color);
return Theme(
data: ThemeData(primarySwatch: _color),
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0.0,
iconTheme: IconThemeData(color: Colors.black26),
brightness: Brightness.light,
backgroundColor: Colors.white,
actions: <Widget>[
DeleteAlertDialog(
color: _color,
onActionPressed: () => model.removeTask(_task),
)
],
),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 0.0, vertical: 8.0),
child: Column(children: <Widget>[
Container(
margin:
EdgeInsets.symmetric(horizontal: 36.0, vertical: 0.0),
height: 160,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
TodoBadge(
id: _hero.codePointId,
color: _color,
codePoint: _task.codePoint,
),
Spacer(
flex: 1,
),
Container(
margin: EdgeInsets.only(bottom: 4.0),
child: Hero(
tag: _hero.remainingTaskId,
child: Text(
"${model.getTotalTodosFrom(_task)} Task",
style: Theme.of(context)
.textTheme
.body1
.copyWith(color: Colors.grey[500]),
),
)
),
Hero(
tag: _hero.nameId,
child:Text(_task.name,
style: Theme.of(context)
.textTheme
.title
.copyWith(color: Colors.black54)
),
),
Spacer(),
Hero(
tag: _hero.progressId,
child: TaskProgressIndicator(
color: _color,
progress: model.getTaskCompletionPercent(_task),
),
),
],
),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(top: 16.0),
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
var todo = _todos[index];
return Container(
padding: EdgeInsets.only(left: 22.0, right: 22.0),
child: ListTile(
onTap: () => model.updateTodo(todo.copy(
isCompleted: todo.isCompleted == 1 ? 0 : 1)),
contentPadding: EdgeInsets.symmetric(
vertical: 4.0, horizontal: 0.0),
leading: Checkbox(
onChanged: (value) => model.updateTodo(
todo.copy(
isCompleted:
todo.isCompleted == 1 ? 0 : 1)),
value: todo.isCompleted == 1 ? true : false),
title: Text(
todo.name,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w600,
color: todo.isCompleted == 1
? _color
: Colors.black54,
decoration: todo.isCompleted == 1
? TextDecoration.lineThrough
: TextDecoration.none),
),
trailing: IconButton(
icon: Icon(Icons.delete_outline),
onPressed: () => model.removeTodo(todo),
),
),
);
},
itemCount: _todos.length,
),
),
)
]),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
backgroundColor: _color,
foregroundColor: Colors.white,
onPressed: () {
Map<String, dynamic> args = {"taskId": widget.taskId, "heroIds": _hero};
Navigator.of(context).pushNamed(
PagePath.addTaskPage,
arguments: args);
},
),
)
);
}
);
},
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_task_page/state.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/model/hero_id_model.dart';
class AddTaskState implements Cloneable<AddTaskState> {
String newTask;
String taskId;
HeroId heroIds;
@override
AddTaskState clone() {
return AddTaskState()
..newTask = newTask
..taskId = taskId
..heroIds = heroIds;
}
}
AddTaskState initState(Map<String, dynamic> args) {
return AddTaskState()
..newTask = ""
..taskId = args["taskId"]
..heroIds = args["heroIds"];
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_task_page/view.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:todo/model/task_list_model.dart';
import 'package:todo/utils/color_utils.dart';
import 'package:todo/widgets/todo_badge/widget.dart';
import 'action.dart';
import 'state.dart';
Widget buildView(AddTaskState state, Dispatch dispatch, ViewService viewService) {
return ScopedModelDescendant<TodoListModel>(
builder: (BuildContext context, Widget child, TodoListModel model) {
if (model.tasks.isEmpty) {
return Container(
color: Colors.white,
);
}
var _task = model.tasks.firstWhere((t) => t.id == state.taskId);
var _color = ColorUtils.getColorFrom(_task.color);
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
'New Task',
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black26),
brightness: Brightness.light,
),
body: Container(
constraints: BoxConstraints.expand(),
padding: EdgeInsets.symmetric(horizontal: 36.0, vertical: 36.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'What task are you planning to perfrom?',
style: TextStyle(
color: Colors.black38,
fontWeight: FontWeight.w600,
fontSize: 16.0),
),
Container(height: 16.0),
TextField(
autofocus: true,
cursorColor: _color,
onChanged: (text) {
state.newTask = text;
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Your Task...',
hintStyle: TextStyle(
color: Colors.black26,
)),
style: TextStyle(
color: Colors.black54,
fontWeight: FontWeight.w500,
fontSize: 36.0),
),
Container(height: 26.0),
Row(
children: [
TodoBadge(
id: state.heroIds.codePointId,
codePoint: _task.codePoint,
color: _color,
size: 24,
),
Container(width: 22.0),
Text(_task.name,
style: TextStyle(
color: Colors.black38,
fontWeight: FontWeight.w600
))
],
)
],
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
floatingActionButton: Builder(
builder: (BuildContext context) {
return FloatingActionButton.extended(
icon: Icon(Icons.save),
label: Text('Create Task'),
backgroundColor: _color,
onPressed: () {
if (state.newTask.isEmpty) {
final snackBar = SnackBar(
backgroundColor: _color,
content: Text(
'Ummm...It seems that you are trying to add invisible task which is not allowed in this realm.'),
);
Scaffold.of(context).showSnackBar(snackBar);
} else {
dispatch(AddTaskActionCreator.addTaskAction(_color, model, state.newTask, state.taskId));
}
},
);
},
),
);
},
);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_task_page/page.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'effect.dart';
import 'state.dart';
import 'view.dart';
class AddTaskPage extends Page<AddTaskState, Map<String, dynamic>> {
AddTaskPage()
: super(
initState: initState,
effect: buildEffect(),
view: buildView,
dependencies: Dependencies<AddTaskState>(
adapter: null,
slots: <String, Dependent<AddTaskState>>{
}),
middleware: <Middleware<AddTaskState>>[
],);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_task_page/action.dart
|
import 'package:flutter/material.dart' hide Action;
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/model/task_list_model.dart';
enum AddTaskAction { onAddTask }
class AddTaskActionCreator {
static Action addTaskAction(Color color, TodoListModel model, String newTask, String taskId) {
return Action(AddTaskAction.onAddTask, payload: {
"color": color,
"model": model,
"newTask": newTask,
"taskId": taskId
});
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_task_page/effect.dart
|
import 'package:flutter/material.dart' hide Action;
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/model/todo_model.dart';
import 'action.dart';
import 'state.dart';
Effect<AddTaskState> buildEffect() {
return combineEffects(<Object, Effect<AddTaskState>>{
AddTaskAction.onAddTask: _onAddTaskAction,
});
}
void _onAddTaskAction(Action action, Context<AddTaskState> ctx) {
action.payload["model"].addTodo(
Todo(
action.payload["newTask"],
parent: action.payload["taskId"],
)
);
Navigator.pop(ctx.context);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/state.dart
|
import 'package:flutter/material.dart';
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/utils/color_utils.dart';
class AddCardState implements Cloneable<AddCardState> {
String category;
Color taskColor;
IconData taskIcon;
@override
AddCardState clone() {
return AddCardState()
..category
..taskColor
..taskIcon;
}
}
AddCardState initState(Map<String, dynamic> args) {
return AddCardState()
..category = ""
..taskColor = ColorUtils.defaultColors[0]
..taskIcon = Icons.work;
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/view.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:todo/model/task_list_model.dart';
import 'package:todo/widgets/color_picker_builder/widget.dart';
import 'package:todo/widgets/icon_picker_builder/widget.dart';
import 'action.dart';
import 'state.dart';
Widget buildView(AddCardState state, Dispatch dispatch, ViewService viewService) {
return ScopedModelDescendant<TodoListModel>(
builder: (BuildContext context, Widget child, TodoListModel model) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
'New Category',
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black26),
brightness: Brightness.light,
),
body: Container(
constraints: BoxConstraints.expand(),
padding: EdgeInsets.symmetric(horizontal: 36.0, vertical: 36.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Category will help you group related task!',
style: TextStyle(
color: Colors.black38,
fontWeight: FontWeight.w600,
fontSize: 16.0),
),
Container(height: 16.0),
TextField(
autofocus: true,
cursorColor: state.taskColor,
onChanged: (text) {
state.category = text;
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Category Name...',
hintStyle: TextStyle(
color: Colors.black26,
)),
style: TextStyle(
color: Colors.black54,
fontWeight: FontWeight.w500,
fontSize: 36.0),
),
Container(height: 26.0),
Row(
children: [
ColorPickerBuilder(
color: state.taskColor,
onColorChanged: (newColor) {
state.taskColor = newColor;
dispatch(AddCardActionCreator.changeState(state));
}
),
Container(width: 22.0),
IconPickerBuilder(
iconData: state.taskIcon,
highlightColor: state.taskColor,
onIconChanged: (newIcon) {
state.taskIcon = newIcon;
dispatch(AddCardActionCreator.changeState(state));
}
),
],
)
],
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
floatingActionButton: Builder(
builder: (BuildContext context) {
return FloatingActionButton.extended(
icon: Icon(Icons.save),
label: Text('Create New Card'),
backgroundColor: state.taskColor,
onPressed: () {
if (state.category.isEmpty) {
final snackBar = SnackBar(
backgroundColor: state.taskColor,
content: Text(
'Ummm...It seems that you are trying to add invisible category which is not allowed in this realm.'),
);
Scaffold.of(context).showSnackBar(snackBar);
} else {
dispatch(AddCardActionCreator.onAddCategory(state, model));
}
},
);
},
),
);
},
);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/page.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'effect.dart';
import 'reducer.dart';
import 'state.dart';
import 'view.dart';
class AddCardPage extends Page<AddCardState, Map<String, dynamic>> {
AddCardPage()
: super(
initState: initState,
effect: buildEffect(),
reducer: buildReducer(),
view: buildView,
dependencies: Dependencies<AddCardState>(
adapter: null,
slots: <String, Dependent<AddCardState>>{
}),
middleware: <Middleware<AddCardState>>[
],);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/action.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/model/task_list_model.dart';
import 'state.dart';
enum AddCardAction { changeState, onAddCategory }
class AddCardActionCreator {
static Action changeState(AddCardState state) {
return Action(AddCardAction.changeState, payload: state);
}
static Action onAddCategory(AddCardState state, TodoListModel model) {
return Action(AddCardAction.onAddCategory, payload: {
"category": state.category,
"taskColor": state.taskColor,
"taskIconCodePoint": state.taskIcon.codePoint,
"model": model,
});
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/reducer.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'action.dart';
import 'state.dart';
Reducer<AddCardState> buildReducer() {
return asReducer(
<Object, Reducer<AddCardState>>{
AddCardAction.changeState: _changeStateAction,
},
);
}
AddCardState _changeStateAction(AddCardState state, Action action) {
AddCardState state = action.payload;
final AddCardState newState = state.clone()
..category = state.category
..taskColor = state.taskColor
..taskIcon = state.taskIcon;
return newState;
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/add_card_page/effect.dart
|
import 'package:flutter/material.dart' hide Action;
import 'package:fish_redux/fish_redux.dart';
import 'package:todo/model/task_model.dart';
import 'action.dart';
import 'state.dart';
Effect<AddCardState> buildEffect() {
return combineEffects(<Object, Effect<AddCardState>>{
AddCardAction.onAddCategory: _onAddCategoryAction,
});
}
void _onAddCategoryAction(Action action, Context<AddCardState> ctx) {
action.payload["model"].addTask(Task(
action.payload["category"],
codePoint: action.payload["taskIconCodePoint"],
color: action.payload["taskColor"].value
));
Navigator.pop(ctx.context);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/privacy_policy_page/state.dart
|
import 'package:fish_redux/fish_redux.dart';
class PrivacyPolicyPageState implements Cloneable<PrivacyPolicyPageState> {
String privacyPolicy;
@override
PrivacyPolicyPageState clone() {
return PrivacyPolicyPageState()
..privacyPolicy = privacyPolicy;
}
}
PrivacyPolicyPageState initState(Map<String, dynamic> args) {
return PrivacyPolicyPageState()
..privacyPolicy = """
Sabin Bajracharya built the Todo app as a Free app. This SERVICE is provided by Sabin Bajracharya at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Todo unless otherwise defined in this Privacy Policy.
**Information Collection and Use**
For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retained on your device and is not collected by me in any way.
The app does use third party services that may collect information used to identify you.
Link to privacy policy of third party service providers used by the app
* [Firebase Analytics](https://firebase.google.com/policies/analytics)
**Log Data**
I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics.
**Cookies**
Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.
**Service Providers**
I may employ third-party companies and individuals due to the following reasons:
* To facilitate our Service;
* To provide the Service on our behalf;
* To perform Service-related services; or
* To assist us in analyzing how our Service is used.
I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
**Security**
I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security.
**Links to Other Sites**
This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.
**Children’s Privacy**
These Services do not address anyone under the age of 13\. I do not knowingly collect personally identifiable information from children under 13\. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions.
**Changes to This Privacy Policy**
I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page.
**Contact Us**
If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me at birqueens@gmail.com
""";
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/privacy_policy_page/view.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'state.dart';
Widget buildView(PrivacyPolicyPageState state, Dispatch dispatch, ViewService viewService) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
'Privacy Policy',
style: TextStyle(color: Colors.black)
),
elevation: 0.0,
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black12),
brightness: Brightness.light,
),
body: Markdown(data: state.privacyPolicy),
);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/pages
|
mirrored_repositories/Todo_Flutter/todo/lib/pages/privacy_policy_page/page.dart
|
import 'package:fish_redux/fish_redux.dart';
import 'state.dart';
import 'view.dart';
class PrivacyPolicyPage extends Page<PrivacyPolicyPageState, Map<String, dynamic>> {
PrivacyPolicyPage()
: super(
initState: initState,
view: buildView,
);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/task_list_model.dart
|
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:todo/db/db_provider.dart';
import 'package:todo/model/task_model.dart';
import 'package:todo/model/todo_model.dart';
class TodoListModel extends Model {
bool _isLoading = false;
List<Task> _tasks = [];
List<Todo> _todos = [];
Map<String, int> _taskCompletionPercentage = Map();
// var _db = DBProvider.db;
bool get isLoading => _isLoading;
List<Task> get tasks => _tasks.toList();
List<Todo> get todos => _todos.toList();
int getTaskCompletionPercent(Task task) => _taskCompletionPercentage[task.id];
int getTotalTodosFrom(Task task) => todos.where((t) => t.parent == task.id).length;
var _db = DBProvider.db;
static TodoListModel of(BuildContext context) =>
ScopedModel.of<TodoListModel>(context);
@override
void addListener(listener) {
super.addListener(listener);
_isLoading = true;
loadTodos();
notifyListeners();
}
@override
void removeListener(listener) {
super.removeListener(listener);
print("remove listener called");
}
void loadTodos() async {
var isNew = !await DBProvider.db.dbExits();
if (isNew) {
// init todo data
}
_tasks = await _db.getAllTask();
_todos = await _db.getAllTodo();
_tasks.forEach((t) => _calcTaskCompletionPercent(t.id));
_isLoading = false;
await Future.delayed(Duration(milliseconds: 300));
notifyListeners();
}
void addTask(Task task) {
_tasks.add(task);
_calcTaskCompletionPercent(task.id);
_db.insertTask(task);
notifyListeners();
}
void removeTask(Task task) {
_db.removeTask(task).then((_) {
_tasks.removeWhere((t) => t.id == task.id);
_todos.removeWhere((t) => t.parent == task.id);
notifyListeners();
});
}
void addTodo(Todo todo) {
_todos.add(todo);
_calcTaskCompletionPercent(todo.parent);
_db.insertTodo(todo);
notifyListeners();
}
void removeTodo(Todo todo) {
_todos.remove(todo);
_calcTaskCompletionPercent(todo.parent);
_db.removeTodo(todo);
notifyListeners();
}
void updateTodo(Todo todo) {
var oldTodo = _todos.firstWhere((t) => t.id == todo.id);
var replaceIndex = _todos.indexOf(oldTodo);
_todos.replaceRange(replaceIndex, replaceIndex + 1, [todo]);
_calcTaskCompletionPercent(todo.parent);
_db.updateTodo(todo);
notifyListeners();
}
void _calcTaskCompletionPercent(String taskId) {
var todos = this.todos.where((t) => t.parent == taskId);
var totalTodos = todos.length;
if (totalTodos == 0) {
_taskCompletionPercentage[taskId] = 0;
} else {
var totalCompletedTodos = todos.where((t) => t.isCompleted == 1).length;
_taskCompletionPercentage[taskId] = (totalCompletedTodos / totalTodos * 100).toInt();
}
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/todo_model.g.dart
|
part of 'todo_model.dart';
Todo _$TodoFromJson(Map<String, dynamic> json) {
return Todo(json['name'] as String,
parent: json['parent'] as String,
id: json['id'] as String,
isCompleted: json['completed'] as int,
);
}
Map<String, dynamic> _$TodoToJson(Todo instance) => <String, dynamic> {
'id': instance.id,
'parent': instance.parent,
'name': instance.name,
'completed': instance.isCompleted
};
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/hero_id_model.dart
|
import 'package:meta/meta.dart';
class HeroId {
final String nameId;
final String codePointId;
final String progressId;
final String remainingTaskId;
HeroId({
@required this.nameId,
@required this.codePointId,
@required this.progressId,
@required this.remainingTaskId
});
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/todo_model.dart
|
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:todo/utils/uuid.dart';
part 'todo_model.g.dart';
@JsonSerializable()
class Todo {
final String name;
final String id, parent;
@JsonKey(name: 'completed')
final int isCompleted;
Todo(this.name, {
@required this.parent,
this.isCompleted = 0,
String id
}): this.id = id ?? Uuid().generateV4();
Todo copy({String name, int isCompleted, int id, int parent}) {
return Todo(
name ?? this.name,
isCompleted: isCompleted ?? this.isCompleted,
id: id ?? this.id,
parent: parent ?? this.parent
);
}
factory Todo.fromJson(Map<String, dynamic> json) => _$TodoFromJson(json);
Map<String, dynamic> toJson() => _$TodoToJson(this);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/task_model.g.dart
|
part of 'task_model.dart';
Task _$TaskFromJson(Map<String, dynamic> json) {
return Task(json['name'] as String,
color: json['color'] as int,
codePoint: json['code_point'] as int,
id: json['id'] as String);
}
Map<String, dynamic> _$TaskToJson(Task instance) => <String, dynamic> {
'id': instance.id,
'name': instance.name,
'color': instance.color,
'code_point': instance.codePoint
};
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/model/task_model.dart
|
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:todo/utils/uuid.dart';
part 'task_model.g.dart';
@JsonSerializable()
class Task {
String id;
String name;
int color;
@JsonKey(name: 'code_point')
int codePoint;
Task(
this.name, {
@required this.color,
@required this.codePoint,
String id,
}) : this.id = id ?? Uuid().generateV4();
factory Task.fromJson(Map<String, dynamic> json) => _$TaskFromJson(json);
Map<String, dynamic> toJson() => _$TaskToJson(this);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib/model
|
mirrored_repositories/Todo_Flutter/todo/lib/model/data/choice_card.dart
|
import 'package:flutter/material.dart';
class Choice {
final String title;
final IconData icon;
const Choice({this.title, this.icon});
}
const List<Choice> choices = const <Choice>[
const Choice(title: 'Privacy Policy', icon: Icons.vpn_key),
];
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/route/scale_route.dart
|
import 'package:flutter/material.dart';
class ScaleRoute extends PageRouteBuilder {
final Widget widget;
final RelativeRect rect;
ScaleRoute({@required this.widget, @required this.rect}):
super(pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) { return widget; },
transitionsBuilder:(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return Stack(
children: <Widget>[
PositionedTransition(
child: child,
rect: RelativeRectTween(
begin: rect,
end: RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0),
).animate(animation),
),
],
);
},
transitionDuration: Duration(milliseconds: 300),
);
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/utils/color_utils.dart
|
import 'package:flutter/material.dart';
class ColorUtils{
static List<Color> defaultColors = [
Colors.blueGrey,
Colors.red,
Colors.pink,
Colors.purple,
Colors.deepPurple,
Colors.indigo,
Colors.blue,
Colors.lightBlue,
Colors.cyan,
Colors.teal,
Colors.green,
Colors.lightGreen,
Colors.lime,
Colors.yellow,
Colors.amber,
Colors.orange,
Colors.deepOrange,
Colors.brown,
Colors.grey,
];
static Map<int, Color> _colors = Map();
static Map<int, Color> get colors {
if (_colors.isNotEmpty) {
return _colors;
}
defaultColors.forEach((color) {
_colors[color.value] = color;
});
return _colors;
}
static Color getColorFrom(id) {
return colors.containsKey(id) ? colors[id] : defaultColors[0];
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/utils/uuid.dart
|
// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved.
// Use of this source code is governed by the MIT license that can be found
// in the LICENSE file.
import 'dart:math';
/// A UUID generator, useful for generating unique IDs for your Todos.
/// Shamelessly extracted from the Flutter source code.
///
/// This will generate unique IDs in the format:
///
/// f47ac10b-58cc-4372-a567-0e02b2c3d479
///
/// ### Example
///
/// final String id = Uuid().generateV4();
class Uuid {
final Random _random = Random();
/// Generate a version 4 (random) uuid. This is a uuid scheme that only uses
/// random numbers as the source of the generated uuid.
String generateV4() {
// Generate xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx / 8-4-4-4-12.
final int special = 8 + _random.nextInt(4);
return '${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}-'
'${_bitsDigits(16, 4)}-'
'4${_bitsDigits(12, 3)}-'
'${_printDigits(special, 1)}${_bitsDigits(12, 3)}-'
'${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}';
}
String _bitsDigits(int bitCount, int digitCount) =>
_printDigits(_generateBits(bitCount), digitCount);
int _generateBits(int bitCount) => _random.nextInt(1 << bitCount);
String _printDigits(int value, int count) =>
value.toRadixString(16).padLeft(count, '0');
}
| 0
|
mirrored_repositories/Todo_Flutter/todo/lib
|
mirrored_repositories/Todo_Flutter/todo/lib/utils/datetime_utils.dart
|
import 'package:intl/intl.dart';
class DateTimeUtils {
static String get currentDay {
DateTime now = DateTime.now();
return DateFormat('EEEE').format(now);
}
static String get currentMonth {
DateTime now = DateTime.now();
return DateFormat('MMM').format(now);
}
static String get currentDate {
DateTime now = DateTime.now();
return DateFormat('d').format(now);
}
}
| 0
|
mirrored_repositories/Todo_Flutter/todo
|
mirrored_repositories/Todo_Flutter/todo/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:todo/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/memperio
|
mirrored_repositories/memperio/lib/home_page.dart
|
import 'package:firebase_auth/firebase_auth.dart'
hide EmailAuthProvider, PhoneAuthProvider;
import 'package:flutter/material.dart';
import 'package:memperio/src/learn/learn_category.dart';
import 'package:memperio/src/widgets.dart';
import 'package:provider/provider.dart';
import 'app_state.dart';
import 'package:memperio/app_state.dart' as app_state;
import 'src/authentication.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<LearnCategory> categories = app_state.categories;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('MemPerio'),
),
body: ListView(
children: [
Consumer<ApplicationState>(
builder: (context, appState, _) => AuthFunc(
loggedIn: appState.loggedIn,
signOut: () {
FirebaseAuth.instance.signOut();
}),
),
Consumer<ApplicationState>(
builder: (context, appState, _) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (appState.loggedIn) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
const StyledContainer(
title: '리포트',
titleIcon: Icons.workspace_premium_rounded,
subButtonEnable: true,
route: '/report',
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
StyledCircularPercentIndicator(
text: '진행도',
percent: 0.8,
),
SizedBox(
width: 40,
),
StyledCircularPercentIndicator(
text: '목표',
percent: 0.7,
)
],
),
),
StyledContainer(
title: '학습',
titleIcon: Icons.edit_document,
subButtonEnable: true,
route: '/learn',
content: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
for (int i = 0; i < categories.length; i++) ...[
LearnCategoryButton(
name: categories[i].name,
tag: categories[i].tag,
icon: Icons.abc,
id: i,
)
],
],
),
),
),
],
),
),
] else ...[
const Text('로그인이 필요합니다.')
],
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/memperio
|
mirrored_repositories/memperio/lib/app_state.dart
|
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart'
hide EmailAuthProvider, PhoneAuthProvider;
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:flutter/material.dart';
import 'package:memperio/src/learn/learn_category.dart';
List<LearnCategory> categories = [];
class ApplicationState extends ChangeNotifier {
ApplicationState() {
init();
}
bool _loggedIn = false;
bool get loggedIn => _loggedIn;
var db = FirebaseFirestore.instance;
Future<void> init() async {
FirebaseUIAuth.configureProviders([
EmailAuthProvider(),
]);
FirebaseAuth.instance.userChanges().listen((user) {
if (user != null) {
_loggedIn = true;
db.collection("learn").get().then(
(querySnapshot) {
for (var docSnapshot in querySnapshot.docs) {
categories.add(LearnCategory(
name: docSnapshot.data()['name'],
tag: docSnapshot.data()['tag'],
));
}
},
);
notifyListeners();
} else {
_loggedIn = false;
}
notifyListeners();
});
}
}
| 0
|
mirrored_repositories/memperio
|
mirrored_repositories/memperio/lib/firebase_options.dart
|
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyC_0LSYNtuTFrcwPN0zpPphgauopoZ97Fk',
appId: '1:1063798082411:web:c7324b490701cc2352da2e',
messagingSenderId: '1063798082411',
projectId: 'memperio-52d1f',
authDomain: 'memperio-52d1f.firebaseapp.com',
storageBucket: 'memperio-52d1f.appspot.com',
measurementId: 'G-G0STVM3JVZ',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyA0YDGN277vB-jEgitx0cS4uKc4hJ-oQ1I',
appId: '1:1063798082411:android:0f0e077f8530939352da2e',
messagingSenderId: '1063798082411',
projectId: 'memperio-52d1f',
storageBucket: 'memperio-52d1f.appspot.com',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyD13xg2W7A-PUwVfsr1vlJzytr3o8DMF4E',
appId: '1:1063798082411:ios:900b09fee6447d2052da2e',
messagingSenderId: '1063798082411',
projectId: 'memperio-52d1f',
storageBucket: 'memperio-52d1f.appspot.com',
iosBundleId: 'com.example.memperio',
);
static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyD13xg2W7A-PUwVfsr1vlJzytr3o8DMF4E',
appId: '1:1063798082411:ios:0dbb60f9463528ea52da2e',
messagingSenderId: '1063798082411',
projectId: 'memperio-52d1f',
storageBucket: 'memperio-52d1f.appspot.com',
iosBundleId: 'com.example.memperio.RunnerTests',
);
}
| 0
|
mirrored_repositories/memperio
|
mirrored_repositories/memperio/lib/main.dart
|
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:memperio/src/learn/learn_menu.dart';
import 'package:memperio/src/learn/learn_menu_sub.dart';
import 'package:memperio/src/learn/learn_page.dart';
import 'package:memperio/src/report.dart';
import 'package:provider/provider.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
import 'app_state.dart';
import 'home_page.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(ChangeNotifierProvider(
create: (context) => ApplicationState(),
builder: ((context, child) => const App()),
));
}
final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => const HomePage(),
routes: [
GoRoute(
path: 'sign-in',
builder: (context, state) {
return SignInScreen(
actions: [
ForgotPasswordAction(((context, email) {
final uri = Uri(
path: '/sign-in/forgot-password',
queryParameters: <String, String?>{
'email': email,
},
);
context.push(uri.toString());
})),
AuthStateChangeAction(((context, state) {
final user = switch (state) {
SignedIn state => state.user,
UserCreated state => state.credential.user,
_ => null
};
if (user == null) {
return;
}
if (state is UserCreated) {
user.updateDisplayName(user.email!.split('@')[0]);
FirebaseFirestore.instance
.collection('users')
.doc(user.uid)
.set({
'userId': user.uid,
'timeSpent': 0,
});
}
if (!user.emailVerified) {
user.sendEmailVerification();
const snackBar = SnackBar(content: Text('이메일 인증을 진행해주세요.'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
context.go('/');
})),
],
);
},
routes: [
GoRoute(
path: 'forgot-password',
builder: (context, state) {
final arguments = state.uri.queryParameters;
return ForgotPasswordScreen(
email: arguments['email'],
headerMaxExtent: 200,
);
},
),
],
),
GoRoute(
path: 'profile',
builder: (context, state) {
return ProfileScreen(
providers: const [],
actions: [
SignedOutAction((context) {
context.pushReplacement('/');
}),
],
);
},
),
GoRoute(
path: 'learn',
builder: (context, state) {
return const LearnMenu();
},
routes: [
GoRoute(
path: 'sub/:id/:name/:tag',
name: 'sub',
builder: (context, state) {
return LearnMenuSub(
id: state.pathParameters['id'],
name: state.pathParameters['name'],
tag: state.pathParameters['tag'],
);
}),
GoRoute(
path: 'page/:name/:tag/:id/:howMuch/:startedAt',
name: 'learn-page',
builder: (context, state) {
return LearnPage(
name: state.pathParameters['name'],
id: state.pathParameters['id'],
tag: state.pathParameters['tag'],
howMuch: state.pathParameters['howMuch'],
startedAt: state.pathParameters['startedAt'],
);
}),
],
),
GoRoute(
path: 'report',
builder: (context, state) {
return const ReportPage();
})
],
),
],
);
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'MemPerio',
theme: ThemeData(
textTheme: GoogleFonts.robotoTextTheme(
Theme.of(context).textTheme,
),
visualDensity: VisualDensity.adaptivePlatformDensity,
useMaterial3: true,
),
routerConfig: _router,
);
}
}
| 0
|
mirrored_repositories/memperio/lib
|
mirrored_repositories/memperio/lib/src/report.dart
|
import 'package:flutter/material.dart';
class ReportPage extends StatelessWidget {
const ReportPage({super.key});
String _welcome() {
var timeNow = DateTime.now().hour;
if (timeNow <= 11) {
return '좋은 아침입니다';
} else if (timeNow <= 17) {
return '';
} else {
return '';
}
}
@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
}
| 0
|
mirrored_repositories/memperio/lib
|
mirrored_repositories/memperio/lib/src/authentication.dart
|
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
import 'widgets.dart';
class AuthFunc extends StatefulWidget {
const AuthFunc({
super.key,
required this.loggedIn,
required this.signOut,
});
final bool loggedIn;
final void Function() signOut;
@override
State<AuthFunc> createState() => _AuthFuncState();
}
class _AuthFuncState extends State<AuthFunc> {
String userDisplayName = '';
String _getUserDisplayName() {
final user = FirebaseAuth.instance.currentUser;
if (user != null) {
return user.displayName!;
} else {
return '';
}
}
@override
void initState() {
super.initState();
userDisplayName = _getUserDisplayName();
}
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 2,
child: Visibility(
visible: widget.loggedIn,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
child: UserAvatar(
auth: FirebaseAuth.instance,
),
),
),
),
Expanded(
flex: 3,
child: Visibility(
visible: widget.loggedIn,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
userDisplayName,
style: const TextStyle(fontSize: 18),
),
const SizedBox(height: 12),
const DDayViewer(),
],
),
),
),
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 20),
child: StyledButton(
onPressed: () {
!widget.loggedIn
? context.push('/sign-in')
: widget.signOut();
},
child:
!widget.loggedIn ? const Text('로그인') : const Text('로그아웃'),
),
),
Visibility(
visible: widget.loggedIn,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 20),
child: StyledButton(
onPressed: () {
context.push('/profile');
},
child: const Text('프로필'),
),
),
)
],
),
),
],
);
}
}
class DDayViewer extends StatefulWidget {
const DDayViewer({super.key});
@override
State<DDayViewer> createState() => _DDayViewer();
}
class _DDayViewer extends State<DDayViewer> {
bool dateSelected = false;
DateTime selectedDate = DateTime.now();
DateTime dueDate = DateTime.now().add(const Duration(days: 1));
int differenceFromToday = 1;
int differenceFromSelectedDate = 1;
int differenceCalcFromToday() {
return dueDate.difference(DateTime.now()).inDays + 1;
}
int differenceCalcFromSelectedDate() {
return dueDate.difference(selectedDate).inDays + 1;
}
@override
Widget build(BuildContext context) => Column(
children: [
if (dateSelected) ...[
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('중간고사까지'),
Text('D-$differenceFromToday'),
],
),
LinearPercentIndicator(
barRadius: const Radius.circular(25),
padding: EdgeInsets.zero,
percent: 1 - differenceFromToday / differenceFromSelectedDate,
lineHeight: 10,
backgroundColor: Colors.black38,
progressColor: Colors.indigo.shade900,
),
],
),
] else ...[
StyledButton(
onPressed: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now().add(const Duration(days: 1)),
firstDate: DateTime.now().add(const Duration(days: 1)),
lastDate: DateTime(9999),
);
if (pickedDate == null) return;
setState(
() {
selectedDate = DateTime.now();
dueDate = pickedDate;
dateSelected = true;
differenceFromSelectedDate =
differenceCalcFromSelectedDate();
differenceFromToday = differenceCalcFromToday();
},
);
},
child: const Text('원하는 D-Day를 선택해주세요.'),
),
],
],
);
}
| 0
|
mirrored_repositories/memperio/lib
|
mirrored_repositories/memperio/lib/src/widgets.dart
|
import 'package:flutter/material.dart';
import 'package:percent_indicator/percent_indicator.dart';
import 'package:go_router/go_router.dart';
class Header extends StatelessWidget {
const Header(
this.heading, {
super.key,
this.textStyle = const TextStyle(fontSize: 24),
});
final String heading;
final TextStyle? textStyle;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
heading,
style: textStyle,
),
);
}
class Paragraph extends StatelessWidget {
const Paragraph(this.content, {super.key});
final String content;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Text(
content,
style: const TextStyle(fontSize: 18),
),
);
}
class IconAndDetail extends StatelessWidget {
const IconAndDetail(this.icon, this.detail, {super.key});
final IconData icon;
final String detail;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Icon(icon),
const SizedBox(width: 8),
Text(
detail,
style: const TextStyle(fontSize: 18),
)
],
),
);
}
class StyledButton extends StatelessWidget {
const StyledButton({required this.child, required this.onPressed, super.key});
final Widget child;
final void Function() onPressed;
@override
Widget build(BuildContext context) => OutlinedButton(
onPressed: onPressed,
child: child,
);
}
class StyledCircularPercentIndicator extends StatelessWidget {
const StyledCircularPercentIndicator(
{required this.text, required this.percent, super.key});
final String text;
final double percent;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: CircularPercentIndicator(
radius: 80,
lineWidth: 15,
progressColor: Colors.deepPurple,
percent: percent,
circularStrokeCap: CircularStrokeCap.round,
center: Text(
text,
style: const TextStyle(
color: Colors.deepPurple,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
);
}
}
class LearnCategoryButton extends StatefulWidget {
const LearnCategoryButton({
super.key,
required this.name,
required this.icon,
required this.tag,
required this.id,
});
final String name;
final List<dynamic> tag;
final IconData icon;
final int id;
@override
State<LearnCategoryButton> createState() => _LearnCategoryButtonState();
}
class _LearnCategoryButtonState extends State<LearnCategoryButton> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
onPressed: () {
context.pushNamed('sub', pathParameters: {
'id': widget.id.toString(),
'name': widget.name,
'tag': widget.tag.join(','),
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Icon(
widget.icon,
size: 48,
),
Text(widget.name),
],
),
),
),
);
}
}
class StyledContainer extends StatelessWidget {
const StyledContainer({
super.key,
required this.title,
required this.titleIcon,
required this.subButtonEnable,
required this.route,
required this.content,
});
final String title;
final IconData titleIcon;
final bool subButtonEnable;
final String route;
final Widget content;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Container(
decoration: BoxDecoration(
color: Colors.deepPurple.shade50,
borderRadius: BorderRadius.circular(25),
),
child: Padding(
padding: const EdgeInsets.all(30),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
titleIcon,
color: Colors.deepPurple,
size: 28,
),
const SizedBox(width: 8),
Text(
title,
style: const TextStyle(
color: Colors.deepPurple,
fontSize: 18,
),
),
],
),
if (subButtonEnable) ...[
StyledButton(
child: const Text('더보기'),
onPressed: () {
context.push(route);
},
)
]
],
),
const SizedBox(
height: 15,
),
content,
],
),
),
),
);
}
}
class TagContainer extends StatelessWidget {
const TagContainer({
super.key,
required this.tag,
});
final String tag;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
right: 8,
top: 8,
bottom: 8,
),
child: Container(
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(24),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
tag,
style: const TextStyle(
color: Colors.white,
),
),
),
),
);
}
}
class TagList extends StatelessWidget {
const TagList({
super.key,
required this.tagList,
});
final List tagList;
@override
Widget build(BuildContext context) {
return Row(
children: [
for (String tag in tagList) ...[TagContainer(tag: tag)]
],
);
}
}
class DurationViewer extends StatelessWidget {
const DurationViewer({
super.key,
required this.timeSpent,
});
final Duration timeSpent;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
const Icon(Icons.timer_rounded),
Text(timeSpent.toString()),
],
);
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/learn_menu_sub.dart
|
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:memperio/src/widgets.dart';
class LearnMenuSub extends StatefulWidget {
const LearnMenuSub({this.id, this.name, this.tag, super.key});
final String? id;
final String? name;
final String? tag;
@override
State<LearnMenuSub> createState() => _LearnMenuSubState();
}
class _LearnMenuSubState extends State<LearnMenuSub> {
var tagList = [];
var db = FirebaseFirestore.instance;
String howMuchProbs = '1';
int size = 1;
DateTime startedAt = DateTime.now();
@override
void initState() {
tagList = widget.tag!.split(',');
db.collection("learn/${widget.id}/q").get().then((querySnapshot) {
size = querySnapshot.size;
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: Text(widget.name!),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
TagList(tagList: tagList),
StyledContainer(
title: '원하는 문제 수를 입력해주세요.',
titleIcon: Icons.label_important_rounded,
subButtonEnable: false,
route: '',
content: Column(
children: [
Row(
children: [
Expanded(
child: TextField(
onChanged: (value) {
howMuchProbs = value;
},
decoration: InputDecoration(
labelText: '최소 1 ~ 최대 $size',
),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
LimitRange(1, size)
],
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
StyledButton(
child: const Text('시작하기'),
onPressed: () {
startedAt = DateTime.now();
context.pushNamed(
'learn-page',
pathParameters: {
'name': widget.name!,
'tag': widget.tag!,
'id': widget.id!,
'howMuch': howMuchProbs,
'startedAt': startedAt.toString(),
},
);
},
),
],
),
),
],
),
),
],
),
),
],
),
);
}
}
class LimitRange extends TextInputFormatter {
LimitRange(
this.minRange,
this.maxRange,
) : assert(
minRange <= maxRange,
);
final int minRange;
final int maxRange;
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue, TextEditingValue newValue) {
var value = int.parse(newValue.text);
if (value < minRange) {
return TextEditingValue(text: minRange.toString());
} else if (value > maxRange) {
return TextEditingValue(text: maxRange.toString());
}
return newValue;
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/learn_menu.dart
|
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:memperio/src/learn/learn_category.dart';
import 'package:toggle_switch/toggle_switch.dart';
import 'package:memperio/app_state.dart' as app_state;
class LearnMenu extends StatefulWidget {
const LearnMenu({super.key});
@override
State<LearnMenu> createState() => _LearnMenu();
}
class _LearnMenu extends State<LearnMenu> {
String searchText = '';
List<LearnCategory> categories = app_state.categories;
late Set<String> tagsAll = {};
int? selectedTagIndex;
String? selectedTag;
@override
void initState() {
// Get tags from categories and add them to tagsAll
for (int i = 0; i < categories.length; i++) {
for (int j = 0; j < categories[i].tag.length; j++) {
tagsAll.add(categories[i].tag[j]);
}
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: const Text('학습'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
TextField(
decoration: const InputDecoration(
prefixIcon: Icon(Icons.search_rounded),
),
onChanged: (value) {
setState(() {
searchText = value;
});
},
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: ToggleSwitch(
radiusStyle: true,
minWidth:
MediaQuery.of(context).size.width / tagsAll.length,
cornerRadius: 12.0,
inactiveBgColor: Colors.deepPurple.shade50,
inactiveFgColor: Colors.deepPurple,
activeBgColor: const [Colors.deepPurple],
initialLabelIndex: selectedTagIndex,
doubleTapDisable: true,
totalSwitches: tagsAll.length,
labels: tagsAll.toList(),
onToggle: (index) {
try {
selectedTagIndex = index!;
selectedTag = tagsAll.toList()[index];
} catch (e) {
selectedTagIndex = null;
selectedTag = null;
}
},
),
),
),
],
),
Expanded(
child: ListView.builder(
itemCount: categories.length,
itemBuilder: (BuildContext context, int index) {
// TODO: Filter categories w/ tags and input
if (searchText.isNotEmpty &&
!categories[index]
.name
.toLowerCase()
.contains(searchText.toLowerCase())) {
return const SizedBox.shrink();
} else {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
)),
onPressed: () {
context.pushNamed('sub', pathParameters: {
'id': index.toString(),
'name': categories[index].name,
'tag': categories[index].tag.join(','),
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
categories[index].name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
);
}
},
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/learn_category.dart
|
class LearnCategory {
LearnCategory({required this.name, required this.tag});
final String name;
final List<dynamic> tag;
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/results_screen.dart
|
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:memperio/src/learn/review_page.dart';
import 'package:memperio/src/widgets.dart';
class ResultsScreen extends StatefulWidget {
final String name;
final String tag;
final List<dynamic> data;
final DateTime startedAt;
final DateTime endedAt;
const ResultsScreen(
{super.key,
required this.data,
required this.name,
required this.tag,
required this.startedAt,
required this.endedAt});
@override
State<ResultsScreen> createState() => _ResultsScreenState();
}
class _ResultsScreenState extends State<ResultsScreen> {
final uid = FirebaseAuth.instance.currentUser!.uid;
var tagList = [];
Duration timeSpent = const Duration();
var correct = 0;
var wrong = [];
void _resultBuilder() {
for (var result in widget.data) {
if (result == true) {
correct++;
} else {
wrong.add(result);
}
}
}
void _postToDB({var timeSpent}) {
var db = FirebaseFirestore.instance;
db
.collection('users')
.doc(uid)
.update({'timeSpent': FieldValue.increment(timeSpent), 'userId': uid});
}
void _showReviewPage(BuildContext context, List<dynamic> wrong) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ReviewScreen(content: wrong, timeSpent: timeSpent),
),
);
}
@override
void initState() {
super.initState();
_resultBuilder();
timeSpent = widget.endedAt.difference(widget.startedAt);
_postToDB(timeSpent: timeSpent.inMilliseconds);
tagList = widget.tag.split(',');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('학습 종료'),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.name,
style: const TextStyle(fontSize: 28),
),
TagList(tagList: tagList),
],
),
DurationViewer(timeSpent: timeSpent),
],
),
StyledContainer(
title: '결과',
titleIcon: Icons.check_circle_outline_rounded,
subButtonEnable: false,
route: '',
content: Column(
children: [
StyledCircularPercentIndicator(
text: '$correct / ${widget.data.length}',
percent: correct / widget.data.length,
),
const Text(
'정답률',
style: TextStyle(
color: Colors.deepPurple,
fontSize: 20,
fontWeight: FontWeight.w600,
),
)
],
),
),
ElevatedButton(
child: const Text('틀린 문제 다시 보기'),
onPressed: () {
_showReviewPage(context, wrong);
},
),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/learn_page.dart
|
import 'dart:math';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:memperio/src/learn/questions.dart';
class LearnPage extends StatefulWidget {
const LearnPage(
{this.name, this.tag, this.id, this.howMuch, this.startedAt, super.key});
final String? name;
final String? tag;
final String? id;
final String? howMuch;
final String? startedAt;
@override
State<LearnPage> createState() => _LearnPageState();
}
class _LearnPageState extends State<LearnPage> {
var db = FirebaseFirestore.instance;
int howMuch = 1;
int random = Random().nextInt(4294967295);
bool submitted = false;
Future<List<Question>> getProblemsFromDB() async {
List<Question> probList = [];
void addToProbList(
List<QueryDocumentSnapshot<Map<String, dynamic>>> querySnapshotDocs) {
for (var docSnapshot in querySnapshotDocs) {
var data = docSnapshot.data();
probList.add(Question(
content: data['content'],
answer: data['answer'],
from: data['from'],
year: data['year'],
));
}
}
await db
.collection("learn/${widget.id}/q")
.where("random", isGreaterThanOrEqualTo: random)
.orderBy("random")
.limit(howMuch)
.get()
.then((querySnapshot) {
addToProbList(querySnapshot.docs);
}).catchError((err) {});
if (probList.isEmpty) {
await db
.collection("learn/${widget.id}/q")
.where("random", isLessThanOrEqualTo: random)
.orderBy("random", descending: true)
.limit(howMuch)
.get()
.then((querySnapshot) {
addToProbList(querySnapshot.docs);
}).catchError((err) {});
}
return probList;
}
@override
void initState() {
howMuch = int.parse(widget.howMuch!);
super.initState();
}
@override
Widget build(BuildContext context) {
Future<List<Question>> problems = getProblemsFromDB();
return Scaffold(
appBar: AppBar(
title: Text(widget.name!),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Column(
children: [
FutureBuilder(
future: problems,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const CircularProgressIndicator();
}
return Column(
children: [
Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
children: [
QuestionContainer(
name: widget.name!,
tag: widget.tag!,
data: snapshot.data!,
currentIndex: 0,
progress: 0,
startedAt: widget.startedAt!,
),
],
),
),
], // EndFor
);
},
),
],
),
);
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/review_page.dart
|
import 'package:flutter/material.dart';
import 'package:memperio/src/widgets.dart';
class ReviewScreen extends StatelessWidget {
final List<dynamic> content;
final Duration timeSpent;
const ReviewScreen(
{super.key, required this.content, required this.timeSpent});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('틀린 문제 다시 보기'),
),
body: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [DurationViewer(timeSpent: timeSpent)],
),
Expanded(
child: ListView.builder(
itemCount: content.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [Text(content[index].content)],
),
);
},
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/memperio/lib/src
|
mirrored_repositories/memperio/lib/src/learn/questions.dart
|
import 'package:flutter/material.dart';
import 'package:memperio/src/learn/results_screen.dart';
import 'package:memperio/src/widgets.dart';
class Question {
String content;
String answer;
String from;
String year;
Question({
this.content = 'temp',
this.answer = 'temp',
this.from = 'temp',
this.year = 'temp',
});
}
class QuestionContainer extends StatefulWidget {
const QuestionContainer({
super.key,
required this.name,
required this.tag,
required this.data,
required this.currentIndex,
required this.progress,
required this.startedAt,
});
final String name;
final String tag;
final List<Question> data;
final int currentIndex;
final int progress;
final String startedAt;
@override
State<QuestionContainer> createState() => _QuestionContainerState();
}
class _QuestionContainerState extends State<QuestionContainer> {
late List<String> inputValues;
DateTime startedAt = DateTime.now();
@override
void initState() {
super.initState();
inputValues = List.filled(widget.data.length, '');
}
void _showResultsScreen({
required BuildContext context,
required String name,
required String tag,
required String startedAt,
required DateTime endedAt,
}) {
var answers = [];
for (var data in widget.data) {
answers.add(data.answer);
}
// Get list of answers to compare to user inputs
List<dynamic> result = List.filled(widget.data.length, '');
for (var i = 0; i < widget.data.length; i++) {
if (answers[i] == inputValues[i]) {
result[i] = true;
} else {
result[i] = widget.data[i];
}
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ResultsScreen(
data: result,
name: name,
tag: tag,
startedAt: DateTime.parse(startedAt),
endedAt: endedAt),
),
);
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
children: [
const Text('진행도'),
const SizedBox(width: 12),
Expanded(
child: LinearProgressIndicator(
value: widget.progress / widget.data.length,
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(24),
),
),
],
),
const SizedBox(height: 30),
Container(
decoration: BoxDecoration(
color: Colors.deepPurple.shade50,
borderRadius: BorderRadius.circular(25),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
Header(
widget.data[widget.currentIndex].content,
textStyle: const TextStyle(
fontSize: 24,
color: Colors.deepPurple,
),
),
TextField(
onChanged: (value) {
inputValues[widget.currentIndex] = value;
},
textInputAction: TextInputAction.go,
onSubmitted: (value) async {
if (widget.currentIndex < widget.data.length - 1) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => QuestionContainer(
name: widget.name,
tag: widget.tag,
data: widget.data,
currentIndex: widget.currentIndex + 1,
progress: widget.progress + 1,
startedAt: widget.startedAt,
),
),
);
} else {
_showResultsScreen(
context: context,
name: widget.name,
tag: widget.tag,
startedAt: widget.startedAt,
endedAt: DateTime.now());
}
},
),
],
),
),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TagContainer(tag: "출제: ${widget.data[widget.currentIndex].from}"),
TagContainer(tag: "년도: ${widget.data[widget.currentIndex].year}"),
],
),
],
);
}
}
| 0
|
mirrored_repositories/memperio
|
mirrored_repositories/memperio/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:memperio/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const App());
// 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/motorotam
|
mirrored_repositories/motorotam/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'screens/main_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: (context, widget) => ResponsiveWrapper.builder(
ClampingScrollWrapper.builder(context, widget!),
breakpoints: const [
ResponsiveBreakpoint.resize(350, name: MOBILE),
ResponsiveBreakpoint.autoScale(600, name: TABLET),
ResponsiveBreakpoint.resize(800, name: DESKTOP),
ResponsiveBreakpoint.autoScale(1700, name: 'XL'),
ResponsiveBreakpoint.autoScale(2460, name: "4K"),
],
),
title: 'MotoRotam',
home: const MainPage(),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/properties_motor_card.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class PropertiesMotorCard extends StatelessWidget {
String motorHacim;
String motorPower;
String motorHiz;
String motorFren;
String motorTork;
PropertiesMotorCard({
Key? key,
required this.motorHacim,
required this.motorPower,
required this.motorHiz,
required this.motorFren,
required this.motorTork,
}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return SizedBox(
width: screenWidth,
height: 120,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 1,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
if (kDebugMode) {
print("tıklandı");
}
},
child: Padding(
padding: const EdgeInsets.only(
top: 0.0, left: 5, right: 5, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 8),
child: Container(
width: 90,
height: 120,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.black,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Image.asset("assets/images/icons_card/engine.png"),
),
const Center(
child: Text(
'Engine',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 16,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
Center(
child: Text(
motorHacim,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 8),
child: Container(
width: 90,
height: 120,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.black,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Image.asset("assets/images/icons_card/Muscle.png"),
),
const Center(
child: Text(
'Power',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 16,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
Center(
child: Text(
motorPower,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 8),
child: Container(
width: 90,
height: 120,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.black,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Image.asset("assets/images/icons_card/Speedometer.png"),
),
const Center(
child: Text(
'Speed',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 16,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
Center(
child: Text(
motorHiz + ' km/h',
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 8),
child: Container(
width: 90,
height: 120,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.black,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Image.asset("assets/images/icons_card/Brake Discs.png"),
),
const Center(
child: Text(
'Brake',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 16,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
const Center(
child: Text(
'ABS/Disk',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 0),
child: Container(
width: 90,
height: 120,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.black,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Image.asset("assets/images/icons_card/engine.png"),
),
const Center(
child: Text(
'Tork',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 16,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
Center(
child: Text(
motorTork,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Inter',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
],
),
),
),
],
),
),
);
},
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/appbar_widget.dart
|
import 'package:flutter/material.dart';
import 'package:motorotam/screens/main_page.dart';
class AppBarWidgets extends StatelessWidget implements PreferredSizeWidget {
late String baslik;
AppBarWidgets({Key? key, required this.baslik}) : super(key: key);
@override
Size get preferredSize => const Size.fromHeight(60);
@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: const Color.fromRGBO(29, 31, 32, 1),
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openDrawer();
},
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
);
},
),
title: Text(baslik),
actions: [
IconButton(
icon: const Icon(Icons.home_filled),
tooltip: 'Favoriler',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MainPage()),
);
}
),
IconButton(
icon: const Icon(Icons.settings),
tooltip: 'Ayarlar',
onPressed: () {},
),
],
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/motor_detail_widget.dart
|
import 'package:flutter/material.dart';
import 'package:motorotam/model/models.dart';
class MotorDetailWidget extends StatelessWidget {
String motorResim;
String motorResimLeft;
String motorResimRight;
MotorDetailWidget({Key? key,
required this.motorResim,
required this.motorResimLeft,
required this.motorResimRight}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: Stack(
//clipBehavior: Clip.none, fit: StackFit.expand,
clipBehavior: Clip.antiAliasWithSaveLayer,
children: <Widget>[
Image.asset(motorResim),//Container
Positioned(
top: 20,
right: 10,
child: SizedBox(
child: Image.asset(motorResimLeft),
width: 70,
),
),
Positioned(
top: 65,
right: 10,
child: SizedBox(
child: Image.asset(motorResimRight),
width: 70,
),
), //Container
], //<Widget>[]
),
);
}
}
/*
Image.asset("assets/images/390_Duke.jpg")),
Image.asset("assets/images/390_Duke.jpg", width: 50,),
Image.asset("assets/images/390_Duke.jpg", width: 50,),
*/
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/lib_color_schemes.g.dart
|
import 'package:flutter/material.dart';
const seed = Color(0xFF6750A4);
const lightColorScheme = ColorScheme(
brightness: Brightness.light,
primary : Color(0xFF6750A4),
onPrimary : Color(0xFFFFFFFF),
primaryContainer : Color(0xFFEADDFF),
onPrimaryContainer : Color(0xFF21005D),
secondary : Color(0xFF625B71),
onSecondary : Color(0xFFFFFFFF),
secondaryContainer : Color(0xFFE8DEF8),
onSecondaryContainer : Color(0xFF1D192B),
tertiary : Color(0xFF7D5260),
onTertiary : Color(0xFFFFFFFF),
tertiaryContainer : Color(0xFFFFD8E4),
onTertiaryContainer : Color(0xFF31111D),
error : Color(0xFFB3261E),
errorContainer : Color(0xFFF9DEDC),
onError : Color(0xFFFFFFFF),
onErrorContainer : Color(0xFF410E0B),
background : Color(0xFFFFFBFE),
onBackground : Color(0xFF1C1B1F),
surface : Color(0xFFFFFBFE),
onSurface : Color(0xFF1C1B1F),
surfaceVariant : Color(0xFFE7E0EC),
onSurfaceVariant : Color(0xFF49454F),
outline : Color(0xFF79747E),
onInverseSurface : Color(0xFFF4EFF4),
inverseSurface : Color(0xFF313033),
inversePrimary : Color(0xFFD0BCFF),
shadow : Color(0xFF000000),
);
const darkColorScheme = ColorScheme(
brightness: Brightness.dark,
primary : Color(0xFFD0BCFF),
onPrimary : Color(0xFF381E72),
primaryContainer : Color(0xFF4F378B),
onPrimaryContainer : Color(0xFFEADDFF),
secondary : Color(0xFFCCC2DC),
onSecondary : Color(0xFF332D41),
secondaryContainer : Color(0xFF4A4458),
onSecondaryContainer : Color(0xFFE8DEF8),
tertiary : Color(0xFFEFB8C8),
onTertiary : Color(0xFF492532),
tertiaryContainer : Color(0xFF633B48),
onTertiaryContainer : Color(0xFFFFD8E4),
error : Color(0xFFF2B8B5),
errorContainer : Color(0xFF8C1D18),
onError : Color(0xFF601410),
onErrorContainer : Color(0xFFF9DEDC),
background : Color(0xFF1C1B1F),
onBackground : Color(0xFFE6E1E5),
surface : Color(0xFF1C1B1F),
onSurface : Color(0xFFE6E1E5),
surfaceVariant : Color(0xFF49454F),
onSurfaceVariant : Color(0xFFCAC4D0),
outline : Color(0xFF938F99),
onInverseSurface : Color(0xFF1C1B1F),
inverseSurface : Color(0xFFE6E1E5),
inversePrimary : Color(0xFF6750A4),
shadow : Color(0xFF000000),
);
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/category_bar.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:motorotam/screens/modeller_page.dart';
class CategoryBar extends StatelessWidget {
const CategoryBar({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return SizedBox(
width: screenWidth,
height: 50,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 1,
itemBuilder: (context, index) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
top: 0.0, left: 12, right: 5, bottom: 0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ModellerPageWidget(),
),
);
},
child: Container(
width: 90,
height: 40,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(0),
topRight: Radius.circular(0),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(0),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Racing',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Enduro',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Naked',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Scooter',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Cros',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Touring',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Cruisers',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Electric',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'Scrambler',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
Container(
height: 30,
width: 3,
color: Colors.black,
),
Container(
width: 90,
height: 40,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(0),
topRight: Radius.circular(0),
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(20),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.9),
spreadRadius: 1,
blurRadius: 2,
offset: const Offset(0.1, 4),
),
],
color: Colors.white,
),
child: const Center(
child: RotatedBox(
quarterTurns: 4,
child: Text(
'All ...',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
],
),
],
),
),
],
);
},
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/motor_card.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:responsive_framework/responsive_framework.dart';
class MotorCard extends StatelessWidget {
final String resim;
final String baslik;
final String yil;
final String fiyat;
final double yildiz;
const MotorCard({
Key? key, required this.resim, required this.baslik, required this.fiyat, required this.yildiz, required this.yil,
}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return Padding(
padding: const EdgeInsets.all(4.0),
child: SizedBox(
width: screenWidth,
child: Card(
borderOnForeground: true,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
side: const BorderSide(
color: Color.fromRGBO(29, 31, 32, 1),
width: 6.0,
),
borderRadius: BorderRadius.circular(20.0),
),
color: const Color.fromRGBO(29, 31, 32, 1),
clipBehavior: Clip.antiAlias,
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset(
resim
),
ListTile(
title: Text(
baslik,
style: TextStyle(
fontSize: ResponsiveValue(
context,
defaultValue: 18.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 24.0,
),
Condition.largerThan(
name: TABLET,
value: 26.0,
)
],
).value,
color: Colors.white),
),
subtitle: Text(
yil,
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontSize: ResponsiveValue(
context,
defaultValue: 16.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 18.0,
),
Condition.largerThan(
name: TABLET,
value: 20.0,
)
],
).value,),
),
),
ListTile(
leading: RatingBar.builder(
initialRating: yildiz,
minRating: 1,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 18.0,
itemPadding: const EdgeInsets.symmetric(horizontal: 0.1),
itemBuilder: (context, _) => const Icon(
Icons.star,
color: Colors.amber,
),
onRatingUpdate: (rating) {
if (kDebugMode) {
print(rating);
}
},
),
trailing: Text(
'$fiyat ₺',
style: TextStyle(
color: Colors.white.withOpacity(0.6), fontSize: ResponsiveValue(
context,
defaultValue: 14.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 16.0,
),
Condition.largerThan(
name: TABLET,
value: 20.0,
)
],
).value,),
),
),
],
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/top_brands.dart
|
import 'package:flutter/material.dart';
class TopBrands extends StatelessWidget {
const TopBrands({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(
top: 10.0, left: 20, right: 20, bottom: 0),
child: Container(
decoration: const BoxDecoration(
color: Color.fromRGBO(238, 237, 233, 1),
),
child: const Text(
'Top Brands',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 18,
letterSpacing: 0,
fontWeight: FontWeight.bold,
height: 1),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10, right: 20),
child: Container(
width: 58,
height: 22,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
color: Color.fromRGBO(29, 31, 32, 1),
),
child: const Center(
child: Text(
'view all',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(255, 255, 255, 1),
fontFamily: 'Inter',
fontSize: 12,
letterSpacing:
0 /*percentages not used in flutter. defaulting to zero*/,
fontWeight: FontWeight.normal,
height: 1),
),
),
),
),
],
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/components/yatay_list.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class YatayListMarka extends StatelessWidget {
const YatayListMarka({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return SizedBox(
width: screenWidth,
height: 100,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 8,
itemBuilder: (context, index) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
if (kDebugMode) {
print("tıklandı");
}
},
child: Padding(
padding: const EdgeInsets.only(
top: 0.0, left: 5, right: 0, bottom: 0),
child: Container(
width: 60,
height: 80,
decoration: const BoxDecoration(),
child: Stack(
children: <Widget>[
const Positioned(
top: 65,
left: 0,
child: Text(
'Yamaha',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 16,
fontWeight: FontWeight.normal,
height: 1,
),
),
),
Positioned(
top: 0,
left: 0,
child: Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/yamaha.png'),
fit: BoxFit.fitWidth),
),
),
),
],
),
),
),
),
],
);
},
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/confing/constants.dart
|
import 'package:flutter/material.dart';
const kLightTextColor = Color(0xffB5C8E7);
const kHardTextColor = Color(0xff586191);
//const kPrimaryDarkColor = Color(0xff46BDFA);
const kPrimaryDarkColor = Color(0xffFFCA8C);
const kPrimaryLightColor = Color(0xff77E2FE);
const kBackgroundColor = Color(0xffEFF2F7);
const List<Color> kCategoriesPrimaryColor = [
Color(0xffFFCA8C),
Color(0xff5DF9D3),
Color(0xff5DF9D3),
Color(0xffB8ACFF),
Color(0xffB8ACFF),
Color(0xffB8ACFF),
];
const List<Color> kCategoriesSecondryColor = [
Color(0xffFEA741),
Color(0xff45BAFB),
Color(0xffFFCA8C),
Color(0xff9182F9),
Color(0xff31DFB5),
Color(0xff586191),
];
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/confing/size_config.dart
|
import 'package:flutter/material.dart';
class SizeConfig {
static double screenWidth = 411.0;
static double screenHeight = 200.0;
static initSize(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
screenWidth = mediaQuery.size.width;
screenHeight = mediaQuery.size.height;
}
}
double getRelativeHeight(double percentage) {
return percentage * SizeConfig.screenHeight;
}
double getRelativeWidth(double percentage) {
return percentage * SizeConfig.screenWidth;
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/model/json_cozumle.dart
|
import 'dart:convert';
import 'package:flutter/services.dart';
jsonCozumle() async{
try {
String jsonString = await rootBundle.loadString('assets/jsons/markalar_modeller.json');
Map<String, dynamic> motorlarMap = json.decode(jsonString);
for(String markaId in motorlarMap.keys){
Map<String, dynamic> markaMap = motorlarMap[markaId];
String markaAdi = markaMap["Ktm"];
Map<String, dynamic> modellerMap = markaMap['Duke250'];
// List<Model> tumModeller = [];
for(String modelAdi in modellerMap.keys){
// Map<Model, dynamic> modelMap = modellerMap[modelAdi];
// String model = Model(modelMap['marka']);
// tumModeller.add(model);
}
}
} catch (e){
print('Bir hata oluştu !!! : ${e.toString()}');
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/model/models.dart
|
class Motor {
List<String> marka;
String model;
String yil;
String fiyat;
double yildiz;
String resim;
String resimRight;
String resimLeft;
String motorTipi;
String motorHacmi;
String motorTork;
String motorPower;
String motorHiz;
String sanziman;
String debriyaj;
String sogutma;
String atesleme;
String sasiTipi;
String onAmortisor;
String arkaAmortisor;
String onFren;
String arkaFren;
String frenDiskCap;
String zincir;
String onLastikCap;
String arkaLastikCap;
String yukseklik;
String agirlik;
String yakitDeposu;
String ortalamaYakit;
Motor({
required this.marka,
required this.resim,
required this.model,
required this.yil,
required this.fiyat,
required this.motorHiz,
required this.yildiz,
required this.motorTipi,
required this.motorHacmi,
required this.motorPower,
required this.sanziman,
required this.debriyaj,
required this.sogutma,
required this.atesleme,
required this.sasiTipi,
required this.onAmortisor,
required this.arkaAmortisor,
required this.onFren,
required this.arkaFren,
required this.frenDiskCap,
required this.zincir,
required this.onLastikCap,
required this.arkaLastikCap,
required this.yukseklik,
required this.agirlik,
required this.yakitDeposu,
required this.ortalamaYakit,
required this.motorTork,
required this.resimRight,
required this.resimLeft,
});
}
class Marka {
List<String> isim;
Marka({required this.isim});
}
Marka markalar = Marka(isim: ["KTM", "Honda", "Kawasaki"]);
Motor ktm250 = Motor(
marka: markalar.isim ,
resim: "assets/images/ktm_250/250_Duke.jpg",
resimLeft: "assets/images/ktm_250/250_Duke_01.jpg",
resimRight: "assets/images/ktm_250/250_Duke_02.jpg",
model: 'KTM Duke 250',
yil: '2022',
fiyat: '154.0 ₺',
yildiz: 3.4,
motorTipi: "1 silindir, 4 zamanlı, benzin",
motorHacmi: '249.9 cc',
motorTork: '28.0 nm',
motorPower: '31.0',
motorHiz: '147 km/h',
sanziman: "Sıralı, 6 vites",
debriyaj: "PASC kaydırmalı debriyaj",
sogutma: "Sıvı soğutma",
atesleme: 'Bosch EMS',
sasiTipi: "Çelik borulardan ana boru şasi, toz kaplama",
onAmortisor: 'WP APEX 43',
arkaAmortisor: "WP APEX Monoshock",
onFren: "Dört pistonlu / Disk fren",
arkaFren: "Tek pistonlu / Disk fren",
frenDiskCap: "320 mm / 230 mm",
zincir: "3520 X-Ring",
onLastikCap: "110/70 17",
arkaLastikCap: "150/60 17",
yukseklik: "830",
agirlik: "149",
yakitDeposu: "13.4",
ortalamaYakit: "3.46 l/100 km"
);
Motor ktm390 = Motor(
marka: markalar.isim ,
resim: "assets/images/390_Duke.jpg",
resimLeft: "assets/images/ktm_250/250_Duke.jpg",
resimRight: "assets/images/ktm_250/250_Duke.jpg",
model: 'KTM Duke 390',
yil: '2021',
fiyat: '200.0 ₺',
yildiz: 4.5,
motorTipi: "Paralel çift silindirli 4 zamanlı",
motorHacmi: '373.0 cc',
motorPower: '32kW 44hp',
motorTork: '37.0 nm',
motorHiz: '170 km/h ',
sanziman: "Sıralı, 6 vites",
debriyaj: "PASC kaydırmalı debriyaj",
sogutma: "Sıvı soğutma",
atesleme: 'Bosch EMS',
sasiTipi: "Çelik borulardan ana boru şasi, toz kaplama",
onAmortisor: 'WP APEX 43',
arkaAmortisor: "WP APEX Monoshock",
onFren: "Dört pistonlu fren kaliper",
arkaFren: "Tek pistonlu fren kaliper",
frenDiskCap: "320 mm / 230 mm",
zincir: "520 X-Ring",
onLastikCap: "110/70 17",
arkaLastikCap: "150/60 17",
yukseklik: "830 mm",
agirlik: "149 kg",
yakitDeposu: "13.4 l",
ortalamaYakit: "3.46 l/100 km",
);
Motor ktm890 = Motor(
marka: markalar.isim ,
resim: "assets/images/ktm_890/890_Duke.png",
resimLeft: "assets/images/ktm_890/890_Duke_01.png",
resimRight: "assets/images/ktm_890/890_Duke_02.png",
model: 'KTM Duke 890',
yil: '2022',
fiyat: '287.900',
yildiz: 4.5,
motorTipi: "Paralel çift silindirli 4 zamanlı",
motorHacmi: '889 cc',
motorPower: '89kW 121hp',
motorHiz: '240',
sanziman: "Sıralı, 6 vites",
debriyaj: "PASC kaydırmalı debriyaj",
sogutma: "Sıvı soğutma",
atesleme: 'Bosch EMS',
sasiTipi: "Krom molibden çelik borudan ana boru şasi",
onAmortisor: 'WP APEX 43',
arkaAmortisor: "WP APEX Monoshock",
onFren: "Dört pistonlu, 2x Brembo radyal kaliper",
arkaFren: "Tek pistonlu Brembo yüzer kaliper",
frenDiskCap: "320 mm / 240 mm",
zincir: "520 X-Ring",
onLastikCap: "120/70 17",
arkaLastikCap: "180/55 17",
yukseklik: "834",
agirlik: "166",
yakitDeposu: "14",
ortalamaYakit: "4.74 l/100 km",
motorTork: '99 nm'
);
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/screens/motor_detail_page.dart
|
import 'package:flutter/material.dart';
import 'package:motorotam/components/appbar_widget.dart';
import 'package:motorotam/components/properties_motor_card.dart';
import 'package:responsive_framework/responsive_framework.dart';
import '../components/motor_detail_widget.dart';
class MotorDetailPage extends StatelessWidget {
String motorModel;
String motorResim;
String motorResimLeft;
String motorResimRight;
String motorFiyat;
double motorYildiz;
String motorHacim;
String motorFren;
String motorPower;
String motorHiz;
String motorTork;
String motorTipi;
String motorSanziman;
String motorDebriyaj;
String motorSogutma;
String motorAtesleme;
String motorSasi;
String motorOnAmortisor;
String motorArkaAmortisor;
String motorOnFren;
String motorFrenDiskCap;
String motorArkaFren;
String motorOnLastik;
String motorArkaLastik;
String motorYukseklik;
String motorYakitDeposu;
String motorOrtalamaYakit;
String motorZincir;
String motorAgirlik;
MotorDetailPage({
Key? key,
required this.motorModel,
required this.motorAtesleme,
required this.motorResim,
required this.motorResimLeft,
required this.motorResimRight,
required this.motorOnLastik,
required this.motorFrenDiskCap,
required this.motorArkaLastik,
required this.motorYukseklik,
required this.motorYakitDeposu,
required this.motorOrtalamaYakit,
required this.motorOnAmortisor,
required this.motorArkaAmortisor,
required this.motorOnFren,
required this.motorArkaFren,
required this.motorFiyat,
required this.motorHacim,
required this.motorFren,
required this.motorPower,
required this.motorHiz,
required this.motorTork,
required this.motorTipi,
required this.motorSanziman,
required this.motorDebriyaj,
required this.motorSogutma,
required this.motorSasi,
required this.motorZincir,
required this.motorAgirlik,
required this.motorYildiz,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFEEEDE9),
appBar: AppBarWidgets(
baslik: motorModel,
),
body: ListView(
children: [
ResponsiveRowColumn(
layout: ResponsiveWrapper.of(context).isSmallerThan(TABLET)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: MotorDetailWidget(
motorResim: motorResim,
motorResimRight: motorResimRight,
motorResimLeft: motorResimLeft,),
),
],
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 5),
height: 40,
color: const Color.fromRGBO(29, 31, 32, 1),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 3,
child: Text(
motorFiyat,
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 1,
child: Row(
children: [
const Icon(
Icons.star,
color: Colors.amber,
),
Text(motorYildiz.toString(),
style: TextStyle(color: Colors.amber, fontSize: 18)),
],
),
),
const Text("4260 Reviews ",
style: TextStyle(color: Colors.white, fontSize: 14)),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Temel Özellikler",
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
Row(
children: [
motorRenkSecici(
renk: const Color.fromRGBO(255, 81, 6, 1),
border: Colors.black12,
shadowRenk: Colors.black26,
),
const SizedBox(
width: 5,
),
motorRenkSecici(
renk: Colors.white,
border: Colors.black12,
shadowRenk: Colors.black26,
),
const SizedBox(
width: 5,
),
],
),
],
),
),
Row(
children: [
PropertiesMotorCard(
motorHacim: motorHacim,
motorPower: motorPower,
motorFren: motorFren,
motorHiz: motorHiz,
motorTork: motorTork,
),
],
),
const Padding(
padding: EdgeInsets.only(left: 8, top: 20),
child: Text(
"Ayrıntılı Özellikler",
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
),
ozellikBasliklari(baslik: 'Motor'),
motorOzellikleri(anahtar: 'Motor Tipi : ', deger: motorTipi),
motorOzellikleri(anahtar: 'Motor Hacmi: ', deger: motorHacim),
motorOzellikleri(anahtar: 'Güç: ', deger: motorPower),
motorOzellikleri(anahtar: 'Şanzıman: ', deger: motorSanziman),
motorOzellikleri(anahtar: 'Debriyaj: ', deger: motorDebriyaj),
motorOzellikleri(anahtar: 'Soğutma: ', deger: motorSogutma),
motorOzellikleri(
anahtar: 'Ateşleme Tertibatı: ', deger: motorAtesleme),
const Divider(
indent: 14,
endIndent: 14,
height: 30,
thickness: 5,
),
ozellikBasliklari(baslik: 'Yürüyen Aksam'),
yuruyenAksamOzellikleri(anahtar: 'Şasi: ', deger: motorSasi),
yuruyenAksamOzellikleri(
anahtar: 'Ön Amortisör: ', deger: motorOnAmortisor),
yuruyenAksamOzellikleri(
anahtar: 'Arka Amortisör: ', deger: motorArkaAmortisor),
yuruyenAksamOzellikleri(anahtar: 'Ön Fren: ', deger: motorOnFren),
yuruyenAksamOzellikleri(anahtar: 'Arka Fren: ', deger: motorArkaFren),
yuruyenAksamOzellikleri(
anahtar: 'Fren Diskleri Çap Ön/Arka: ', deger: motorFrenDiskCap),
yuruyenAksamOzellikleri(anahtar: 'Zincir: ', deger: motorZincir),
yuruyenAksamOzellikleri(
anahtar: 'Ön Lastik Ebat: ', deger: motorOnLastik),
yuruyenAksamOzellikleri(
anahtar: 'Arka Lastik: ', deger: motorArkaLastik),
yuruyenAksamOzellikleri(
anahtar: 'Oturma Yüksekliği: ', deger: motorYukseklik + ' mm'),
yuruyenAksamOzellikleri(
anahtar: 'Yakıt deposu: ', deger: motorYakitDeposu + ' Litre'),
yuruyenAksamOzellikleri(
anahtar: 'Yakıtsız ağırlık yaklaşık: ',
deger: motorAgirlik + ' kg'),
yuruyenAksamOzellikleri(
anahtar: 'Ortalama Yakıt Tüketimi: ', deger: motorOrtalamaYakit),
],
),
);
}
Container motorRenkSecici(
{required Color renk, required Color shadowRenk, required Color border}) {
return Container(
width: 24,
height: 24,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
spreadRadius: 1,
color: shadowRenk,
offset: const Offset(1, 1),
blurRadius: 3,
)
],
border: Border.all(
color: border,
),
color: renk,
shape: BoxShape.circle),
);
}
Padding motorOzellikleri({required String anahtar, required String deger}) {
return Padding(
padding: const EdgeInsets.only(
top: 5,
left: 40,
),
child: Row(
children: [
RichText(
text: TextSpan(
text: anahtar,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black),
children: <TextSpan>[
TextSpan(
text: deger,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.black),
),
],
),
),
],
),
);
}
Padding yuruyenAksamOzellikleri(
{required String anahtar, required String deger}) {
return Padding(
padding: const EdgeInsets.only(
top: 5,
left: 40,
),
child: Row(
children: [
RichText(
text: TextSpan(
text: anahtar,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black),
children: <TextSpan>[
TextSpan(
text: deger,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.black),
),
],
),
),
],
),
);
}
Padding ozellikBasliklari({required String baslik}) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
const Icon(
Icons.workspaces_filled,
size: 18.0,
),
const SizedBox(
width: 5,
),
Text(
baslik,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/screens/modeller_page.dart
|
import 'package:flutter/material.dart';
import 'package:motorotam/components/appbar_widget.dart';
import 'package:motorotam/components/category_bar.dart';
import 'package:motorotam/components/motor_card.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:responsive_framework/responsive_row_column.dart';
import 'motor_detail_page.dart';
class ModellerPageWidget extends StatelessWidget {
const ModellerPageWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: const Color(0xFFEEEDE9),
appBar: AppBarWidgets(baslik: "Modeller",),
body: Align(
alignment: Alignment.center,
child: ListView(
children: [
const CategoryBar(),
ResponsiveRowColumn(
rowPadding: const EdgeInsets.all(0),
layout: ResponsiveWrapper.of(context).isSmallerThan(TABLET)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
Container(
width: ResponsiveValue(
context,
defaultValue: 55.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 55.0,
),
Condition.largerThan(
name: TABLET,
value: 100.0,
),
Condition.largerThan(
name: DESKTOP,
value: 250.0,
),
],
).value,
height: ResponsiveValue(
context,
defaultValue: 6.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 6.0,
),
Condition.largerThan(
name: TABLET,
value: 12.0,
),
Condition.largerThan(
name: DESKTOP,
value: 16.0,
),
],
).value,
color: const Color.fromRGBO(29, 31, 32, 1),
),
const SizedBox(
width: 8,
),
const Text(
"Naked Modeller",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
const SizedBox(
width: 8,
),
Container(
width: ResponsiveValue(
context,
defaultValue: 130.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 400.0,
),
Condition.largerThan(
name: TABLET,
value: 500.0,
),
Condition.largerThan(
name: DESKTOP,
value: 1200.0,
),
],
).value,
height: ResponsiveValue(
context,
defaultValue: 6.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 6.0,
),
Condition.largerThan(
name: TABLET,
value: 12.0,
),
Condition.largerThan(
name: DESKTOP,
value: 16.0,
),
],
).value,
color: const Color.fromRGBO(29, 31, 32, 1),
),
],
),
),
),
],
),
ResponsiveRowColumn(
rowPadding: EdgeInsets.all(0),
layout: ResponsiveWrapper.of(context).isSmallerThan(MOBILE)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(motorModel: '',
motorFiyat: '', motorYildiz: 3.5,
motorHacim: '', motorFren: '',
motorPower: '',
motorHiz: '',
motorTork: '',
motorTipi: '',
motorSanziman: '',
motorDebriyaj: '',
motorSogutma: '',
motorAtesleme: '',
motorSasi: '',
motorOnAmortisor: '',
motorArkaAmortisor: '',
motorOnFren: '',
motorArkaFren: '',
motorOnLastik: '',
motorArkaLastik: '',
motorYukseklik: '',
motorYakitDeposu: '',
motorOrtalamaYakit: '',
motorFrenDiskCap: '',
motorZincir: '',
motorAgirlik: '',
motorResim: '',
motorResimLeft: '',
motorResimRight: '',
),
),
);
},
child: MotorCard(baslik: 'KTM 250', fiyat: '123.0', resim: "assets/images/390_Duke.jpg", yildiz: 3, yil: '2022',),
),
),
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(motorModel: '',
motorFiyat: '',
motorYildiz: 2.0,
motorHacim: '',
motorFren: '',
motorPower: '',
motorHiz: '',
motorTork: '',
motorTipi: '',
motorSanziman: '',
motorDebriyaj: '',
motorSogutma: '',
motorAtesleme: '',
motorSasi: '',
motorOnAmortisor: '',
motorArkaAmortisor: '',
motorOnFren: '',
motorArkaFren: '',
motorOnLastik: '',
motorArkaLastik: '',
motorYukseklik: '',
motorYakitDeposu: '',
motorOrtalamaYakit: '',
motorFrenDiskCap: '',
motorZincir: '',
motorAgirlik: '',
motorResim: '',
motorResimLeft: '',
motorResimRight: '' ,
),
),
);
},
child: MotorCard(baslik: 'KTM 390', fiyat: '123.0', resim: "assets/images/390_Duke.jpg", yildiz: 2, yil: '2022', ),
),
),
],
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/screens/splash_screen.dart
|
import 'package:flutter/material.dart';
class IlkEkran extends StatelessWidget {
const IlkEkran({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: // Figma Flutter Generator Googlepixel21Widget - FRAME
Container(
width: 411,
height: 731,
decoration: const BoxDecoration(
color: Color.fromRGBO(238, 237, 233, 1),
),
child: Stack(children: <Widget>[
Positioned(
top: 100,
left: 127,
child: Container(
width: 166,
height: 161,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/logo.png'),
fit: BoxFit.fitWidth),
),
),
),
const Positioned(
top: 300,
left: 138,
child: Text(
'MotoRotam',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontFamily: 'Inter',
fontSize: 24,
letterSpacing:
0 /*percentages not used in flutter. defaulting to zero*/,
fontWeight: FontWeight.normal,
height: 1),
)),
const Positioned(
top: 350,
left: 138,
child: Text(
'Mobil App Slogan',
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.5299999713897705),
fontFamily: 'Inter',
fontSize: 16,
letterSpacing:
0 /*percentages not used in flutter. defaulting to zero*/,
fontWeight: FontWeight.normal,
height: 1),
)),
Positioned(
top: 431,
left: 44,
child: Container(
width: 323,
height: 300,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/logo_2.png'),
fit: BoxFit.fitWidth),
))),
])));
}
}
| 0
|
mirrored_repositories/motorotam/lib
|
mirrored_repositories/motorotam/lib/screens/main_page.dart
|
import 'package:flutter/material.dart';
import 'package:motorotam/components/appbar_widget.dart';
import 'package:motorotam/screens/motor_detail_page.dart';
import 'package:responsive_framework/responsive_framework.dart';
import '../components/category_bar.dart';
import '../components/motor_card.dart';
import '../components/top_brands.dart';
import '../components/yatay_list.dart';
import '../model/models.dart';
class MainPage extends StatelessWidget {
const MainPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: const Color(0xFFEEEDEF),
appBar: AppBarWidgets(baslik: "MotoRotam",),
body: Align(
alignment: Alignment.center,
child: ListView(
children: [
const TopBrands(),
const YatayListMarka(),
ResponsiveRowColumn(
layout: ResponsiveWrapper.of(context).isSmallerThan(TABLET)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: Container(
width: screenWidth,
height: ResponsiveValue(
context,
defaultValue: 6.0,
valueWhen: const [
Condition.smallerThan(
name: MOBILE,
value: 6.0,
),
Condition.largerThan(
name: TABLET,
value: 12.0,
),
Condition.largerThan(
name: DESKTOP,
value: 16.0,
),
],
).value,
color: const Color.fromRGBO(29, 31, 32, 1),
),
),
],
),
const CategoryBar(),
ResponsiveRowColumn(
columnPadding: const EdgeInsets.all(12),
layout: ResponsiveWrapper.of(context).isSmallerThan(MOBILE)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(
motorModel: ktm250.model,
motorFiyat: ktm250.fiyat.toString(),
motorYildiz: ktm250.yildiz,
motorHacim: ktm250.motorHacmi.toString(),
motorFren: ktm250.onFren,
motorPower: ktm250.motorPower.toString(),
motorHiz: ktm250.motorHiz,
motorTork: ktm250.motorTork,
motorTipi: ktm250.motorTipi,
motorSanziman: ktm250.sanziman,
motorDebriyaj: ktm250.debriyaj,
motorSogutma: ktm250.sogutma,
motorAtesleme: ktm250.atesleme,
motorSasi: ktm250.sasiTipi,
motorOnAmortisor: ktm250.onAmortisor,
motorArkaAmortisor: ktm250.arkaAmortisor,
motorOnFren: ktm250.onFren,
motorArkaFren: ktm250.arkaFren,
motorOnLastik: ktm250.onLastikCap,
motorArkaLastik: ktm250.arkaLastikCap,
motorYukseklik: ktm250.yukseklik,
motorYakitDeposu: ktm250.yakitDeposu,
motorOrtalamaYakit: ktm250.ortalamaYakit,
motorFrenDiskCap: ktm250.frenDiskCap,
motorZincir: ktm250.zincir,
motorAgirlik: ktm250.agirlik,
motorResim: ktm250.resim,
motorResimLeft: ktm250.resimLeft,
motorResimRight: ktm250.resimRight,
),
),
);
},
child: MotorCard(
baslik: ktm250.model,
fiyat: ktm250.fiyat.toString(),
resim: ktm250.resim,
yildiz: ktm250.yildiz,
yil: ktm250.yil,
),
),
),
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(motorModel: ktm390.model,
motorFiyat: ktm390.fiyat.toString(),
motorYildiz: ktm390.yildiz,
motorHacim: ktm390.motorHacmi.toString(), motorFren: '',
motorPower: ktm390.motorPower.toString(),
motorHiz: ktm390.motorHiz,
motorTork: ktm390.motorTork,
motorTipi: ktm390.motorTipi,
motorSanziman: ktm390.sanziman,
motorDebriyaj: ktm390.debriyaj,
motorSogutma: ktm390.sogutma,
motorAtesleme: ktm390.atesleme,
motorSasi: ktm390.sasiTipi,
motorOnAmortisor: ktm390.onAmortisor,
motorArkaAmortisor: ktm390.arkaAmortisor,
motorOnFren: ktm390.onFren,
motorArkaFren: ktm390.arkaFren,
motorOnLastik: ktm390.onLastikCap,
motorArkaLastik: ktm390.arkaLastikCap,
motorYukseklik: ktm390.yukseklik,
motorYakitDeposu: ktm390.yakitDeposu,
motorOrtalamaYakit: ktm390.ortalamaYakit,
motorFrenDiskCap: ktm390.frenDiskCap,
motorZincir: ktm390.zincir,
motorAgirlik: ktm390.agirlik,
motorResim: ktm390.resim,
motorResimLeft: ktm390.resimLeft,
motorResimRight: ktm390.resimRight,
),
),
);
},
child: MotorCard(
baslik: ktm390.model,
fiyat: ktm390.fiyat.toString(),
resim: ktm390.resim,
yildiz: ktm390.yildiz,
yil: ktm390.yil,
),
),
),
],
),
ResponsiveRowColumn(
columnPadding: const EdgeInsets.all(12),
layout: ResponsiveWrapper.of(context).isSmallerThan(MOBILE)
? ResponsiveRowColumnType.COLUMN
: ResponsiveRowColumnType.ROW,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(motorModel: ktm890.model,
motorFiyat: ktm890.fiyat.toString(),
motorYildiz: ktm890.yildiz,
motorHacim: ktm890.motorHacmi.toString(), motorFren: '',
motorPower: ktm890.motorPower.toString(),
motorHiz: ktm890.motorHiz,
motorTork: ktm890.motorTork,
motorTipi: ktm890.motorTipi,
motorSanziman: ktm890.sanziman,
motorDebriyaj: ktm890.debriyaj,
motorSogutma: ktm890.sogutma,
motorAtesleme: ktm890.atesleme,
motorSasi: ktm890.sasiTipi,
motorOnAmortisor: ktm890.onAmortisor,
motorArkaAmortisor: ktm890.arkaAmortisor,
motorOnFren: ktm890.onFren,
motorArkaFren: ktm890.arkaFren,
motorOnLastik: ktm890.onLastikCap,
motorArkaLastik: ktm890.arkaLastikCap,
motorYukseklik: ktm890.yukseklik,
motorYakitDeposu: ktm890.yakitDeposu,
motorOrtalamaYakit: ktm890.ortalamaYakit,
motorFrenDiskCap: ktm890.frenDiskCap,
motorZincir: ktm890.zincir,
motorAgirlik: ktm890.agirlik,
motorResim: ktm890.resim,
motorResimLeft: ktm890.resimLeft,
motorResimRight: ktm890.resimRight,
),
),
);
},
child: MotorCard(
baslik: ktm890.model,
fiyat: ktm890.fiyat.toString(),
resim: ktm890.resim,
yildiz: ktm890.yildiz,
yil: ktm890.yil,
),
),
),
ResponsiveRowColumnItem(
rowFlex: 1,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MotorDetailPage(motorModel: '',
motorFiyat: '-?-',
motorYildiz: 1.5,
motorHacim: '**', motorFren: '',
motorPower: '??',
motorHiz: '???',
motorTork: '?',
motorTipi: '*?',
motorSanziman: '',
motorDebriyaj: '&&',
motorSogutma: '',
motorAtesleme: '++',
motorSasi: '',
motorOnAmortisor: '',
motorArkaAmortisor: '',
motorOnFren: '',
motorArkaFren: '',
motorOnLastik: '',
motorArkaLastik: '',
motorYukseklik: '',
motorYakitDeposu: '',
motorOrtalamaYakit: '',
motorFrenDiskCap: '',
motorZincir: '',
motorAgirlik: '',
motorResim: '',
motorResimLeft: '',
motorResimRight: '',
),
),
);
},
child: MotorCard(
baslik: 'KTM 790',
fiyat: '123.0',
resim: ktm890.resim,
yildiz: 3.5,
yil: '2022',
),
),
),
],
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/motorotam
|
mirrored_repositories/motorotam/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:motorotam/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_news_netbase
|
mirrored_repositories/flutter_news_netbase/lib/main.dart
|
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/RecentPage.dart';
import 'package:flutter_news_netbase/part2/HomePage.dart';
import 'package:flutter_news_netbase/part1/LevelPage.dart';
import 'package:flutter_news_netbase/part1/Settings.dart';
import 'package:flutter_news_netbase/part1/SmallVideoPage.dart';
import 'package:flutter_news_netbase/part1/SquarePage.dart';
import 'package:flutter_news_netbase/part1/FreeNewsPage.dart';
import 'package:flutter_news_netbase/part2/AIItemsPage.dart';
import 'package:flutter_news_netbase/part2/DrawerPage.dart';
import 'package:flutter_news_netbase/part2/SearchBar.dart';
//import 'package:flutter_news_netbase/part1/HotPage.dart';
import 'package:flutter_news_netbase/part1/NoticePage.dart';
import 'package:flutter_news_netbase/part2/routes/VideoTabPage.dart';
import 'package:flutter_news_netbase/part2/content2/VidaoTabPage2.dart';
import 'package:flutter_news_netbase/part2/content2/HotPage.dart';
import 'package:flutter_news_netbase/part2/circle/CirclePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
//设置全局状态栏颜色 红色
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.red));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
routes: {
'/recent': (BuildContext context) => RecentPage(),
// '/level': (BuildContext context) => LevelPage(),
// '/settings': (BuildContext context) => AccountSettingPage(),
// '/video': (BuildContext context) => SmallVideoPage(),
// '/square': (BuildContext context) => SquarePage(),
// '/freeflow_news': (BuildContext context) => FreeNewsPage(),
'/all_items': (BuildContext context) => AIItemsPage(),
'/hot': (BuildContext context) => HotPage(),
'/notice': (BuildContext context) => NoticePage()
},
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int initPage = 0;
PageController pageController;
@override
void initState() {
// this 表示当前继承的 SingleTickerProviderStateMixin 的当前这个类
pageController = PageController(initialPage: initPage);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: buildTitleBar(),
body: PageView(
controller: pageController,
// physics: NeverScrollableScrollPhysics(), //禁止滑动
onPageChanged: (int index) {
print('当前点击的页面是:${index}');
setState(() {
initPage = index;
});
},
children: <Widget>[
HomePage(),
//SmallVideoPage(),
VideoTabPage2(),
//HotPage(),
HotPage(),
// NoticePage(),
CirclePage(),
],
),
bottomNavigationBar: BottomNavigationBar(
onTap: (index) {
pageController.jumpToPage(index);
},
items: [
BottomNavigationBarItem(
title: Text('首页'),
icon: Icon(
Icons.home,
color: Colors.grey,
)),
BottomNavigationBarItem(
title: Text('视频'),
icon: Icon(
Icons.live_tv,
color: Colors.grey,
)),
BottomNavigationBarItem(
title: Text('圈子'),
icon: Icon(
Icons.whatshot,
color: Colors.grey,
)),
BottomNavigationBarItem(
title: Text('热度'),
icon: Icon(
Icons.recent_actors,
color: Colors.grey,
)),
],
currentIndex: initPage,
//当前选中的,修改成当前索引
elevation: 10,
//阴影
type: BottomNavigationBarType.fixed,
//白色的底
// fixedColor: Colors.red,//选中的颜色
backgroundColor: Colors.white,
//背景颜色
//icon的大小
iconSize: 25,
selectedItemColor: Colors.blue,
//选中时的item颜色,不能喝fixedColor一起使用
//type: BottomNavigationBarType.shifting,//正好反过来
selectedIconTheme: IconThemeData(size: 20),
//选中标签的大小,以IconThemeData为准
selectedFontSize: 10, //选中标签的文字大小
),
drawer: DrawerPage(),
drawerDragStartBehavior: DragStartBehavior.start,
//滑动开始的坐标
drawerEdgeDragWidth: 50, //从左到右滑动,默认padding为20
// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/HotPage.dart
|
import 'package:flutter/material.dart';
class HotPage extends StatefulWidget {
@override
_HotPageState createState() => _HotPageState();
}
class _HotPageState extends State<HotPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('热门'),
),
body: Text('热门'),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/RecentPage.dart
|
import 'package:flutter/material.dart';
class RecentPage extends StatefulWidget {
@override
_RecentPageState createState() => _RecentPageState();
}
class _RecentPageState extends State<RecentPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: Row(
children: <Widget>[
buildContents(
'assets/images/daily_economic_news.png', 'item1', Colors.red),
buildContents('assets/images/family_it.png', 'item2', Colors.blue),
buildContents(
'assets/images/weekly_chinese_news.png', 'item3', Colors.orange),
buildContents(
'assets/images/new_peking_news.png', 'item4', Colors.green),
],
),
);
}
Widget buildContents(String path, String text, Color color) {
return Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
child: Image.asset(
path,
width: 40,
height: 40,
fit: BoxFit.fill,
),
backgroundColor: color,
radius: 30,
),
),
Text(
text,
style: TextStyle(color: Colors.grey, fontSize: 12),
)
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/FreeNewsPage.dart
|
import 'package:flutter/material.dart';
class FreeNewsPage extends StatefulWidget {
@override
_FreeNewsPageState createState() => _FreeNewsPageState();
}
class _FreeNewsPageState extends State<FreeNewsPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: new Text('免流量看新闻'),
),
body: buildContents(),
);
}
Widget buildContents() {
return Column(
children: <Widget>[
buildCards('白金卡', Colors.indigo, '电信', '内容1.。。。。。。。。', '内容2.。。。。。。。。'),
buildCards('乐卡', Colors.red, '联通', '内容2.。。。。。。。。', '内容2.。。。。。。。。'),
buildCards(
'态度包', Colors.lightBlue, '移动', '内容3.。。。。。。。。。', '内容3.。。。。。。。。。'),
buildCards('流量包', Colors.red, '联通', '内容4.。。。。。。。。。。', '内容4.。。。。。。。。。。'),
],
);
}
Widget buildCards(
String title1, Color color, String title2, String title3, String title4) {
return Stack(
children: <Widget>[
Card(
elevation: 5, //阴影
margin: EdgeInsets.all(20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8), //圆角矩形
),
),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Text(
title1,
style: TextStyle(fontSize: 20),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 8),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Text(
title2,
style: TextStyle(
color: Colors.grey[50],
fontSize: 15,
),
),
),
)
],
),
Text(
title3,
style: TextStyle(fontSize: 13, color: Colors.grey),
),
Text(
title4,
style: TextStyle(fontSize: 13, color: Colors.grey),
),
],
),
),
),
Positioned(
left: 260,
top: 50,
width: 90,
height: 33,
child: Container(
child: Center(
child: Text(
'立即领取',
style: TextStyle(color: Colors.red, fontSize: 15),
),
),
padding: EdgeInsets.symmetric(horizontal: 8),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
),
borderRadius: BorderRadius.circular(10.0),
),
),
)
],
);
//
}
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/LevelPage.dart
|
import 'package:flutter/material.dart';
class LevelPage extends StatefulWidget {
@override
_LevelPageState createState() => _LevelPageState();
}
class _LevelPageState extends State<LevelPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.grey[200],
appBar: new AppBar(
title: new Text('等级介绍'),
),
body: Column(
children: <Widget>[
buildTitle(context),
buildContents(context, '科员', Icons.star_border, '0', '0'),
buildContents(context, '科员', Icons.star_border, '1', '60'),
buildContents(context, '副科长', Icons.star_border, '2', '300'),
buildContents(context, '副科长', Icons.star_border, '3', '600'),
buildContents(context, '科员', Icons.star_border, '4', '900'),
buildContents(context, '科员', Icons.star_border, '5', '1400'),
buildContents(context, '副科长', Icons.star_border, '6', '2100'),
buildContents(context, '副科长', Icons.star_border, '7', '4200'),
buildContents(context, '科员', Icons.star_border, '8', '6300'),
buildContents(context, '科员', Icons.star_border, '9', '9400'),
buildContents(context, '副科长', Icons.star_border, '10', '12600'),
buildContents(context, '副科长', Icons.star_border, '11', '15700'),
],
),
);
}
Widget buildTitle(BuildContext context) {
//根据context获取屏幕的宽度
double width = MediaQuery.of(context).size.width / 4 - 5;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
//文本
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(
'等级头衔',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
),
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(
'等级头衔',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
),
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(
'等级图标',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
),
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(
'等级',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
),
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(
'所需积分',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
),
],
);
}
Widget buildContents(BuildContext context, String text, IconData icon,
String level, String score) {
//根据context获取屏幕的宽度
double width = MediaQuery.of(context).size.width / 4 - 5;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
//文字
Container(
width: width,
child: Center(child: Text(text)),
padding: EdgeInsets.symmetric(horizontal: 5),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
border: new Border.all(
color: Colors.red,
width: 1.0,
)),
),
//图标
Container(
width: width,
padding: EdgeInsets.all(5),
child: Icon(
icon,
size: 20,
color: Colors.red,
),
),
//文本
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(level),
),
),
//积分
Container(
width: width,
padding: EdgeInsets.all(5),
child: Center(
child: Text(level),
),
),
],
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/AIItemsPage.dart
|
import 'package:flutter/material.dart';
class AIItemsPage extends StatefulWidget {
@override
_AIItemsPageState createState() => _AIItemsPageState();
}
class _AIItemsPageState extends State<AIItemsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text('所有栏目'),
),
body: buildContents(),
);
}
Widget buildContents(){
double width = MediaQuery.of(context).size.width;
List<String> datas = [
'关注',
'头条',
'视频',
'娱乐',
'体育',
'新时代',
'要闻',
'段子',
'知否',
'上海',
'公开课',
'圈子',
'财经',
'科技',
'汽车',
'网易号',
'军事',
'时尚',
'跟帖',
'直播',
'图片',
'小视频',
'NBA',
'热点',
'房产',
'股票',
'轻松一刻',
'历史',
'家居',
'播单',
'独家',
'游戏',
'健康',
'航空',
'小说',
'热度'
];
return SizedBox(
width: width,
child: Wrap(
spacing: 10.0,
runSpacing: 10.0,
direction: Axis.horizontal,
verticalDirection: VerticalDirection.down,
alignment: WrapAlignment.spaceEvenly,
crossAxisAlignment: WrapCrossAlignment.start,
children: datas.map((data){
return Chip(
label: Container(
child: Center(child: Text(data),),
width: 55,
),
labelStyle: TextStyle(
color: data=='头条'?Colors.red:Colors.black87,
fontSize: 13,
),
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[200],
width: 1.0,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.circular(20),
),
);
}).toList(),
),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/SmallVideoPage.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/model/SmallVideoModel.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
import 'package:flutter_news_netbase/part2/content2/SmallVideoListPage.dart';
import 'package:video_player/video_player.dart';
class SmallVideoPage extends StatefulWidget {
//增加一个key
SmallVideoPage({Key key}) : super(key: key);
@override
_SmallVideoPageState createState() => _SmallVideoPageState();
}
class _SmallVideoPageState extends State<SmallVideoPage> {
List<Data> datas2;
@override
void initState() {
super.initState();
datas2 = <Data>[];
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[200],
// appBar: new AppBar(
// title: new Text('小视频'),
// ),
body: buildContexts(context),
);
}
Widget buildGridView(BuildContext context, List<Data> datas) {
return GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 6,
mainAxisSpacing: 3,
childAspectRatio: 9.0 / 16.0,
children: datas.map((data) {
return VideoItem(data: data, key: widget.key);
}).toList(),
);
}
// Widget buildVideoItems(BuildContext context, Data data) {
// String counts = data.viewCounts;
// int intData = int.parse(counts);
// String results = "";
// if (intData >= 10000) {
// double newData = intData / 10000;
// results = "${newData.toStringAsFixed(1)}万";
// } else {
// results = counts;
// }
//
// return GestureDetector(
// onTap: () {
// gotoNewPage(context, SmallVideoListPage());
// },
// child: Container(
// width: 180,
// height: 100,
// child: Stack(
// children: <Widget>[
// VideoPage(data),
// Positioned(
// bottom: 20,
// left: 0,
// right: 0,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Padding(
// padding: EdgeInsets.fromLTRB(8, 0, 8, 0),
// child: Text(
// '${data.title}',
// //最多只能有2行显示
// maxLines: 2,
// //超出部分省略号
// overflow: TextOverflow.ellipsis,
// style: TextStyle(fontSize: 17, color: Colors.white),
// ),
// ),
// Padding(
// padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: <Widget>[
// Text(
// '$results次包房量',
// style: TextStyle(fontSize: 13, color: Colors.grey),
// ),
// Text(
// '${data.votecount}人点赞',
// style: TextStyle(fontSize: 13, color: Colors.grey),
// ),
// ],
// ),
// ),
// ],
// ),
// )
// ],
// ),
// ),
// );
// }
Widget buildContexts(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return FutureBuilder(
future: rootBundle.loadString('assets/video.json'),
builder: (BuildContext context, AsyncSnapshot snap) {
if (snap.hasData) {
SmallVideoModel model = videoModuleFromJson(snap.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
datas2.add(bean);
}
return buildGridView(context, datas2);
} else {
return CircularProgressIndicator();
}
},
);
}
}
class VideoItem extends StatefulWidget {
Data data;
VideoItem({
Key key,
@required this.data,
}) : assert(data != null),
super(key: key);
@override
VideoItemState createState() => VideoItemState();
}
class VideoItemState extends State<VideoItem> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
//进入视频详情页
gotoNewPage(context, SmallVideoListPage(widget.data));
},
child: GridTile(
//文字描述部分位于底部
footer: GridTileBar(
backgroundColor: Colors.transparent,
title: buildTitleText(widget.data, isSubTitle: false),
subtitle: buildTitleText(widget.data, isSubTitle: true),
),
child: VideoPlayerThumbPage(widget.data),
),
);
}
///构建描述视频文本标题
buildTitleText(Data data, {bool isSubTitle = false}) {
String counts = data.viewCounts;
int intData = int.parse(counts);
String results = "";
if (intData >= 10000) {
double newData = intData / 10000;
results = "${newData.toStringAsFixed(1)}万";
} else {
results = counts;
}
}
}
//视频播放页面修改一下,普通视频加载页面
//实际开发中,没有必要在这里进行加载视频操作
//获取到视频缩略图,让它显示出来即可
//接口里会有一个thumb之内的字段表示视频缩略图
//点进详情页才加载视频
class VideoPlayerThumbPage extends StatefulWidget {
final Data data;
VideoPlayerThumbPage(this.data);
@override
_VideoPlayerThumbPageState createState() => _VideoPlayerThumbPageState();
}
class _VideoPlayerThumbPageState extends State<VideoPlayerThumbPage> {
bool _initialized;
VideoPlayerController controller;
@override
void initState() {
super.initState();
controller = VideoPlayerController.network(widget.data.url);
controller.initialize();
_initialized = controller.value.initialized;
controller.addListener(() {
// if (!mounted) {
// return;
// }
final bool controllerInitialized = controller.value.initialized;
if (_initialized != controllerInitialized) {
setState(() {
_initialized = controllerInitialized;
});
}
});
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width / 2;
return SizedBox(
width: width,
height: 330,
child: _initialized
? VideoPlayer(controller)
: Container(width: width, height: 330, color: Colors.teal),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/NoticePage.dart
|
import 'package:flutter/material.dart';
class NoticePage extends StatefulWidget {
@override
_NoticePageState createState() => _NoticePageState();
}
class _NoticePageState extends State<NoticePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('消息'),
),
body: Text('消息'),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/Settings.dart
|
import 'package:flutter/material.dart';
class AccountSettingPage extends StatefulWidget {
@override
_AccountSettingPageState createState() => _AccountSettingPageState();
}
class _AccountSettingPageState extends State<AccountSettingPage> {
bool init_value = true;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[200],
appBar: new AppBar(
title: new Text('账号设置'),
),
body: ListView(
children: <Widget>[
ListTile(
title: Text(
'账号',
style: TextStyle(fontSize: 20, color: Colors.black),
),
trailing: Text(
'weizhen_zhao@163.com',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'绑定手机号',
),
subtitle: Text(
'绑定成功后可通过手机号快速登录',
style: TextStyle(
color: Colors.grey,
fontSize: 12,
),
),
trailing: Container(
width: 80,
height: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'去绑定',
style: TextStyle(color: Colors.red),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'头像',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
CircleAvatar(
child: Image.asset('assets/images/daily_economic_news.png'),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'昵称',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'有态度的网友阿伟',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'生日',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'1980-01-01',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'生日',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'1980-01-01',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'性别',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'男',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
SwitchListTile(
value: init_value,
onChanged: (bool value) {
setState(() {
init_value = !init_value;
});
},
subtitle: Text(
'其他网友不会看到你的用户名,头像和个人主页',
style: TextStyle(
color: Colors.grey,
fontSize: 12,
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'跟帖设备名称',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'小米8',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
// Divider(
// thickness: 1,
// color: Colors.grey[300],
// ),
ListTile(
title: Text(
'我的等级',
),
trailing: Container(
width: 80,
height: 80,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'LV0 跟帖局科员',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.grey[400],
)
],
),
),
),
Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.red, borderRadius: BorderRadius.circular(30.0)),
child: Center(
child: Text(
'登出',
style: TextStyle(color: Colors.white, fontSize: 15),
),
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part1/SquarePage.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SquarePage extends StatefulWidget {
@override
_SquarePageState createState() => _SquarePageState();
}
class _SquarePageState extends State<SquarePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text('圈子-广场'),
),
body: buildGridView(),
);
}
Widget buildGridView() {
return GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1 / 1.4,
),
children: <Widget>[
buildItems('assets/images/daily_economic_news.png','每日经济新闻','28.1w关注'),
buildItems('assets/images/family_it.png','IT之家','33.1w关注'),
buildItems('assets/images/new_peking_news.png','新北京新闻','34.1w关注'),
buildItems('assets/images/weekly_chinese_news.png','中国新闻周报','35.1w关注'),
buildItems('assets/images/daily_economic_news.png','每日经济新闻','28.1w关注'),
buildItems('assets/images/family_it.png','IT之家','33.1w关注'),
buildItems('assets/images/new_peking_news.png','新北京新闻','34.1w关注'),
buildItems('assets/images/weekly_chinese_news.png','中国新闻周报','35.1w关注'),
buildItems('assets/images/daily_economic_news.png','每日经济新闻','28.1w关注'),
buildItems('assets/images/family_it.png','IT之家','33.1w关注'),
buildItems('assets/images/new_peking_news.png','新北京新闻','34.1w关注'),
buildItems('assets/images/weekly_chinese_news.png','中国新闻周报','35.1w关注'),
],
);
}
Widget buildItems(String path,String text2,String text3) {
// return Padding(
// padding: const EdgeInsets.all(10.0),
// child: ClipRRect(
// borderRadius: BorderRadius.circular(10.0),//圆角矩形
// child: Image.asset(
// path,
// fit: BoxFit.fitHeight,
// ),
// ),
// );
return Column(
children: <Widget>[
Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0), //圆角矩形
child: Image.asset(
path,
fit: BoxFit.fitHeight,
),
),
),
//第二部分
// Padding(
// padding: const EdgeInsets.all(13),
// child: Align(
// alignment: Alignment.topRight,
// child: Icon(
// Icons.add_circle,
// color: Colors.red,
// size: 20,
// ),
// ),
// )
Positioned(
top: 10,
right: 13,
child: Icon(
Icons.add_circle,
color: Colors.red,
size: 20,
),
)
],
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Align(
alignment: Alignment.center,
child: Text(
text2,
style: TextStyle(
fontSize: 13,
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Align(
alignment: Alignment.center,
child: Text(
text3,
style: TextStyle(
fontSize: 13,
color: Colors.grey[400],
),
),
),
),
],
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/TabContentsPage.dart
|
import 'package:flutter_news_netbase/part1/SmallVideoPage.dart';
import 'package:flutter_news_netbase/part2/RecentPage.dart';
import 'package:flutter/material.dart';
List<Widget> data=[
RecentPage(),
Center(child: Text('关注'),),
Center(child: Text('头条'),),
Center(child: Text('视频'),),
Center(child: Text('娱乐'),),
Center(child: Text('体育'),),
Center(child:Text('新时代'),),
Center(child: Text('要闻'),),
Center(child: Text('段子'),),
Center(child: Text('知否'),),
Center(child: Text('上海'),),
Center(child: Text('公开课'),),
Center(child: Text('圈子'),),
Center(child: Text('财经'),),
Center(child: Text('科技'),),
Center(child: Text('汽车'),),
Center(child: Text('网易号'),),
Center(child: Text('军事'),),
Center(child: Text('时尚'),),
Center(child: Text('跟帖'),),
Center(child: Text('直播'),),
Center(child: Text('图片'),),
Center(child: Text('小视频'),),
Center(child: Text('NBA'),),
Center(child: Text('热点'),),
];
List<Widget> videoTabData = [
Center(child: Text('推荐'),),
SmallVideoPage(key:ObjectKey(SmallVideoPage())),
Center(child: Text('榜单'),),
Center(child: Text('超级IP'),),
Center(child: Text('新衣人'),),
Center(child: Text('百年影像'),),
Center(child: Text('播单'),),
Center(child: Text('搞笑'),),
Center(child: Text('影视'),),
Center(child: Text('综艺'),),
Center(child: Text('音乐'),),
Center(child: Text('现场'),),
Center(child: Text('黑科技'),),
Center(child: Text('小品'),),
Center(child: Text('萌宠'),),
Center(child: Text('军武'),),
Center(child: Text('猎奇'),),
Center(child: Text('二次元'),),
];
List<String> videoTabsLabels=[
'推荐',
'小视频',
'榜单',
'超级IP',
'新衣人',
'百年影像',
'播单',
'搞笑',
'影视',
'综艺',
'音乐',
'现场',
'黑科技',
'小品',
'萌宠',
'军武',
'猎奇',
'二次元'
];
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/RecentPage.dart
|
import 'package:flutter/material.dart';
class RecentPage extends StatefulWidget {
@override
_RecentPageState createState() => _RecentPageState();
}
class _RecentPageState extends State<RecentPage> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
ListTile(
title: Text(
'最近浏览',
style: TextStyle(color: Colors.black, fontSize: 14),
),
trailing: Container(
width: 100,
child: GestureDetector(
onTap: () {
print('进入我的关注页面');
},
child: Row(
children: <Widget>[
Text(
'查看我的关注',
style: TextStyle(color: Colors.grey, fontSize: 12),
),
Icon(
Icons.keyboard_arrow_right,
color: Colors.grey,
)
],
),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
buildContents(
'assets/images/daily_economic_news.png', 'item1', Colors.red),
buildContents(
'assets/images/family_it.png', 'item2', Colors.blue),
buildContents('assets/images/weekly_chinese_news.png', 'item3',
Colors.orange),
buildContents(
'assets/images/new_peking_news.png', 'item4', Colors.green),
buildContents(
'assets/images/family_it.png', 'item2', Colors.blue),
],
),
],
),
);
}
Widget buildContents(String path, String text, Color color) {
return GestureDetector(
onTap: () {
print('进入了item的点击事件');
},
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
child: Image.asset(
path,
width: 30,
height: 30,
fit: BoxFit.fill,
),
backgroundColor: color,
radius: 30,
),
),
Positioned(
right: 18,
bottom: 10,
child: Container(
width: 13,
height: 13,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.all(
Radius.circular(10),
)),
child: Text(
'★',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 11,
color: Colors.white,
),
),
),
),
text == 'item2'
? Positioned(
right: 10,
bottom: 10,
child: Container(
width: 13,
height: 13,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.all(
Radius.circular(10),
)),
child: Text(
'V',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
color: Colors.white,
),
),
),
)
: Container(),
],
),
Text(
text,
style: TextStyle(color: Colors.grey, fontSize: 12),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/AIItemsPage.dart
|
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:reorderables/reorderables.dart';
class AIItemsPage extends StatefulWidget {
@override
_AIItemsPageState createState() => _AIItemsPageState();
}
class _AIItemsPageState extends State<AIItemsPage> {
List<String> datas = [
'关注',
'头条',
'视频',
'娱乐',
'体育',
'新时代',
'要闻',
'段子',
'知否',
'上海',
'公开课',
'圈子',
'财经',
'科技',
'汽车',
'网易号',
'军事',
'时尚',
'跟帖',
'直播',
'图片',
'小视频',
'NBA',
'热点',
'房产',
'股票',
'轻松一刻',
'历史',
'家居',
'播单',
'独家',
'游戏',
'健康',
'航空',
'小说',
'热度'
];
@override
void initState() {
super.initState();
_tiles = [
buildItems('关注'),
buildItems('头条'),
buildItems('视频'),
buildItems('娱乐'),
buildItems('体育'),
buildItems('新时代'),
buildItems('要闻'),
buildItems('段子'),
buildItems('知否'),
buildItems('上海'),
buildItems('公开课'),
buildItems('圈子'),
buildItems('财经'),
buildItems('科技'),
buildItems('汽车'),
buildItems('网易号'),
buildItems('军事'),
buildItems('时尚'),
buildItems('跟帖'),
buildItems('直播'),
buildItems('图片'),
buildItems('小视频'),
buildItems('NBA'),
buildItems('热点'),
buildItems('房产'),
buildItems('股票'),
buildItems('轻松一刻'),
buildItems('历史'),
buildItems('家居'),
buildItems('播单'),
buildItems('独家'),
buildItems('游戏'),
buildItems('健康'),
buildItems('航空'),
buildItems('小说'),
buildItems('热度'),
];
}
List<Widget> _tiles;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text(
'所有栏目',
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
backgroundColor: Colors.white,
elevation: 0,
leading: Container(),
centerTitle: true,
actions: <Widget>[
InkWell(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Icon(
Icons.close,
color: Colors.black,
),
),
onTap: () {
Navigator.of(context).pop(0);
},
)
],
),
body: buildContents(),
);
}
Widget buildContents() {
return ListView(
children: <Widget>[
Container(
width: 400,
height: 50,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0, 0, 0),
child: Text(
'我的栏目',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0, 0, 0),
child: Text(
'拖动排序',
style: TextStyle(
fontSize: 13,
),
),
),
],
),
Positioned(
top: 10,
right: 10,
child: Container(
width: 50,
height: 25,
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(20),
)),
child: Center(
child: Text(
'完成',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
),
),
),
],
),
),
buildContentsAll(),
RaisedButton(
child: Text(
'新增',
),
color: Colors.blue,
onPressed: () {
setState(() {
Random random = Random();
int index = random.nextInt(datas.length);
var newItem = buildItems(datas[index]);
_tiles.add(newItem);
});
},
),
RaisedButton(
child: Text(
'删除',
),
color: Colors.blue,
onPressed: () {
setState(() {
_tiles.removeAt(datas.length - 1);
});
},
)
],
);
}
Widget buildContentsAll() {
return ReorderableWrap(
alignment: WrapAlignment.spaceEvenly,
spacing: 3.0,
//水平方向间距
runSpacing: 4.0,
//垂直方向间距
padding: EdgeInsets.all(5),
//内边距
children: _tiles,
onReorder: onReorder,
onNoReorder: (index) {
//this callback is optional
print('滑动结束时位置的索引:$index');
},
onReorderStarted: (index) {
//this callback is optional
print('滑动开始时位置的索引:$index');
});
}
void onReorder(int oldIndex, int newIndex) {
//删除旧位置的索引
Widget data = _tiles.removeAt(oldIndex);
//插入新位置的widget
_tiles.insert(newIndex, data);
print('滑动过程中,旧位置的索引:$oldIndex,新位置的索引$newIndex');
}
Widget buildItems(String data) {
return GestureDetector(
onTap: () {
print('点击了item ${datas.indexOf(data)}');
Navigator.of(context).pop(datas.indexOf(data));
},
child: Container(
margin: EdgeInsets.fromLTRB(1, 1, 0, 0),
width: 70,
height: 50,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Icon(
Icons.close,
color: Colors.grey[400],
size: 14,
),
Text(
data,
style: TextStyle(
color: data == '头条' ? Colors.red : Colors.black,
fontSize: 10,
),
)
],
),
),
);
}
// Widget buildContents() {
// double width = MediaQuery.of(context).size.width;
//
// List<String> datas = [
// '关注',
// '头条',
// '视频',
// '娱乐',
// '体育',
// '新时代',
// '要闻',
// '段子',
// '知否',
// '上海',
// '公开课',
// '圈子',
// '财经',
// '科技',
// '汽车',
// '网易号',
// '军事',
// '时尚',
// '跟帖',
// '直播',
// '图片',
// '小视频',
// 'NBA',
// '热点',
// '房产',
// '股票',
// '轻松一刻',
// '历史',
// '家居',
// '播单',
// '独家',
// '游戏',
// '健康',
// '航空',
// '小说',
// '热度'
// ];
//
// return SizedBox(
// width: width,
// child: Wrap(
// spacing: 10.0,
// runSpacing: 10.0,
// direction: Axis.horizontal,
// verticalDirection: VerticalDirection.down,
// alignment: WrapAlignment.spaceEvenly,
// crossAxisAlignment: WrapCrossAlignment.start,
// children: datas.map((data) {
// return Chip(
// label: Container(
// child: Center(
// child: Text(data),
// ),
// width: 55,
// ),
// labelStyle: TextStyle(
// color: data == '头条' ? Colors.red : Colors.black87,
// fontSize: 13,
// ),
// backgroundColor: Colors.white,
// shape: RoundedRectangleBorder(
// side: BorderSide(
// color: Colors.grey[200],
// width: 1.0,
// style: BorderStyle.solid,
// ),
// borderRadius: BorderRadius.circular(20),
// ),
// );
// }).toList(),
// ),
// );
// }
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/HomePage.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/content2/TabContentsPage.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_news_netbase/part2/SearchBar.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
//首页
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
int result = 0;
TabController tabController;
final List<Tab> tabs = <Tab>[
Tab(
text: '关注',
),
Tab(text: '头条'),
Tab(text: '视频'),
Tab(text: '娱乐'),
Tab(text: '体育'),
Tab(text: '新时代'),
Tab(text: '要闻'),
Tab(text: '段子'),
Tab(text: '知否'),
Tab(text: '上海'),
Tab(text: '公开课'),
Tab(text: '圈子'),
Tab(text: '财经'),
Tab(text: '科技'),
Tab(text: '汽车'),
Tab(text: '网易号'),
Tab(text: '军事'),
Tab(text: '时尚'),
Tab(text: '跟帖'),
Tab(text: '直播'),
Tab(text: '图片'),
Tab(text: '小视频'),
Tab(
text: 'NBA',
),
Tab(
text: '热点',
)
];
@override
Widget build(BuildContext context) {
setState(() {
tabController.index = result;
});
return Scaffold(
appBar: buildTitleBar(),
body: TabBarView(
controller: tabController,
children: data,
),
);
}
Widget buildTitleBar() {
return AppBar(
//设置颜色
backgroundColor: Colors.red,
// 主题内容
title: Container(
decoration: BoxDecoration(
color: Colors.redAccent,
border: Border.all(color: Colors.redAccent, width: 2),
borderRadius: BorderRadius.circular(30),
),
//margin: EdgeInsets.symmetric(vertical: 8, horizontal: 0),
//padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.search,
size: 15,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: GestureDetector(
onTap: () {
routePathAnim(
context,
SearchBar(
Colors.white, //状态栏的颜色
onCancelSearch: onCancelSearch,
onSearchQueryChanged: onSearchQueryChange,
),
showAnim: true,
duration: 300,
type: Type.RIGHT_TO_LEFT);
// Navigator.of(context).push(
// PageRouteBuilder(
// pageBuilder: (BuildContext context,
// Animation<double> animation,
// Animation<double> secondaryAnimation) {
// return SearchBar(
// Colors.white, //状态栏的颜色
// onCancelSearch: onCancelSearch,
// onSearchQueryChanged: onSearchQueryChange,
// );
// },
// transitionsBuilder: (BuildContext context,
// Animation<double> animation,
// Animation<double> secondaryAnimation,
// Widget child) {
// return SlideTransition(
// position: Tween(
// begin: Offset(1.0, 0.0),
// end: Offset(0.0, 0.0))
// .animate(animation),
// child: child,
// );
// },
// transitionDuration: Duration(milliseconds: 300),
// ),
// );
},
child: Text(
'最新劲爆新闻实时推送',
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
)
],
),
),
//右侧
actions: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 5),
child: InkWell(
onTap: () {
Navigator.of(context).pushNamed('/hot');
},
child: Icon(
Icons.whatshot,
size: 20,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 5),
child: InkWell(
onTap: () {
Navigator.of(context).pushNamed('/notice');
},
child: Icon(
Icons.chat,
size: 20,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 5),
child: InkWell(
onTap: () {
pushData(context).then((data) {
result = data;
});
},
child: Icon(
Icons.format_list_bulleted,
size: 20,
),
),
)
],
bottom: TabBar(
// Key key,
// @required this.tabs,
// this.controller,
// this.isScrollable = false,
// this.indicatorColor,
// this.indicatorWeight = 2.0,
// this.indicatorPadding = EdgeInsets.zero,
// this.indicator,
// this.indicatorSize,
// this.labelColor,
// this.labelStyle,
// this.labelPadding,
// this.unselectedLabelColor,
// this.unselectedLabelStyle,
// this.dragStartBehavior = DragStartBehavior.start,
// this.onTap,
tabs: tabs,
controller: tabController,
isScrollable: true,
//表示是否可以滑动
indicatorColor: Colors.white,
//下划线的颜色
indicatorWeight: 2.0,
//下划线的粗细
indicatorPadding: EdgeInsets.all(10),
//下划线的内边距
indicatorSize: TabBarIndicatorSize.tab,
//紧跟着文字
labelColor: Colors.white,
//文字的颜色
labelStyle: TextStyle(color: Colors.white, fontSize: 20),
labelPadding: EdgeInsets.all(5.0),
//文字的内边距
unselectedLabelColor: Colors.yellow,
//未选中时的颜色
unselectedLabelStyle: TextStyle(color: Colors.green, fontSize: 18),
onTap: (index) {
print('点击了$index');
},
),
);
}
Future<int> pushData(BuildContext context) async {
var data = await Navigator.of(context).pushNamed('/all_items');
return data;
}
void onCancelSearch() {}
void onSearchQueryChange(String data) {}
@override
void dispose() {
tabController.dispose();
super.dispose();
}
@override
void initState() {
tabController = TabController(length: tabs.length, vsync: this);
super.initState();
result = 0;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/DrawerPage.dart
|
import 'package:flutter/material.dart';
class DrawerPage extends StatefulWidget {
@override
_DrawerPageState createState() => _DrawerPageState();
}
class _DrawerPageState extends State<DrawerPage> {
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return SizedBox(
child: new Scaffold(
backgroundColor: Colors.blue,
body: Padding(
padding: MediaQuery.of(context).padding,
child: Text('\n 侧滑面板'),
),
),
width: width * 4 / 5,
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib
|
mirrored_repositories/flutter_news_netbase/lib/part2/SearchBar.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
typedef SearchCallback = void Function(String data);
class SearchBar extends StatefulWidget {
SearchBar(Color statusBarColor,
{Key key, //操作状态有关的,操作状态
@required this.onCancelSearch, //回调函数
@required this.onSearchQueryChanged //回调函数
})
: super(key: key);
final VoidCallback onCancelSearch; //系统自带空回调
final SearchCallback onSearchQueryChanged; //有返回结果的回调函数
@override
_SearchBarState createState() => _SearchBarState();
}
class _SearchBarState extends State<SearchBar> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
//设置状态栏图标和文字颜色
brightness: Brightness.light,
backgroundColor: Colors.white,
title: TitleContents(widget.onSearchQueryChanged),
titleSpacing: 0,
//文字的边距
leading: IconButton(
//左边的导航栏
icon: Icon(
Icons.keyboard_arrow_left,
size: 35,
color: Colors.grey[100],
),
onPressed: (){
Navigator.of(context).pop();
},
),
),
);
}
}
class TitleContents extends StatefulWidget {
TitleContents(this.onSearchQueryChanged);
SearchCallback onSearchQueryChanged;
@override
_TitleContentsState createState() => _TitleContentsState();
}
class _TitleContentsState extends State<TitleContents> {
TextEditingController _searchFieldController = TextEditingController();
@override
Widget build(BuildContext context) {
return Container(
height: 50,
width: 350,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 30,
width: 250,
child: TextField(
controller: _searchFieldController,
//键盘类型
keyboardType: TextInputType.datetime,
//键盘主题色
keyboardAppearance: Brightness.light,
//键盘回车键的按钮类型 (搜索,发送,完成)
textInputAction: TextInputAction.search,
//选择键盘输入的类型(英文大写,英文小写,文字,数字等)
textCapitalization: TextCapitalization.words,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.grey[400],
),
borderRadius: BorderRadius.all(Radius.circular(30)),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.grey[400],
),
borderRadius: BorderRadius.all(Radius.circular(30)),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.grey[400],
),
borderRadius: BorderRadius.all(Radius.circular(30)),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.red,
),
borderRadius: BorderRadius.all(Radius.circular(30)),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.red,
),
borderRadius: BorderRadius.all(Radius.circular(30)),
),
contentPadding: EdgeInsets.zero,
///前缀
prefixIcon: Icon(
Icons.search,
color: Colors.grey,
size: 20,
),
///后缀
suffixIcon: InkWell(
child: Icon(
Icons.close,
color: Colors.grey,
size: 20,
),
onTap: clearSearhQuery,
),
///输入框隐藏的提示文本
hintText: '最劲爆新闻实时推送',
hintStyle: TextStyle(color: Colors.grey, fontSize: 14),
hintMaxLines: 1,
enabled: true,
///表示要启用文本输入框
),
cursorColor: Colors.red,
///表示光标的颜色为红色
autofocus: true,
///是否自动聚焦
style: TextStyle(color: Colors.black12),
onChanged: widget.onSearchQueryChanged,
),
),
Padding(
padding: EdgeInsets.only(left: 10, right: 10),
child: GestureDetector(
onTap: () {
print('点击了搜索按钮');
},
child: Text(
'搜索',
style: TextStyle(color: Colors.black54, fontSize: 15),
),
),
),
],
),
);
}
clearSearhQuery() {
_searchFieldController.clear();
widget.onSearchQueryChanged('');
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/gestures/GestureUtil.dart
|
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class GestureUtil extends TapGestureRecognizer {
@override
void rejectGesture(int pointer) {
// super.rejectGesture(pointer);
acceptGesture(pointer);
}
}
// 创建手势识别器(能够决事件冲突的手势识别器)不是GestureDetector
Widget buildGesture(GestureTapCallback onTap, Widget child) {
return RawGestureDetector(
gestures: {
GestureUtil: GestureRecognizerFactoryWithHandlers<GestureUtil>(
() => GestureUtil(),
(GestureUtil instance) {
instance.onTap = onTap;
},
),
},
behavior: HitTestBehavior.opaque,
child: child,
);
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/view/TabCommon.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_news_netbase/part2/TabContentsPage.dart';
import 'package:flutter_news_netbase/part2/SearchBar.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
class TabCommon extends StatefulWidget {
TabController _tabController;
int _result = 1;
List<Tab> _tabs = [];
List<String> tabStrData = <String>[];
List<Widget> tabWidgets = <Widget>[];
// Widget titleWidgets;
Color indicatorColor;
double indicatorWeight = 2;
EdgeInsets indicatorPadding;
TabBarIndicatorSize indicatorSize;
Color labelColor;
TextStyle labelStyle;
Color unselectedLabelColor;
DragStartBehavior dragStartBehavior;
TextStyle unselectedLabelStyle;
Color backgroundColor;
bool isShowSearIcon;
double widths;
bool showContainer;
Color containerBorderColor;
bool isScrollable = true;
TabCommon(
this.tabStrData,
this.tabWidgets, {
this.backgroundColor,
this.isShowSearIcon,
this.indicatorColor,
this.indicatorWeight,
this.indicatorPadding,
this.indicatorSize,
this.labelColor,
this.labelStyle,
this.unselectedLabelColor,
this.unselectedLabelStyle,
this.dragStartBehavior,
Key key,
this.showContainer = false,
this.containerBorderColor,
this.isScrollable,
}) : super(key: key);
@override
_TabCommonState createState() => _TabCommonState();
}
// 通用的一个Tab页面,Tab页面的基类
class _TabCommonState extends State<TabCommon>
with SingleTickerProviderStateMixin {
Tab currentTab;
@override
void initState() {
super.initState();
widget._tabController = TabController(
length: widget.tabWidgets.length,
vsync: this,
initialIndex: widget._result);
widget._tabs = widget.tabStrData.map((item) {
if (widget.showContainer == true) {
return Tab(
child: Container(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
decoration: new BoxDecoration(
border: new Border.all(
color: widget.containerBorderColor == null
? Colors.grey
: widget.containerBorderColor,
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Text(item),
),
);
} else {
currentTab = Tab(
text: item,
);
return currentTab;
}
}).toList();
}
@override
Widget build(BuildContext context) {
widget.widths = MediaQuery.of(context).size.width;
setState(() {
widget._tabController.index = widget._result;
});
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
title: buildCommonTitle(tabs: widget._tabs, isShowSearIcon: true),
),
body: TabBarView(
children: widget.tabWidgets == null
? buildCommonTitle(tabs: widget._tabs, isShowSearIcon: true)
: widget.tabWidgets,
controller: widget._tabController,
),
);
}
@override
void dispose() {
super.dispose();
widget._tabController.dispose();
}
@override
onSearchQueryChanged(String query) {
print('点击 search $query');
}
onCancelSearch() {
onSearchQueryChanged('');
Navigator.of(context).pop();
}
Widget buildTabBar(List<Tab> tabs) {
return TabBar(
key: PageStorageKey<Tab>(currentTab),
tabs: tabs,
controller: widget._tabController,
isScrollable: widget.isScrollable,
indicatorColor:
widget.indicatorColor == null ? Colors.black : widget.indicatorColor,
indicatorWeight:
widget.indicatorWeight == null ? 2.0 : widget.indicatorWeight,
indicatorPadding: widget.indicatorPadding == null
? EdgeInsets.all(0)
: widget.indicatorPadding,
indicatorSize: widget.indicatorSize == null
? TabBarIndicatorSize.tab
: widget.indicatorSize,
labelColor: widget.labelColor == null ? Colors.black : widget.labelColor,
labelStyle: widget.labelStyle == null
? TextStyle(color: Colors.black, fontSize: 14)
: widget.labelStyle,
unselectedLabelStyle: widget.unselectedLabelStyle == null
? TextStyle(color: Colors.orange, fontSize: 14)
: widget.unselectedLabelStyle,
dragStartBehavior: widget.dragStartBehavior == null
? DragStartBehavior.start
: widget.dragStartBehavior,
onTap: (index) {
print('点击了 $index');
},
);
}
Widget buildCommonTitle({
Key key,
@required List<Widget> tabs,
bool isShowSearIcon = false,
TabController controller,
bool isScrollable = true,
Color indicatorColor,
double indicatorWeight = 2.0,
EdgeInsetsGeometry indicatorPadding = EdgeInsets.zero,
Decoration indicator,
TabBarIndicatorSize indicatorSize,
Color labelColor,
TextStyle labelStyle,
EdgeInsetsGeometry labelPadding,
Color unselectedLabelColor,
TextStyle unselectedLabelStyle,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
ValueChanged<int> onTap,
}) {
if (isShowSearIcon == true) {
return Container(
width: widget.widths,
height: 50,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: buildTabBar(widget._tabs),
flex: 9,
),
Expanded(
child: InkWell(
onTap: () {
routePathAnim(
context,
SearchBar(
Colors.white,
onCancelSearch: onCancelSearch,
onSearchQueryChanged: onSearchQueryChanged,
),
showAnim: true,
type: Type.RIGHT_TO_LEFT,
duration: 800);
},
child: Container(
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Icon(
Icons.search,
size: 25,
color: Colors.grey,
),
),
),
flex: 1,
)
],
),
);
} else {
buildTabBar(widget._tabs);
}
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/circle/CircleSquarePage.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/utils/NumberUtil.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
import 'package:flutter_news_netbase/part2/circle/CircleSquarePageDetails.dart';
import 'package:flutter_news_netbase/part2/model/CircleSquareModel.dart';
class CircleSquarePage extends StatefulWidget {
@override
_CircleSquarePageState createState() => _CircleSquarePageState();
}
class _CircleSquarePageState extends State<CircleSquarePage> {
List<Widget> datas;
@override
void initState() {
// TODO: implement initState
super.initState();
datas = <Widget>[];
}
@override
Widget build(BuildContext context) {
double width =MediaQuery.of(context).size.width;
return Scaffold(
body: FutureBuilder(
future: rootBundle.loadString('assets/circle_square.json'),
builder: (BuildContext context, AsyncSnapshot snap) {
if (snap.hasData) {
CircleSquareModel model = circleSquareModelFromJson(snap.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
Widget widget = buildContents(bean);
datas.add(widget);
}
return ListView(
children: datas,
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
Widget buildContents(Data data) {
List<Widget> childrens = <Widget>[];
for (int j = 0; j < data.contents.length; j++) {
Contents contents = data.contents[j];
String followCount =
parseNumbers('${contents.followCount}', '人关注', fractionDigits: 1);
Widget child = buildItems(contents.img, contents.title, followCount);
if(child !=null){
childrens.add(child);
}
}
return Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
// 标题
child: Text(
data.infos,
style: TextStyle(
fontSize: 13,
),
),
),
),
GestureDetector(
onTap: () {
print('点击了圈子广场,进入详情页面');
gotoNewPage(context, CircleSquarePageDetails(data));
},
child: GridView.count(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
crossAxisCount: 3,
crossAxisSpacing: 3,
mainAxisSpacing: 3,
childAspectRatio: 1 / 1.3,
children: childrens,
),
),
],
),
);
}
Widget buildItems(String path, String text2, String text3) {
return Container(
width: 80,
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.network(path,
width: 80, height: 80, fit: BoxFit.fill),
),
),
Positioned(
top: 13,
right: 13,
child: Icon(
Icons.add_circle,
color: Colors.red,
size: 20,
),
)
],
),
Align(
alignment: Alignment.center,
child: Container(
width: 80,
padding: EdgeInsets.fromLTRB(0, 3, 0, 3),
// 描述
child: Text(
text2,
maxLines: 2,
style: TextStyle(
fontSize: 13,
// 【全局主题设置】:
// color: theme.getThemeData.textTheme.display2.color,
),
),
),
),
Align(
alignment: Alignment.center,
child: Container(
width: 80,
child: Text(
text3,
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/circle/CircleRecommendPage.dart
|
import 'package:flutter/material.dart';
class CircleRecommendPage extends StatefulWidget {
@override
_CircleRecommendPageState createState() => _CircleRecommendPageState();
}
class _CircleRecommendPageState extends State<CircleRecommendPage> {
@override
Widget build(BuildContext context) {
return Text('搜索');
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/circle/CirclePage.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_news_netbase/part2/view/TabCommon.dart';
import 'package:flutter_news_netbase/part2/content2/TabContentsPage.dart';
class CirclePage extends StatefulWidget {
@override
_CirclePageState createState() => _CirclePageState();
}
class _CirclePageState extends State<CirclePage> {
TabCommon tabCommon;
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
tabCommon = TabCommon(
circleTabsLabels,
circleTabData,
showContainer: true,
containerBorderColor: Colors.red,
key: ObjectKey(CirclePage()),
backgroundColor: Colors.white,
isShowSearIcon: false,
isScrollable: true,
indicatorColor: Colors.white,
indicatorWeight: 2.0,
indicatorPadding: EdgeInsets.all(0),
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Colors.black,
labelStyle: TextStyle(
color: Colors.black, fontWeight: FontWeight.bold, fontSize: 25),
unselectedLabelColor: Colors.grey,
unselectedLabelStyle: TextStyle(color: Colors.grey, fontSize: 14),
dragStartBehavior: DragStartBehavior.start);
return tabCommon;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/circle/CircleSquarePageDetails.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/model/CircleSquareModel.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class CircleSquarePageDetails extends StatefulWidget {
Data data;
CircleSquarePageDetails(this.data);
@override
CircleSquarePageDetailsState createState() =>
new CircleSquarePageDetailsState();
}
class CircleSquarePageDetailsState extends State<CircleSquarePageDetails> {
FlutterWebviewPlugin flutterWebViewPlugin;
// String urls = 'https://www.baidu.com';
// ignore: prefer_collection_literals
final Set<JavascriptChannel> jsChannels = [
JavascriptChannel(
name: 'Print',
onMessageReceived: (JavascriptMessage message) {
print(message.message);
}),
].toSet();
@override
void initState() {
super.initState();
flutterWebViewPlugin = FlutterWebviewPlugin();
}
@override
Widget build(BuildContext context) {
// return new Scaffold(
// appBar: new AppBar(
// title: new Text('实时热榜详情页'),
// ),
// );
double width = MediaQuery.of(context).size.width;
flutterWebViewPlugin.onScrollYChanged.listen((double y) {
if (mounted) {
setState(() {
print('Y轴滑动的距离是: $y');
});
}
});
flutterWebViewPlugin.onProgressChanged.listen((double progress) {
if (mounted) {
setState(() {
print('当前网页加载进度是: $progress');
});
}
});
Contents contents;
for (int j = 0; j < widget.data.contents.length; j++) {
contents = widget.data.contents[j];
}
return WebviewScaffold(
url: contents.url,
// javascriptChannels: jsChannels,
// mediaPlaybackRequiresUserGesture: false,
withZoom: true,
withLocalStorage: true,
hidden: false,
// userAgent:
// 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Mobile Safari/537.36',
initialChild: Container(
width: width,
color: Colors.grey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(),
Text('正在玩命加载中...'),
],
),
),
);
}
@override
void dispose() {
flutterWebViewPlugin.dispose();
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/routes/RouteManager.dart
|
import 'package:flutter/material.dart';
//专场动画的自定义 时长,动画类型都可以自定义
void routePathAnim(BuildContext context, Widget newPage,
{bool showAnim = false,
Type type = Type.RIGHT_TO_LEFT,
int duration = 100}) {
if (showAnim) {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return newPage;
},
transitionsBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
double dx = 1.0;
double dy = 0.0;
double endX = 0.0;
double endY = 0.0;
switch (type) {
case Type.BOTTOM_TO_TOP:
dx = 0.0;
dy = 1.0;
endX = 0.0;
endY = 0.0;
break;
case Type.LEFT_TO_RIGHT:
dx = 0.0;
dy = 0.0;
endX = 0.0;
endY = 1.0;
break;
case Type.RIGHT_TO_LEFT:
dx = 1.0;
dy = 0.0;
endX = 0.0;
endY = 0.0;
break;
case Type.TOP_TO_BOTTOM:
dx = 0.0;
dy = 0.0;
endX = 0.0;
endY = 1.0;
break;
}
return SlideTransition(
position: Tween(begin: Offset(dx, dy), end: Offset(endX, endY))
.animate(animation),
child: child,
);
},
transitionDuration: Duration(milliseconds: duration),
),
);
} else {
//去掉路由动画
Navigator.of(context)
.push(PageRouteBuilder(pageBuilder: (_, __, ___) => newPage));
}
}
enum Type {
//从下到上
BOTTOM_TO_TOP,
//从上到下
TOP_TO_BOTTOM,
//从右到左
RIGHT_TO_LEFT,
//从左到右
LEFT_TO_RIGHT,
}
//普通路由跳转
void gotoNewPage(BuildContext context, Widget newPage) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return newPage;
},
),
);
}
//命名路由
void gotoNewPage2(BuildContext context, String routeName) {
Navigator.of(context).pushNamed(routeName);
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/routes/VideoTabPage.dart
|
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/TabContentsPage.dart';
import 'package:flutter_news_netbase/part2/SearchBar.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
class VideoTabPage extends StatefulWidget {
@override
_VideoTabPageState createState() => _VideoTabPageState();
}
class _VideoTabPageState extends State<VideoTabPage>
with SingleTickerProviderStateMixin {
TabController tabController;
int result = 1;
List<Tab> tabs = [];
@override
void initState() {
super.initState();
tabController = TabController(
length: videoTabData.length, vsync: this, initialIndex: 0);
result = 1;
tabs = videoTabsLabels.map((item) {
return Tab(
text: item,
);
}).toList();
}
void onCancelSearch() {}
void onSearchQueryChanged(String query) {}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
setState(() {
tabController.index = result;
});
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
title: Container(
width: width,
height: 50,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: TabBar(
tabs: tabs,
controller: tabController,
isScrollable: true,
indicatorColor: Colors.white,
indicatorWeight: 2.0,
indicatorPadding: EdgeInsets.all(0),
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Colors.black,
labelStyle: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 14),
unselectedLabelStyle:
TextStyle(color: Colors.black, fontSize: 14),
dragStartBehavior: DragStartBehavior.start,
onTap: (index) {
print('点击了 $index');
},
),
flex: 9,
),
Expanded(
child: InkWell(
onTap: () {
routePathAnim(
context,
SearchBar(
Colors.white,
onCancelSearch: onCancelSearch,
onSearchQueryChanged: onSearchQueryChanged,
),
showAnim: true,
type: Type.RIGHT_TO_LEFT,
duration: 800);
},
child: Container(
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Icon(
Icons.search,
size: 25,
color: Colors.grey,
),
),
),
flex: 1,
)
],
),
)
//
),
body: TabBarView(
children: videoTabData,
controller: tabController,
),
);
}
@override
void dispose() {
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/TabContentsPage.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/content2/HomeItemListPage.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageCurrent.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageComment.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageRecommend.dart';
import 'package:flutter_news_netbase/part2/circle/CircleRecommendPage.dart';
import 'package:flutter_news_netbase/part2/circle/CircleSquarePage.dart';
List<Widget> data = [
// RecentPage(),
// Center(child: Text('关注'),),
HomeItemListPage(),
Center(
child: Text('头条'),
),
Center(
child: Text('视频'),
),
Center(
child: Text('娱乐'),
),
Center(
child: Text('体育'),
),
Center(
child: Text('新时代'),
),
Center(
child: Text('要闻'),
),
Center(
child: Text('段子'),
),
Center(
child: Text('知否'),
),
Center(
child: Text('上海'),
),
Center(
child: Text('公开课'),
),
Center(
child: Text('圈子'),
),
Center(
child: Text('财经'),
),
Center(
child: Text('科技'),
),
Center(
child: Text('汽车'),
),
Center(
child: Text('网易号'),
),
Center(
child: Text('军事'),
),
Center(
child: Text('时尚'),
),
Center(
child: Text('跟帖'),
),
Center(
child: Text('直播'),
),
Center(
child: Text('图片'),
),
Center(
child: Text('小视频'),
),
Center(
child: Text('NBA'),
),
Center(
child: Text('热点'),
),
];
List<Widget> hotTabData = [
HotPageCurrent(),
HotPageComment(),
HotPageRecommend(),
];
List<String> hotTabsLabels = [
'实时热榜',
'跟帖热议',
'独家推荐',
];
List<String> circleTabsLabels = [
'推荐',
'广场',
];
List<Widget> circleTabData = [
CircleRecommendPage(),
CircleSquarePage(),
];
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageRecommend.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageRecommendDetails.dart';
import 'package:flutter_news_netbase/part2/model/HotRecommendModel.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
import 'package:flutter_news_netbase/part2/utils/NumberUtil.dart';
class HotPageRecommend extends StatefulWidget {
@override
_HotPageRecommendState createState() => _HotPageRecommendState();
}
class _HotPageRecommendState extends State<HotPageRecommend> {
List<Widget> datas;
@override
void initState() {
// TODO: implement initState
super.initState();
datas = <Widget>[];
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold(
body: FutureBuilder(
future: rootBundle.loadString('assets/hot_recommend.json'),
builder: (BuildContext context, AsyncSnapshot snap) {
if (snap.hasData) {
HotRecommendModel model = recommendModuleFromJson(snap.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
Widget widgets = GestureDetector(
onTap: () {
print('点击了独家推荐,进入详情页面');
gotoNewPage(context, HotPageRecommendDetails(bean));
},
child: Card(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Image.asset(
bean.img,
width: width,
height: 180,
fit: BoxFit.fill,
),
Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Text(
bean.title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.grey,
),
),
),
bean.contents.length != 0
? Container(
height: bean.contents == null ? 10 : 60,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Text(
bean.contents,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 16),
),
)
: Container(),
Padding(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: buildAuthorInfos(bean),
)
],
),
),
);
datas.add(widgets);
datas.add(Divider(
height: 10,
color: Colors.grey[400],
));
}
return ListView(
children: datas,
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
Widget buildAuthorInfos(Data bean) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
//用户
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
child: Text(
bean.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
//评论
buildCommentCountText(bean),
],
);
}
Widget buildCommentCountText(Data data) {
String result =
parseNumbers('${data.commentCount}', '跟帖', fractionDigits: 1);
String results = '';
if (parseNumber2Int('${data.commentCount}') >= 3000) {
String input = String.fromCharCodes(Runes('\u{1F525}'));
results = '${input}${result}';
return Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(5),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.red, width: 1),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.red),
),
);
} else {
results = result;
return Container(
padding: EdgeInsets.all(1),
margin: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
);
}
}
@override
void dispose() {
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageRecommendDetails.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/model/HotRecommendModel.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class HotPageRecommendDetails extends StatefulWidget {
Data data;
HotPageRecommendDetails(this.data);
FlutterWebviewPlugin flutterWebviewPlugin;
@override
_HotPageRecommendDetailsState createState() => _HotPageRecommendDetailsState();
}
class _HotPageRecommendDetailsState extends State<HotPageRecommendDetails> {
@override
void initState() {
super.initState();
widget.flutterWebviewPlugin = FlutterWebviewPlugin();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return WebviewScaffold(
url: widget.data.url,
withZoom: true, //是否可以缩放
withLocalStorage: true, //使用本地存储
hidden: false,
//userAgent: , //模拟浏览器
initialChild: Container(
color: Colors.grey,
width: width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
Text('正在玩命加载中...')
],
)
),
);
}
@override
void dispose(){
super.dispose();
widget.flutterWebviewPlugin.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPage.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/view/TabCommon.dart';
import 'package:flutter_news_netbase/part2/content2/TabContentsPage.dart';
class HotPage extends StatefulWidget {
@override
_HotPageState createState() => _HotPageState();
}
class _HotPageState extends State<HotPage> {
TabCommon tabCommon;
@override
void initState() {
// tabCommon =TabCommon(hotTabsLabels, hotTabData
}
@override
Widget build(BuildContext context) {
tabCommon = TabCommon(hotTabsLabels, hotTabData,
showContainer: true,
containerBorderColor: Colors.red,
key: ObjectKey(HotPage()),
backgroundColor: Colors.white,
isShowSearIcon: false,
isScrollable: true,
indicatorColor: Colors.white,
indicatorWeight: 2.0,
indicatorPadding: EdgeInsets.all(0),
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Colors.black,
labelStyle: TextStyle(
color: Colors.black, fontWeight: FontWeight.bold, fontSize: 25),
unselectedLabelColor: Colors.grey,
unselectedLabelStyle: TextStyle(color: Colors.grey, fontSize: 14),
dragStartBehavior: DragStartBehavior.start);
return tabCommon;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HomeItemListPage.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/RecentPage.dart';
import 'package:flutter_news_netbase/part2/model/NewsModel.dart';
class HomeItemListPage extends StatefulWidget {
@override
_HomeItemListPageState createState() => _HomeItemListPageState();
}
// 需要的字段
// title标题
// infos介绍
// tag标签 (置顶、、独家等)专题
// source 新闻来源 (报社,电台,电视台,网站,自媒体等)
// type类型 (可以用来判断item选用哪一种布局类型)
// thumb小图
// images 新闻配图(可能为空,也可能是多张)
// commentCount 评论数量 (跟帖)
// votecount 点赞数量
// replyCount 转发数量
class _HomeItemListPageState extends State<HomeItemListPage> {
List<Widget> children;
@override
Widget build(BuildContext context) {
// return ListView(
// children: children,
// );
return FutureBuilder(
future: rootBundle.loadString('assets/news.json'),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
//将数据封装成模型类,通过模型类来管理数据
NewsModel model = newsModuleFromJson(snapshot.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
//根据返回值动态添加UI
switch (bean.type) {
case "1":
Widget widget = buildItem1(bean);
children.add(widget);
children.add(
Divider(
height: 1,
color: Colors.grey,
),
);
break;
case "2":
Widget widget2 = buildItem2(bean);
children.add(widget2);
children.add(
Divider(
height: 1,
color: Colors.grey,
),
);
break;
case "3":
Widget widget3 = buildItem3(bean);
children.add(widget3);
children.add(
Divider(
height: 1,
color: Colors.grey,
),
);
break;
}
}
return ListView(
children: children,
);
} else {
return CircularProgressIndicator();
}
},
);
}
@override
void initState() {
super.initState();
children = <Widget>[];
children.add(RecentPage());
}
Widget buildItem1(Data bean) {
return Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
bean.title,
style: TextStyle(fontSize: 17),
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: buildTagText(bean),
),
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
bean.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
buildCommentCountText(bean.commentCount),
],
)
],
),
);
}
Widget buildTagText(Data bean) {
if (bean.tag != null) {
return Text(
bean.tag,
style: TextStyle(fontSize: 10, color: Colors.red),
);
} else {
return Text('');
}
}
Widget buildCommentCountText(String commentCount) {
if (int.parse(commentCount) >= 2000) {
return Container(
padding: EdgeInsets.all(1),
margin: EdgeInsets.fromLTRB(0, 10, 10, 10),
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
child: Text(
'${commentCount}跟帖',
style: TextStyle(fontSize: 10, color: Colors.red),
),
);
} else {
return Container(
padding: EdgeInsets.all(1),
margin: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
'${commentCount}跟帖',
style: TextStyle(fontSize: 10, color: Colors.grey),
),
);
}
}
Widget buildItem2(Data bean) {
return Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
bean.title,
style: TextStyle(fontSize: 17),
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: buildTagText(bean),
),
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
bean.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
buildCommentCountText(bean.commentCount),
],
),
],
),
flex: 7,
),
Expanded(
child: Image.asset(
bean.thumb,
width: 110,
height: 80,
fit: BoxFit.fill,
),
flex: 4,
)
],
),
);
}
Widget buildItem3(Data bean) {
double width = MediaQuery.of(context).size.width;
return Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
bean.title,
style: TextStyle(fontSize: 17),
),
Row(
children: buildImages(width, bean),
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: buildTagText(bean),
),
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
bean.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
buildCommentCountText(bean.commentCount),
],
)
],
),
);
}
List<Widget> buildImages(double width, Data bean) {
List<Widget> children = bean.images.map((urls) {
if (bean.images.length == 1) {
return Padding(
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
child: Image.asset(
urls.imgsrc,
width: width - 20,
height: 150,
fit: BoxFit.fill,
),
);
} else {
return Padding(
padding: EdgeInsets.fromLTRB(5, 10, 5, 0),
child: Image.asset(
urls.imgsrc,
width: (width - 50) / 3,
height: 100,
fit: BoxFit.fill,
),
);
}
}).toList();
return children;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageComment.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/model/HotCommentModel.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageCommentDetails.dart';
import 'package:flutter_news_netbase/part2/utils/NumberUtil.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
class HotPageComment extends StatefulWidget {
@override
_HotPageCommentState createState() => _HotPageCommentState();
}
class _HotPageCommentState extends State<HotPageComment> {
List<Widget> datas;
@override
void initState() {
super.initState();
datas = <Widget>[];
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold(
body: FutureBuilder(
future: rootBundle.loadString('assets/hot_comment.json'),
builder: (BuildContext context, AsyncSnapshot snap) {
if (snap.hasData) {
HotCommentModel model = hotCommentModelFromJson(snap.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
Widget widget = buildItem1(bean,width);
datas.add(widget);
datas.add(Divider(
height: 10,
color: Colors.grey[400],
));
}
return ListView(
children: datas,
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
Widget buildItem1(Data data, double width,{bool showHotComments = true}) {
return GestureDetector(
onTap: () {
print('点击了实时热榜,进入详情页');
gotoNewPage(context, HotPageCommentDetails(data));
},
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//排序
// Align(
// alignment: Alignment.centerLeft,
// child: buildTitles(data),
// ),
Row(
children: <Widget>[
Expanded(
flex: 6,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//标题
Align(
alignment: Alignment.centerLeft,
child: buildTitleInfos(data)),
showHotComments == true
? Align(
alignment: Alignment.centerLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: _buildAvatars(data),
),
)
: Container(),
],
),
),
Expanded(
flex: 4,
child: //右侧图片
Image.asset(
data.img,
width: 150,
height: 75,
fit: BoxFit.fill,
),
),
],
),
//最后一部分,热帖
buildLastContents(width, data),
],
),
),
);
}
Widget buildLastContents(double width, Data data) {
List<Color> colors1 = [
Colors.red,
Colors.redAccent,
Colors.orange,
Colors.orangeAccent,
];
return Container(
width: width,
child: Stack(
children: <Widget>[
Positioned(
child: Container(
width: width,
padding: EdgeInsets.all(5),
margin: EdgeInsets.fromLTRB(45, 5, 0, 5),
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(2),
),
),
child: Text(
'${data.hotCommontPost}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15),
),
),
),
Positioned(
top: 10,
left: 5,
child: buildTitle(
colors1,
Offset(0, 0),
45,
0,
'热帖',
Colors.white
),
),
],
),
);
}
List<Widget> _buildAvatars(Data data) {
List<Widget> children = <Widget>[];
Widget text = Padding(
padding: EdgeInsets.fromLTRB(0, 0, 5, 0),
child: Text(
'网友热议中',
style: TextStyle(fontSize: 10, color: Colors.grey),
),
);
children.add(text);
List<Widget> children2 = data.hotcommontImages.map((img) {
return ClipOval(
child: Image.network(
img.avatar,
width: 20,
height: 20,
fit: BoxFit.fill,
),
);
}).toList();
children.addAll(children2);
return children;
}
Widget buildTitles(Data data) {
List<Color> colors = [
Colors.red,
Colors.redAccent,
Colors.orange,
Colors.orangeAccent,
];
List<Color> colors2 = [
Colors.grey[200],
Colors.grey[200],
Colors.grey[200],
];
String results = parseNumbers(data.hotPoints, '万热度');
int ids = parseNumber2Int(data.articleId);
return Stack(
children: <Widget>[
Positioned(
child: buildTitle(colors2, Offset(27.5, 0), 150, 15, results,
ids >= 4 ? Colors.orange : Colors.red),
),
Positioned(
child: buildTitle(ids >= 4 ? colors2 : colors, Offset(0, 0), 40, 0,
data.articleId, Colors.white),
)
],
);
}
Widget buildTitleInfos(Data data) {
return Container(
padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
child: Text(
data.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 17),
),
);
}
Widget buildCommentCountText(Data data) {
String result =
parseNumbers('${data.commentCount}', '跟帖', fractionDigits: 1);
int ids = parseNumber2Int('${data.articleId}');
String results = result;
//前3位
if (ids <= 3) {
String input = String.fromCharCodes(Runes('\u{1F525}'));
results = '${input} ${result}';
} else {
results = '${result}';
}
if (parseNumber2Int('${data.commentCount}') >= 3000) {
return Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(5),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.red, width: 1),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.red),
),
);
} else {
return Container(
padding: EdgeInsets.all(1),
margin: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
);
}
}
Widget buildTitle(List<Color> colors, Offset startPoint, double width,
double left, String text, Color textColor) {
return ClipPath(
clipper: MyCustomClipper(startPoint, width, 25),
child: Container(
width: width,
height: 25,
alignment: Alignment.center,
decoration: new BoxDecoration(
gradient: LinearGradient(colors: colors),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(3),
bottomLeft: Radius.circular(3),
bottomRight: Radius.circular(20),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(left, 0, 0, 0),
child: Center(
child: Text(
text,
style: TextStyle(
color: textColor, fontWeight: FontWeight.bold, fontSize: 12),
),
),
),
),
);
}
}
class MyCustomClipper extends CustomClipper<Path> {
Offset startPoint;
double width;
double height;
MyCustomClipper(this.startPoint, this.width, this.height);
@override
Path getClip(Size size) {
final path = Path();
path.lineTo(width, 0.0); //宽
path.lineTo(width - 12.5, height); //宽度-12.5
path.lineTo(startPoint.dx, height);
path.lineTo(startPoint.dx + 12.5, 0.0); //起始点的x坐标+12.5
path.close(); //把路径关闭
return path;
}
@override
bool shouldReclip(CustomClipper oldClipper) {
return false;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/VideoPage.dart
|
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:flutter_news_netbase/part2/gestures/GestureUtil.dart';
//视频播放器类
class VideoPage extends StatefulWidget {
String dataSource;
VideoPage(this.dataSource);
@override
_VideoPageState createState() => _VideoPageState();
}
class _VideoPageState extends State<VideoPage> {
VideoPlayerController controller;
bool inits = false;
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return buildGesture(
() {
if (controller.value.isPlaying) {
controller.pause();
} else {
controller.play();
}
},
// Column(
// children: <Widget>[
// SizedBox(
// width: width,
// height: height - 5,
// child: inits
// ? VideoPlayer(controller)
// : Container(
// width: width,
// height: 330,
// color: Colors.teal,
// ),
// ),
// Visibility(
// visible: !inits,
// child: Container(
// height: 5,
// child: VideoProgressIndicator(
// controller,
// allowScrubbing: true,
// colors: VideoProgressColors(
// playedColor: Colors.red[400],
// bufferedColor: Colors.white,
// backgroundColor: Colors.grey),
// ),
// ),
// )
// ],
// ),
Stack(
children: <Widget>[
Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: SizedBox(
width: width,
height: height,
child: inits
? VideoPlayer(controller)
: Container(
width: width,
height: height,
color: Colors.teal,
),
),
),
// 进度条
Positioned(
bottom: 0,
left: 0,
right: 0,
child: VideoProgressIndicator(
controller,
allowScrubbing: true,
colors: VideoProgressColors(
playedColor: Colors.red[400],
bufferedColor: Colors.white,
backgroundColor: Colors.grey),
)),
],
),
);
}
@override
void initState() {
controller = VideoPlayerController.network(widget.dataSource);
controller.initialize();
controller.setVolume(1.0); //音量
controller.addListener(() {
//获取controller里面的值
print(controller.value);
if (inits != controller.value.initialized) {
inits = controller.value.initialized;
setState(() {});
}
//如果出现错误 输出错误
if (controller.value.hasError) {
print(controller.value.errorDescription);
}
});
// 循环播放
controller.setLooping(true);
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/SmallVideoListPage.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/model/SmallVideoModel.dart';
import 'package:flutter_news_netbase/part2/content2/VideoPage.dart';
import 'package:flutter_news_netbase/part2/gestures/GestureUtil.dart';
class SmallVideoListPage extends StatefulWidget {
Data data;
SmallVideoListPage(this.data);
@override
_SmallVideoListPageState createState() => _SmallVideoListPageState();
}
class _SmallVideoListPageState extends State<SmallVideoListPage> {
TextEditingController _controller = TextEditingController();
@override
void initState() {}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return new Scaffold(
// appBar: new AppBar(
// title: Text('视频详情页'),
// ),
body: Builder(
builder: (BuildContext contexts) {
return Container(
width: width,
height: height,
child: Stack(
children: <Widget>[
VideoPage(widget.data.url),
buildAboveContents1(contexts),
buildAboveContents2(widget.data),
buildAboveContents3(widget.data),
buildAboveContents4(width, 45)
],
),
);
},
),
);
}
// 评论框
// 修改4 把输入框 封装成一个类 StatefulWidget
Widget buildAboveContents4(double width, double height) {
return Positioned(
bottom: 12,
//left: ,
right: 10,
child: EditableTextView(width, height),
);
}
Widget buildAboveContents1(BuildContext context) {
return Positioned(
top: 50,
left: 20,
right: 20,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
buildGesture(
() {
Navigator.of(context).pop();
},
Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 30,
),
),
buildGesture(
() {
showBottomSheetViews(context);
},
Container(
child: Icon(
Icons.more_horiz,
color: Colors.white,
size: 30,
),
),
)
],
),
);
}
Widget buildAboveContents2(Data data) {
return Positioned(
bottom: 80,
right: 10,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: Icon(
Icons.thumb_up,
size: 30,
color: Colors.white,
),
),
Container(
padding: EdgeInsets.all(0),
child: Text(
'${data.votecount}',
style: TextStyle(
fontSize: 14,
color: Colors.white,
),
),
),
Container(
padding: EdgeInsets.all(10),
child: Icon(
Icons.chat,
size: 30,
)),
Container(
padding: EdgeInsets.all(0),
child: Text(
'${data.commentCount}',
style: TextStyle(
fontSize: 14,
color: Colors.white,
),
),
),
Container(
padding: EdgeInsets.all(10),
child: Icon(
Icons.call_made,
size: 30,
color: Colors.white,
),
),
Container(
padding: EdgeInsets.all(0),
child: Text(
'分享',
style: TextStyle(
fontSize: 14,
color: Colors.white,
),
)),
],
),
);
}
// 视频作者 ID 关注
Widget buildAboveContents3(Data data) {
return Positioned(
bottom: 60,
left: 10,
right: 25,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(5),
child: ClipOval(
child: Image.network(
'${data.img}',
width: 35,
height: 35,
),
),
),
Container(
margin: EdgeInsets.all(5),
child: Text(
'${data.source}',
style: TextStyle(
fontSize: 14,
color: Colors.white,
),
),
),
buildGesture(
() {
print('点击了关注');
},
Container(
width: 45,
height: 25,
margin: EdgeInsets.all(5),
decoration: new BoxDecoration(
color: Colors.red,
border: new Border.all(
color: Colors.red,
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Icon(
Icons.add,
color: Colors.white,
size: 20,
),
),
),
],
),
Container(
padding: EdgeInsets.all(5),
child: Text(
'${data.title}',
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 14,
color: Colors.white,
),
),
),
],
),
);
}
Widget buildBottomSheetItems(IconData icon, String text) {
return Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Icon(
icon,
size: 35,
),
Text(
text,
style: TextStyle(fontSize: 14),
)
],
),
);
}
showBottomSheetViews(BuildContext context) {
Scaffold.of(context).showBottomSheet((BuildContext contexts) {
return Container(
color: Colors.white10,
height: 150,
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// buildBottomSheetItems(Icons.star_border, '收藏'),
// buildBottomSheetItems(Icons.visibility_off, '不感兴趣'),
// buildBottomSheetItems(Icons.error_outline, '我要报错'),
buildGesture(
() {
print('点击了 收藏');
},
buildBottomSheetItems(Icons.star_border, '收藏'),
),
buildGesture(
() {
print('点击了 不感兴趣');
},
buildBottomSheetItems(Icons.visibility_off, '不感兴趣'),
),
buildGesture(
() {
print('点击了 我要报错');
},
buildBottomSheetItems(Icons.error_outline, '我要报错'),
),
],
),
// Container(
// height: 56,
// color: Colors.white,
// child: Center(
// child: Text(
// '关闭',
// style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
// ),
// ),
// ),
buildGesture(
() {
print('点击了关闭');
Navigator.of(context).pop();
},
Container(
height: 50,
color: Colors.white,
child: Center(
child: Text(
'关闭',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
),
),
],
),
);
});
}
@override
void dispose() {
super.dispose();
}
}
class EditableTextView extends StatefulWidget {
double width;
double height;
EditableTextView(this.width, this.height);
@override
EditableTextViewState createState() => new EditableTextViewState();
}
class EditableTextViewState extends State<EditableTextView> {
TextEditingController _controller;
bool autoFocus = false;
// 焦点
FocusNode focusNode;
@override
void initState() {
super.initState();
_controller = TextEditingController();
focusNode = new FocusNode();
}
@override
Widget build(BuildContext context) {
return Container(
width: widget.width,
height: widget.height,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: widget.width / 12 * 9,
height: widget.height,
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: new TextFormField(
focusNode: focusNode,
autofocus: false,
controller: _controller,
keyboardType: TextInputType.text,
minLines: 1,
// maxLines: 5,
style: TextStyle(color: Colors.white, fontSize: 12),
// textAlign: TextAlign.start,
// onTap: () {
// // 点击时获取焦点
// FocusScope.of(context).requestFocus(focusNode);
// },
// onFieldSubmitted: (data) {},
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.grey[200],
),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1.0,
color: Colors.grey[400],
),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
hintText: '我来说两句',
hintStyle: TextStyle(color: Colors.grey, fontSize: 12),
),
),
),
buildGesture(
() {
print('点击了发送,发送的内容是:${_controller.text.toString()}');
},
Container(
width: 35,
height: 25,
margin: EdgeInsets.fromLTRB(10, 0, 0, 0),
decoration: new BoxDecoration(
color: Colors.grey,
border: new Border.all(
color: Colors.grey,
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Center(
child: Text(
'发送',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
);
}
@override
void dispose() {
focusNode.dispose();
_controller.dispose();
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/VidaoTabPage2.dart
|
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/TabContentsPage.dart';
import 'package:flutter_news_netbase/part2/SearchBar.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
import 'package:flutter_news_netbase/part2/view/TabCommon.dart';
class VideoTabPage2 extends StatefulWidget {
@override
_VideoTabPage2State createState() => _VideoTabPage2State();
}
class _VideoTabPage2State extends State<VideoTabPage2>
with SingleTickerProviderStateMixin {
TabController tabController;
int result = 1;
List<Tab> tabs = [];
List<String> tabStrData = <String>[];
List<Widget> tabWidgets = <Widget>[];
Widget titleWidgets;
TabCommon tabCommon;
@override
void initState() {
super.initState();
tabWidgets = videoTabData;
tabStrData = videoTabsLabels;
//tabCommon = TabCommon(tabStrData, tabWidgets, titleWidgets);
}
void onCancelSearch() {}
void onSearchQueryChanged(String query) {}
@override
Widget build(BuildContext context) {
setState(() {
tabCommon = TabCommon(tabStrData, tabWidgets,
isScrollable: true, key: ObjectKey(VideoTabPage2()));
});
return tabCommon;
}
@override
void dispose() {
super.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageCurrentDetails.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/model/HotCurrentModel.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class HotPageCurrentDetails extends StatefulWidget {
Data data;
HotPageCurrentDetails(this.data);
FlutterWebviewPlugin flutterWebviewPlugin;
@override
_HotPageCurrentDetailsState createState() => _HotPageCurrentDetailsState();
}
class _HotPageCurrentDetailsState extends State<HotPageCurrentDetails> {
@override
void initState() {
super.initState();
widget.flutterWebviewPlugin = FlutterWebviewPlugin();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return WebviewScaffold(
url: widget.data.url,
withZoom: true, //是否可以缩放
withLocalStorage: true, //使用本地存储
hidden: false,
//userAgent: , //模拟浏览器
initialChild: Container(
color: Colors.grey,
width: width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
Text('正在玩命加载中...')
],
)
),
);
}
@override
void dispose(){
super.dispose();
widget.flutterWebviewPlugin.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageCurrent.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_news_netbase/part2/content2/HotPageCurrentDetails.dart';
import 'package:flutter_news_netbase/part2/model/HotCurrentModel.dart';
import 'package:flutter_news_netbase/part2/routes/RouteManager.dart';
import 'package:flutter_news_netbase/part2/utils/NumberUtil.dart';
class HotPageCurrent extends StatefulWidget {
@override
_HotPageCurrentState createState() => _HotPageCurrentState();
}
class _HotPageCurrentState extends State<HotPageCurrent> {
List<Widget> datas;
@override
void initState() {
super.initState();
datas = <Widget>[];
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold(
body: FutureBuilder(
future: rootBundle.loadString('assets/hot_current.json'),
builder: (BuildContext context, AsyncSnapshot snap) {
if (snap.hasData) {
HotCurrentModel model = videoModuleFromJson(snap.data);
for (int i = 0; i < model.data.length; i++) {
Data bean = model.data[i];
print('url:${bean.url}');
switch (bean.type) {
case "1":
Widget widget = buildItem1(bean);
datas.add(widget);
datas.add(Divider(
height: 10,
color: Colors.grey[400],
));
break;
case "2":
Widget widget = buildItem2(width, bean);
datas.add(widget);
datas.add(Divider(
height: 1,
color: Colors.grey[400],
));
break;
}
// Widget result = buildTitles(bean);
// datas.add(result);
}
return ListView(
children: datas,
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
Widget buildTitles(Data data) {
List<Color> colors = [
Colors.red,
Colors.redAccent,
Colors.orange,
Colors.orangeAccent,
];
List<Color> colors2 = [
Colors.grey[200],
Colors.grey[200],
Colors.grey[200],
];
String results = parseNumbers(data.hotPoints, '万热度');
int ids = parseNumber2Int(data.articleId);
return Stack(
children: <Widget>[
Positioned(
child: buildTitle(colors2, Offset(27.5, 0), 150, 15, results,
ids >= 4 ? Colors.orange : Colors.red),
),
Positioned(
child: buildTitle(ids >= 4 ? colors2 : colors, Offset(0, 0), 40, 0,
data.articleId, Colors.white),
)
],
);
}
Widget buildTitle(List<Color> colors, Offset startPoint, double width,
double left, String text, Color textColor) {
return ClipPath(
clipper: MyCustomClipper(startPoint, width, 25),
child: Container(
width: width,
height: 25,
alignment: Alignment.center,
decoration: new BoxDecoration(
gradient: LinearGradient(colors: colors),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(3),
bottomLeft: Radius.circular(3),
bottomRight: Radius.circular(20),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(left, 0, 0, 0),
child: Center(
child: Text(
text,
style: TextStyle(
color: textColor, fontWeight: FontWeight.bold, fontSize: 12),
),
),
),
),
);
}
Widget buildItem1(Data data) {
return GestureDetector(
onTap: (){
print('点击了实时热榜,进入详情页');
gotoNewPage(context, HotPageCurrentDetails(data));
},
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//排序
buildTitles(data),
Row(
children: <Widget>[
Expanded(
flex: 6,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//标题
buildTitleInfos(data),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
//用户
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 10, 10),
child: Text(
data.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
//评论
buildCommentCountText(data),
],
)
],
),
),
Expanded(
flex: 4,
child: //右侧图片
Image.asset(
data.img,
width: 150,
height: 75,
fit: BoxFit.fill,
),
),
],
)
],
),
),
);
}
Widget buildTitleInfos(Data data) {
return Container(
padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
child: Text(
data.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 17),
),
);
}
Widget buildCommentCountText(Data data) {
String result =
parseNumbers('${data.commentCount}', '跟帖', fractionDigits: 1);
int ids = parseNumber2Int('${data.articleId}');
String results = result;
//前3位
if (ids <= 3) {
String input = String.fromCharCodes(Runes('\u{1F525}'));
results = '${input} ${result}';
} else {
results = '${result}';
}
if (parseNumber2Int('${data.commentCount}') >= 3000) {
return Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(5),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.red, width: 1),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.red),
),
);
} else {
return Container(
padding: EdgeInsets.all(1),
margin: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
results,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
);
}
}
Widget buildItem2(double width, Data data) {
return GestureDetector(
onTap: (){
print('点击了实时热榜,进入详情页');
gotoNewPage(context, HotPageCurrentDetails(data));
},
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//排序
buildTitles(data),
//标题
buildTitleInfos(data),
//图片
Image.asset(
data.img,
width: width,
height: 150,
fit: BoxFit.fill,
),
Row(
children: <Widget>[
//用户
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
data.source,
style: TextStyle(fontSize: 10, color: Colors.grey),
),
),
//评论
buildCommentCountText(data),
],
)
],
),
),
);
}
@override
void dispose() {
super.dispose();
}
}
//自定义绘制
class MyCustomClipper extends CustomClipper<Path> {
Offset startPoint;
double width;
double height;
MyCustomClipper(this.startPoint, this.width, this.height);
@override
Path getClip(Size size) {
final path = Path();
path.lineTo(width, 0.0); //宽
path.lineTo(width - 12.5, height); //宽度-12.5
path.lineTo(startPoint.dx, height);
path.lineTo(startPoint.dx + 12.5, 0.0); //起始点的x坐标+12.5
path.close(); //把路径关闭
return path;
}
@override
bool shouldReclip(CustomClipper oldClipper) {
return false;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/content2/HotPageCommentDetails.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_news_netbase/part2/model/HotCommentModel.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class HotPageCommentDetails extends StatefulWidget {
Data data;
HotPageCommentDetails(this.data);
FlutterWebviewPlugin flutterWebviewPlugin;
@override
_HotPageCommentDetailsState createState() => _HotPageCommentDetailsState();
}
class _HotPageCommentDetailsState extends State<HotPageCommentDetails> {
@override
void initState() {
super.initState();
widget.flutterWebviewPlugin = FlutterWebviewPlugin();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return WebviewScaffold(
url: widget.data.url,
withZoom: true, //是否可以缩放
withLocalStorage: true, //使用本地存储
hidden: false,
//userAgent: , //模拟浏览器
initialChild: Container(
color: Colors.grey,
width: width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
Text('正在玩命加载中...')
],
)
),
);
}
@override
void dispose(){
super.dispose();
widget.flutterWebviewPlugin.dispose();
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/model/HotCommentModel.dart
|
import 'dart:convert';
HotCommentModel hotCommentModelFromJson(String str) =>
HotCommentModel.fromJson(json.decode(str));
class HotCommentModel {
List<Data> data;
HotCommentModel({this.data});
//改造成factory函数
factory HotCommentModel.fromJson(Map<String, dynamic> json) {
return HotCommentModel(
data: List<Data>.from(json['data'].map((x) => Data.fromJson(x))));
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
return data;
}
}
class Data {
String sourceId;
String articleId;
String updateTime;
String modifyTime;
String url;
String title;
String source;
String img;
String postid;
String hotPoints;
List<HotcommontImages> hotcommontImages;
String hotCommontPost;
String commentCount;
String votecount;
String replyCount;
Data(
{this.sourceId,
this.articleId,
this.updateTime,
this.modifyTime,
this.url,
this.title,
this.source,
this.img,
this.postid,
this.hotPoints,
this.hotcommontImages,
this.hotCommontPost,
this.commentCount,
this.votecount,
this.replyCount});
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
sourceId: json['sourceId'],
articleId: json['article_id'],
updateTime: json['update_time'],
modifyTime: json['modify_time'],
url: json['url'],
title: json['title'],
source: json['source'],
img: json['img'],
postid: json['postid'],
hotPoints: json['hotPoints'],
hotcommontImages: List<HotcommontImages>.from(
json["hotcommontImages"].map((x) => HotcommontImages.fromJson(x)),
),
commentCount: json['commentCount'],
votecount: json['votecount'],
replyCount: json['replyCount'],
hotCommontPost: json['hotCommontPost']);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['sourceId'] = this.sourceId;
data['article_id'] = this.articleId;
data['update_time'] = this.updateTime;
data['modify_time'] = this.modifyTime;
data['url'] = this.url;
data['title'] = this.title;
data['source'] = this.source;
data['img'] = this.img;
data['postid'] = this.postid;
data['hotPoints'] = this.hotPoints;
if (this.hotcommontImages != null) {
data['hotcommontImages'] =
this.hotcommontImages.map((v) => v.toJson()).toList();
}
data['hotCommontPost'] = this.hotCommontPost;
data['commentCount'] = this.commentCount;
data['votecount'] = this.votecount;
data['replyCount'] = this.replyCount;
return data;
}
}
class HotcommontImages {
String avatar;
HotcommontImages({this.avatar});
// HotcommontImages.fromJson(Map<String, dynamic> json) {
// avatar = json['avatar'];
// }
factory HotcommontImages.fromJson(Map<String, dynamic> json) {
return HotcommontImages(avatar: json['avatar']);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['avatar'] = this.avatar;
return data;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/model/HotCurrentModel.dart
|
import 'package:flutter/material.dart';
import 'dart:convert';
//封装解析json 只需要传入json字符串即可
HotCurrentModel videoModuleFromJson(String str) =>
HotCurrentModel.fromJson(json.decode(str));
class HotCurrentModel {
List<Data> data;
HotCurrentModel({this.data});
//改造成factory函数
factory HotCurrentModel.fromJson(Map<String, dynamic> json) {
return HotCurrentModel(
data: List<Data>.from(json['data'].map((x) => Data.fromJson(x))));
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
return data;
}
}
class Data {
String type;
String sourceId;
String articleId;
String updateTime;
String modifyTime;
String url;
String title;
String source;
String img;
String postid;
String hotPoints;
String commentCount;
String votecount;
String replyCount;
Data(
{this.type,
this.sourceId,
this.articleId,
this.updateTime,
this.modifyTime,
this.url,
this.title,
this.source,
this.img,
this.postid,
this.hotPoints,
this.commentCount,
this.votecount,
this.replyCount});
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
type: json['type'],
sourceId: json['sourceId'],
articleId: json['article_id'],
updateTime: json['update_time'],
modifyTime: json['modify_time'],
url: json['url'],
title: json['title'],
source: json['source'],
img: json['img'],
postid: json['postid'],
hotPoints: json['hotPoints'],
commentCount: json['commentCount'],
votecount: json['votecount'],
replyCount: json['replyCount'],
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['type'] = this.type;
data['sourceId'] = this.sourceId;
data['article_id'] = this.articleId;
data['update_time'] = this.updateTime;
data['modify_time'] = this.modifyTime;
data['url'] = this.url;
data['title'] = this.title;
data['source'] = this.source;
data['img'] = this.img;
data['postid'] = this.postid;
data['hotPoints'] = this.hotPoints;
data['commentCount'] = this.commentCount;
data['votecount'] = this.votecount;
data['replyCount'] = this.replyCount;
return data;
}
}
| 0
|
mirrored_repositories/flutter_news_netbase/lib/part2
|
mirrored_repositories/flutter_news_netbase/lib/part2/model/NewsModel.dart
|
import 'dart:convert';
NewsModel newsModuleFromJson(String str) =>
NewsModel.fromJson(json.decode(str));
class NewsModel {
List<Data> data;
NewsModel({this.data});
// NewsModel.fromJson(Map<String, dynamic> json) {
// if (json['data'] != null) {
// data = new List<Data>();
// json['data'].forEach((v) {
// data.add(new Data.fromJson(v));
// });
// }
// }
//改造成factory函数
factory NewsModel.fromJson(Map<String, dynamic> json) {
return NewsModel(
data: List<Data>.from(
json['data'].map((x) => Data.fromJson(x)),
),
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
return data;
}
}
class Data {
String sourceId;
String articleId;
String updateTime;
String modifyTime;
String url;
String title;
String infos;
String subtitle;
String source;
String tag;
String type;
String thumb;
List<Images> images;
String postid;
String commentCount;
String votecount;
String replyCount;
Data(
{this.sourceId,
this.articleId,
this.updateTime,
this.modifyTime,
this.url,
this.title,
this.infos,
this.subtitle,
this.source,
this.tag,
this.type,
this.thumb,
this.images,
this.postid,
this.commentCount,
this.votecount,
this.replyCount});
// Data.fromJson(Map<String, dynamic> json) {
// sourceId = json['sourceId'];
// articleId = json['article_id'];
// updateTime = json['update_time'];
// modifyTime = json['modify_time'];
// url = json['url'];
// title = json['title'];
// infos = json['infos'];
// subtitle = json['subtitle'];
// source = json['source'];
// tag = json['tag'];
// type = json['type'];
// thumb = json['thumb'];
// if (json['images'] != null) {
// images = new List<Images>();
// json['images'].forEach((v) {
// images.add(new Images.fromJson(v));
// });
// }
// postid = json['postid'];
// commentCount = json['commentCount'];
// votecount = json['votecount'];
// replyCount = json['replyCount'];
// }
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
sourceId: json['sourceId'],
articleId: json['article_id'],
updateTime: json['update_time'],
modifyTime: json['modify_time'],
url: json['url'],
title: json['title'],
infos: json['infos'],
subtitle: json['subtitle'],
source: json['source'],
tag: json['tag'],
type: json['type'],
thumb: json['thumb'],
images: List<Images>.from(
json['images'].map((x) {
return Images.fromJson(x);
}),
),
postid: json['postid'],
commentCount: json['commentCount'],
votecount: json['votecount'],
replyCount: json['replyCount']);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['sourceId'] = this.sourceId;
data['article_id'] = this.articleId;
data['update_time'] = this.updateTime;
data['modify_time'] = this.modifyTime;
data['url'] = this.url;
data['title'] = this.title;
data['infos'] = this.infos;
data['subtitle'] = this.subtitle;
data['source'] = this.source;
data['tag'] = this.tag;
data['type'] = this.type;
data['thumb'] = this.thumb;
if (this.images != null) {
data['images'] = this.images.map((v) => v.toJson()).toList();
}
data['postid'] = this.postid;
data['commentCount'] = this.commentCount;
data['votecount'] = this.votecount;
data['replyCount'] = this.replyCount;
return data;
}
}
class Images {
String imgsrc;
Images({this.imgsrc});
// Images.fromJson(Map<String, dynamic> json) {
// imgsrc = json['imgsrc'];
// }
factory Images.fromJson(Map<String, dynamic> json) {
return Images(
imgsrc: json['imgsrc'],
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['imgsrc'] = this.imgsrc;
return data;
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.