Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
neulbo27 authored Apr 1, 2019
2 parents dc52c3a + c90ef7d commit 9dc8505
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 164 deletions.
16 changes: 7 additions & 9 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -244,24 +245,22 @@
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -274,15 +273,11 @@
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
"${PODS_ROOT}/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/Resources/GoogleMaps.bundle",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMaps.bundle",
);
Expand Down Expand Up @@ -430,6 +425,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.droidknights.flutterdroidknights;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
Expand Down Expand Up @@ -562,6 +558,7 @@
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand Down Expand Up @@ -590,6 +587,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand Down
2 changes: 0 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
52 changes: 52 additions & 0 deletions lib/bloc/schedule_like_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'dart:convert';

import 'package:rxdart/rxdart.dart';
import 'package:shared_preferences/shared_preferences.dart';

import './bloc_provider.dart';

class ScheduleLikeBloc implements BlocBase {
final _likeMap = BehaviorSubject<Map<String, dynamic>>();
Observable<Map<String, dynamic>> get $likeMap => _likeMap.stream;
Base64Codec _base64 = Base64Codec();
Utf8Codec _utf8 = Utf8Codec();
Map<String, dynamic> _map = {};
SharedPreferences prefs;

ScheduleLikeBloc() {
init();
}

void init() async {
prefs = await SharedPreferences.getInstance();
_map = json.decode(prefs.getString('dkf_schedule_like_map') ?? "{}");
_likeMap.add(_map);
}

Future<bool> addLike(String id) {
_map[toBase64(id)] = true;
_likeMap.add(_map);
prefs.setString('dkf_schedule_like_map', json.encode(_map));
return prefs.commit();
}

Future<bool> removeLike(String id) {
_map.remove(toBase64(id));
_likeMap.add(_map);
prefs.setString('dkf_schedule_like_map', json.encode(_map));
return prefs.commit();
}

@override
void dispose() {
_likeMap.close();
}

String toBase64(String str) {
return _base64.encode(_utf8.encode(str));
}

String fromBase64(String str) {
return _base64.decode(str).toString();
}
}
29 changes: 0 additions & 29 deletions lib/bloc/tab_bloc.dart

This file was deleted.

72 changes: 46 additions & 26 deletions lib/droidknightsapp_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,36 @@ import 'package:droidknights/pages/info_page.dart';
import 'package:droidknights/pages/schedule_page.dart';
import 'package:droidknights/res/strings.dart';
import 'package:flutter/material.dart';

import 'bloc/bloc_provider.dart';
import 'bloc/tab_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'dart:io' show Platform;

