aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/audio_notifier.dart
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:20:58 -0300
committerLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:31:12 -0300
commit70ec8a79a121471a004e7e4c23157d10157e136f (patch)
treea4f9c0a4fac4e4274ec4324a289b6ef62e1c5653 /lib/data/data_providers/audio_notifier.dart
Initial cleanup push.
Based on agldemo2024 on commit 2a5dc04d801134338150c3f6afc67eaa65599763 Disable device preview. Disable Lottie animation. The original commit was b3c493c340fcb4bb0a937692838fc830bec3e9ea but I am just keeping this change, because the json did not really needed to change. I think. Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/data/data_providers/audio_notifier.dart')
-rw-r--r--lib/data/data_providers/audio_notifier.dart25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/data/data_providers/audio_notifier.dart b/lib/data/data_providers/audio_notifier.dart
new file mode 100644
index 0000000..8981036
--- /dev/null
+++ b/lib/data/data_providers/audio_notifier.dart
@@ -0,0 +1,25 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+class AudioNotifier extends StateNotifier<Audio> {
+ AudioNotifier(super.state);
+
+ void resetToDefaults() {
+ state = state.copyWith(treble: 5.0, bass: 5.0, rearFront: 5.0);
+ }
+
+ void setVolume(double newVal) {
+ state = state.copyWith(volume: newVal);
+ }
+
+ void setTreble(double newVal) {
+ state = state.copyWith(treble: newVal);
+ }
+
+ void setBass(double newVal) {
+ state = state.copyWith(bass: newVal);
+ }
+
+ void setRearFront(double newVal) {
+ state = state.copyWith(rearFront: newVal);
+ }
+}
weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* Decoding testcase for callback fields.
 * Run e.g. ./test_encode_callbacks | ./test_decode_callbacks
 */

#include <stdio.h>
#include <pb_decode.h>
#include "callbacks.pb.h"

bool print_string(pb_istream_t *stream, const pb_field_t *field, void **arg)
{
    uint8_t buffer[1024] = {0};
    
    /* We could read block-by-block to avoid the large buffer... */
    if (stream->bytes_left > sizeof(buffer) - 1)
        return false;
    
    if (!pb_read(stream, buffer, stream->bytes_left))
        return false;
    
    /* Print the string, in format comparable with protoc --decode.
     * Format comes from the arg defined in main().
     */
    printf((char*)*arg, buffer);
    return true;
}

bool print_int32(pb_istream_t *stream, const pb_field_t *field, void **arg)
{
    uint64_t value;
    if (!pb_decode_varint(stream, &value))
        return false;
    
    printf((char*)*arg, (long)value);
    return true;
}

bool print_fixed32(pb_istream_t *stream, const pb_field_t *field, void **arg)
{
    uint32_t value;
    if (!pb_decode_fixed32(stream, &value))
        return false;
    
    printf((char*)*arg, (long)value);
    return true;
}

bool print_fixed64(pb_istream_t *stream, const pb_field_t *field, void **arg)
{
    uint64_t value;
    if (!pb_decode_fixed64(stream, &value))
        return false;
    
    printf((char*)*arg, (long long)value);
    return true;
}

int main()
{
    uint8_t buffer[1024];
    size_t length = fread(buffer, 1, 1024, stdin);
    pb_istream_t stream = pb_istream_from_buffer(buffer, length);
    
    /* Note: empty initializer list initializes the struct with all-0.
     * This is recommended so that unused callbacks are set to NULL instead
     * of crashing at runtime.
     */
    TestMessage testmessage = {};
    
    testmessage.submsg.stringvalue.funcs.decode = &print_string;
    testmessage.submsg.stringvalue.arg = "submsg {\n  stringvalue: \"%s\"\n";
    testmessage.submsg.int32value.funcs.decode = &print_int32;
    testmessage.submsg.int32value.arg = "  int32value: %ld\n";
    testmessage.submsg.fixed32value.funcs.decode = &print_fixed32;
    testmessage.submsg.fixed32value.arg = "  fixed32value: %ld\n";
    testmessage.submsg.fixed64value.funcs.decode = &print_fixed64;
    testmessage.submsg.fixed64value.arg = "  fixed64value: %lld\n}\n";
    
    testmessage.stringvalue.funcs.decode = &print_string;
    testmessage.stringvalue.arg = "stringvalue: \"%s\"\n";
    testmessage.int32value.funcs.decode = &print_int32;
    testmessage.int32value.arg = "int32value: %ld\n";
    testmessage.fixed32value.funcs.decode = &print_fixed32;
    testmessage.fixed32value.arg = "fixed32value: %ld\n";
    testmessage.fixed64value.funcs.decode = &print_fixed64;
    testmessage.fixed64value.arg = "fixed64value: %lld\n";
    testmessage.repeatedstring.funcs.decode = &print_string;
    testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n";
    
    if (!pb_decode(&stream, TestMessage_fields, &testmessage))
        return 1;
    
    return 0;
}