This repository has been archived by the owner on Feb 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(soundspage): dynamically display list of sounds with ability to …
…update current alarm, also disp re #46
- Loading branch information
Scott Clampet
authored and
Scott Clampet
committed
Jan 7, 2019
1 parent
7d3f040
commit 8b992a1
Showing
6 changed files
with
57 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:snuze/models/sound.dart'; | ||
|
||
List<Sound> sounds = [ | ||
Sound(displayName: "bounce", fileName: "bounce.mp4"), | ||
Sound(displayName: "jiggle", fileName: "jiggle.mp4"), | ||
Sound(displayName: "bump", fileName: "bump.mp4"), | ||
Sound(displayName: "boing", fileName: "boing.mp4"), | ||
Sound(displayName: "sproing", fileName: "sproing.mp4"), | ||
Sound(displayName: "buggle", fileName: "buggle.mp4"), | ||
Sound(displayName: "joggle", fileName: "joggle.mp4"), | ||
Sound(displayName: "jimbo", fileName: "jimbo.mp4"), | ||
Sound(displayName: "flimbo", fileName: "flimbo.mp4"), | ||
Sound(displayName: "bimbo", fileName: "bimbo.mp4"), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:scoped_model/scoped_model.dart'; | ||
|
||
import 'package:snuze/scoped-models/main.dart'; | ||
import 'package:snuze/models/sound.dart'; | ||
|
||
class SoundListItem extends StatelessWidget { | ||
final String sound; | ||
final Sound sound; | ||
|
||
SoundListItem({this.sound}); | ||
|
||
_selectSound(sound, Function updateAlarm) { | ||
print("selecting sound and upating alarm"); | ||
updateAlarm(<String, String>{"sound": sound}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
print("sound:" + sound); | ||
return ListTile( | ||
title: Text(sound), | ||
// trailing: Icon(Icons.check, color: Colors.red,), | ||
onTap: () { | ||
print("$sound tapped"); | ||
}, | ||
); | ||
return ScopedModelDescendant<MainModel>( | ||
builder: (BuildContext context, Widget child, MainModel model) { | ||
return ListTile( | ||
title: Text(sound.displayName), | ||
trailing: model.alarm.sound == sound.fileName | ||
? Icon( | ||
Icons.check, | ||
color: Colors.red, | ||
) | ||
: Text(''), | ||
onTap: () { | ||
print("$sound tapped"); | ||
_selectSound(sound.fileName, model.updateAlarm); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:snuze/pages/sounds/sound_list_item.dart'; | ||
import 'package:snuze/helpers/sounds.dart'; | ||
|
||
class SoundsList extends StatelessWidget { | ||
final List<String> sounds; | ||
|
||
SoundsList({this.sounds}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListView.builder( | ||
itemCount: sounds.length, | ||
itemBuilder: (context, index) { | ||
return Column( | ||
children: <Widget>[ | ||
SoundListItem(sound: sounds[index]), | ||
Divider(), | ||
], | ||
); | ||
}); | ||
|
||
return ListView.builder( | ||
itemCount: sounds.length, | ||
itemBuilder: (context, index) { | ||
return Column( | ||
children: <Widget>[ | ||
SoundListItem(sound: sounds[index]), | ||
Divider(), | ||
], | ||
); | ||
}); | ||
} | ||
} |