class DroidknightsAppHome extends StatelessWidget {

class DroidknightsAppHome extends StatefulWidget {
@override
_DroidknightsAppHomeState createState() => _DroidknightsAppHomeState();
}

class _DroidknightsAppHomeState extends State<DroidknightsAppHome> {

int _index = 0;
List<Widget> _pages = [Platform.isAndroid ? InfoPage() : InfoIosPage(), SchedulePage()];

@override
Widget build(BuildContext context) {
final _tabBloc = BlocProvider.of<TabBloc>(context);
return StreamBuilder(
stream: _tabBloc.$bottomTab,
builder: (context, snapshot) {
if (!snapshot.hasData) return Container();
return Platform.isAndroid
? createAndroidWidget(_tabBloc, snapshot)
: createIosWidget();
});
return Platform.isAndroid ? createAndroidWidget() : createIosWidget();
}

Widget createAndroidWidget(TabBloc _tabBloc, var snapshot) {
Widget createAndroidWidget() {

return Scaffold(
body: bodyPages(snapshot.data),
body: bodyPages(),
bottomNavigationBar: BottomNavigationBar(
onTap: (int index) => _tabBloc.changeBottomTab(index),
currentIndex: snapshot.data,
onTap: (int index) => {
setState(() {
_index = index;
})
},
currentIndex: _index,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.info),
Expand All @@ -42,20 +46,36 @@ class DroidknightsAppHome extends StatelessWidget {
));
}

Widget bodyPages(index) {
switch (index) {
case 0:
return Platform.isAndroid ? InfoPage() : InfoIosPage();
case 1:
return SchedulePage();
}
return null;
Widget bodyPages() {
return new Stack(
children: <Widget>[
new Offstage(
offstage: _index != 0,
child: new TickerMode(
enabled: _index == 0,
child: _pages[0],
),
),
new Offstage(
offstage: _index != 1,
child: new TickerMode(
enabled: _index == 1,
child: _pages[1],
),
),
],
);
}

Widget createIosWidget() {
return CupertinoTabScaffold(
backgroundColor: const Color(0xFF112030),
tabBar: CupertinoTabBar(
onTap: (int index) => {
setState(() {
_index = index;
})
},
backgroundColor: CupertinoColors.lightBackgroundGray,
items: [
BottomNavigationBarItem(
Expand All @@ -71,7 +91,7 @@ class DroidknightsAppHome extends StatelessWidget {
tabBuilder: (context, index) {
return CupertinoTabView(
builder: (context) {
return bodyPages(index);
return bodyPages();
},
);
},
Expand Down
10 changes: 1 addition & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ import 'package:flutter/material.dart';
import 'package:droidknights/droidknightsapp_home.dart';
import 'package:droidknights/res/strings.dart';

import 'bloc/bloc_provider.dart';
import 'bloc/tab_bloc.dart';

void main() => runApp(
BlocProvider<TabBloc>(
bloc: TabBloc(),
child: MyApp()
)
);
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Expand Down
36 changes: 20 additions & 16 deletions lib/models/track_schedule.dart
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
class ScheduleListModel{
class ScheduleListModel {
final List<ScheduleModel> list;

ScheduleListModel({this.list});

factory ScheduleListModel.fromJson(List<dynamic> parsedJson) {
List<ScheduleModel> lists = new List<ScheduleModel>();
lists = parsedJson.map((i)=>ScheduleModel.fromJson(i)).toList();
lists = parsedJson.map((i) => ScheduleModel.fromJson(i)).toList();

return ScheduleListModel(
list: lists
);
return ScheduleListModel(list: lists);
}
}
class ScheduleModel{

class ScheduleModel {
final int type;
final String title;
final String time;
final List<SpeakerModel> speakers;
final String contents;

List<String> get names => speakers.map((speaker) => speaker.name).toList();
List<String> get avatarUrls => speakers.map((speaker) => speaker.avatarUrl).toList();
List<String> get avatarUrls =>
speakers.map((speaker) => speaker.avatarUrl).toList();

ScheduleModel({this.type, this.title, this.time, this.speakers, this.contents});
ScheduleModel(
{this.type, this.title, this.time, this.speakers, this.contents});

factory ScheduleModel.fromJson(Map<String, dynamic> parsedJson){
factory ScheduleModel.fromJson(Map<String, dynamic> parsedJson) {
final List<SpeakerModel> speakers = (parsedJson['speakers'] as List)
?.map((e) => e == null ? null : SpeakerModel.fromJson(e as Map<String, dynamic>))
?.toList() ?? [];
?.map((e) => e == null
? null
: SpeakerModel.fromJson(e as Map<String, dynamic>))
?.toList() ??
[];
return ScheduleModel(
type: parsedJson['type'],
title: parsedJson['title'],
time: parsedJson ['time'],
time: parsedJson['time'],
speakers: speakers,
contents: parsedJson ['contents']
);
contents: parsedJson['contents']);
}
}
class SpeakerModel{

class SpeakerModel {
final String name;
final String avatarUrl;

Expand All @@ -49,4 +53,4 @@ class SpeakerModel{
avatarUrl: parsedJson['avatarUrl'],
);
}
}
}
Loading

0 comments on commit 9dc8505

Please sign in to comment.