Skip to content

Commit

Permalink
Выполнено:
Browse files Browse the repository at this point in the history
1. Изменить формат даты в вертушке.
2. Сохранять файлы в галерею.
3. Создать новую страницу всех видео.
4. Вынести кнопки управления видеоплеером.
5. Реализовать функцию скриншота.
6. Добавить адреса.
  • Loading branch information
Isfun committed Aug 16, 2020
1 parent 9ba2601 commit 1115d86
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 458 deletions.
1 change: 1 addition & 0 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.video_archive">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.video_archive">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
Expand Down
1 change: 1 addition & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
Expand Down
294 changes: 294 additions & 0 deletions lib/choose_video.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:video_archive/video_page.dart';

class ChooseVideo extends StatefulWidget {
ChooseVideo({
@required this.date,
@required this.wholeDay,
});

final DateTime date;
final bool wholeDay;

@override
_ChooseVideoState createState() => _ChooseVideoState();
}

class _ChooseVideoState extends State<ChooseVideo> {
var serverResponse;
var isLoading = false;

_fetchDataDay(DateTime date) async {
setState(() {
isLoading = true;
});
final response = await http.get(
"http://45.84.225.18:81/video-archive.php?q=123&ext=80008&y=${date.year.toString()}&m=${date.month.toString()}&d=${date.day.toString()}&h=all");
if (response.statusCode == 200) {
setState(() {
serverResponse = json.decode(response.body);
print(serverResponse);
isLoading = false;
});
} else {
throw Exception('Не получилось загрузить видео');
}
}

_fetchDataHour(DateTime date) async {
setState(() {
isLoading = true;
});
final response = await http.get(
"http://45.84.225.18:81/video-archive.php?q=123&ext=80008&y=${date.year.toString()}&m=${date.month.toString()}&d=${date.day.toString()}&h=${date.hour.toString()}");
if (response.statusCode == 200) {
setState(() {
serverResponse = json.decode(response.body);
print(serverResponse);
isLoading = false;
});
} else {
throw Exception('Не получилось загрузить видео');
}
}

@override
void initState() {
widget.wholeDay ? _fetchDataDay(widget.date) : _fetchDataHour(widget.date);
// _fetchDataHour(widget.date);
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 20.0,
),
Text(
DateFormat('dd.MM.yyyy').format(widget.date),
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: EdgeInsets.only(
right: 200.0,
bottom: 20.0,
top: 20.0,
),
child: Text(
'Выберите видео:',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Container(
width: 350.0,
//width of the shield
child: isLoading
? Center(
child: CircularProgressIndicator(),
)
: serverResponse['res']
? ListView.separated(
separatorBuilder:
(BuildContext context, int index) => SizedBox(
height: 40.0,
),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () async {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) =>
VideoArchivePageTest(
url:
"http://45.84.225.18:81/video-archive.php?q=123&ext=80008&y=${widget.date.year.toString()}&m=${widget.date.month.toString()}&d=${widget.date.day.toString()}&h=${serverResponse['names'][index]['time'].split(':')[0]}&n=${serverResponse['names'][index]['name']}",
name: serverResponse['names'][index]
['name'],
),
),
);
},
child: Container(
width: 300.0,
height: 140.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 5.0,
spreadRadius: 2.0,
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
border: Border.all(
color: Colors.black54,
),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Container(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Container(
width: 300.0,
child: Row(
children: [
SizedBox(
width: 30,
),
Text(
'Время: ',
style: TextStyle(
fontSize: 18,
color: Colors.blue,
),
),
Text(
serverResponse['names']
[index]['time']
.toString(),
style: TextStyle(
fontSize: 18,
),
),
],
),
),
SizedBox(
height: 20.0,
),
Container(
width: 300.0,
child: Row(
children: [
SizedBox(
width: 30,
),
Text(
'Протяжность: ',
style: TextStyle(
fontSize: 18,
color: Colors.green,
),
),
Text(
DateFormat('ms')
.format(
DateTime(
2001,
6,
19,
0,
0,
serverResponse['names']
[
index]
[
'duration'] !=
''
? double
.parse(
serverResponse['names'][index]
[
'duration']
.toString()
.split(
'.')[0],
).round()
: '',
),
)
.toString(),
style: TextStyle(
fontSize: 18,
),
),
],
),
),
SizedBox(
height: 20.0,
),
Container(
padding: EdgeInsets.only(
left: 30.0,
),
width: 300,
child: FittedBox(
child: Text(
'Нур-Султан, Пушкинская, 15, 37',
maxLines: 2,
style: TextStyle(
color: Colors.grey[600],
),
softWrap: true,
),
),
),
],
),
),
SizedBox(
width: 10,
),
serverResponse['names'][index]
['type'] ==
'in'
? FaIcon(
FontAwesomeIcons
.arrowAltCircleDown,
color: Colors.green,
)
: FaIcon(
FontAwesomeIcons
.arrowAltCircleUp,
color: Colors.red,
),
],
),
),
);
},
itemCount: serverResponse['names'].length,
)
: Text(
'Нет видео',
),
),
],
),
),
),
),
);
}
}
36 changes: 26 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
import 'package:device_preview/device_preview.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_archive/video_archive_page.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'provider/app_data.dart';

void main() {
initializeDateFormatting().then(
(_) => runApp(
DevicePreview(
enabled: false,
builder: (context) => MyApp(),
),
runApp(
DevicePreview(
enabled: false,
builder: (context) => MyApp(),
),
);
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
locale: DevicePreview.of(context).locale,
builder: DevicePreview.appBuilder,
home: VideoArchivePage(),
return ChangeNotifierProvider<AppData>(
create: (context) => AppData(),
child: MaterialApp(
locale: DevicePreview.of(context).locale,
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
// DefaultCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('ru', 'RU'),
// const Locale('en', 'UK'),
],
builder: DevicePreview.appBuilder,
home: VideoArchivePage(),
),
);
}
}
11 changes: 11 additions & 0 deletions lib/provider/app_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

class AppData extends ChangeNotifier {
Widget timePicker;
bool isPaused = false;

togglePauseButton() {
isPaused ? isPaused = false : isPaused = true;
notifyListeners();
}
}
Loading

0 comments on commit 1115d86

Please sign in to comment.